当前位置: 首页>>代码示例>>C#>>正文


C# BoundingSphere.SupportMapping方法代码示例

本文整理汇总了C#中BoundingSphere.SupportMapping方法的典型用法代码示例。如果您正苦于以下问题:C# BoundingSphere.SupportMapping方法的具体用法?C# BoundingSphere.SupportMapping怎么用?C# BoundingSphere.SupportMapping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BoundingSphere的用法示例。


在下文中一共展示了BoundingSphere.SupportMapping方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GjkBatteryTest

        public void GjkBatteryTest()
        {
            Gjk gjk = new Gjk();

            const int iterations = 10000;

            //Point to point test
            for (int i = 0; i < iterations; ++i)
            {
                gjk.Reset();

                Vector3 point1 = Utilities.GenerateVector3();
                Vector3 point2 = Utilities.GenerateVector3();
                float expected = Vector3.Distance(point1, point2);

                float actual = gjk.GetMinimumDistance(v =>
                    {
                        return point1 - point2;
                    });

                Utilities.AreEqual(expected, actual);
            }

            //Sphere to sphere test
            for (int i = 0; i < iterations; ++i)
            {
                gjk.Reset();

                BoundingSphere shape1 = new BoundingSphere(Utilities.GenerateVector3(), Utilities.GenerateFloat());
                BoundingSphere shape2 = new BoundingSphere(Utilities.GenerateVector3(), Utilities.GenerateFloat());
                float expected = Collision.DistanceSphereSphere(ref shape1, ref shape2);

                if (Collision.SphereIntersectsSphere(ref shape1, ref shape2))
                {
                    i--;
                    continue;
                }

                float actual = gjk.GetMinimumDistance(v =>
                {
                    Vector3 a = shape1.SupportMapping(v);
                    Vector3 b = shape2.SupportMapping(-v);

                    return a - b;
                });

                Utilities.AreEqual(expected, actual);
            }

            //Box to box test
            for (int i = 0; i < iterations; ++i)
            {
                gjk.Reset();

                BoundingBox shape1 = new BoundingBox(Utilities.GenerateVector3(), Utilities.GenerateVector3());
                BoundingBox shape2 = new BoundingBox(Utilities.GenerateVector3(), Utilities.GenerateVector3());
                float expected = Collision.DistanceBoxBox(ref shape1, ref shape2);

                if (Collision.BoxIntersectsBox(ref shape1, ref shape2))
                {
                    i--;
                    continue;
                }

                float actual = gjk.GetMinimumDistance(v =>
                {
                    Vector3 a = shape1.SupportMapping(v);
                    Vector3 b = shape2.SupportMapping(-v);

                    return a - b;
                });

                Utilities.AreEqual(expected, actual);
            }
        }
开发者ID:samitc,项目名称:slimmath,代码行数:75,代码来源:GjkTest.cs

示例2: GjkRealTest

        public void GjkRealTest()
        {
            Gjk gjk = new Gjk();

            BoundingSphere shape1 = new BoundingSphere(new Vector3(30, 52, 119), 91);
            BoundingSphere shape2 = new BoundingSphere(new Vector3(139, 13, 35), 49);

            float expected = Collision.DistanceSphereSphere(ref shape1, ref shape2);

            //BoundingSphere shape1 = new BoundingSphere(new Vector3(-10.01f, 99f, 2.7f), 0.0001f);
            //BoundingSphere shape2 = new BoundingSphere(new Vector3(12.7f, 2f, -120.07f), 0.0001f);

            //BoundingSphere shape1 = new BoundingSphere(new Vector3(0, 15, 0), 1);
            //BoundingBox shape1 = new BoundingBox(new Vector3(0, 0, 0), new Vector3(1, 1, 1));
            //BoundingBox shape2 = new BoundingBox(new Vector3(0, 2, 0), new Vector3(3, 3, 3));

            float distance = gjk.GetMinimumDistance(v =>
                {
                    Vector3 a = shape1.SupportMapping(v);
                    Vector3 b = shape2.SupportMapping(-v);

                    return a - b;
                }, maxIterations: 50);
        }
开发者ID:samitc,项目名称:slimmath,代码行数:24,代码来源:GjkTest.cs


注:本文中的BoundingSphere.SupportMapping方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。