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


C# BoundingSphere.RayIntersection方法代码示例

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


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

示例1: RayInterSection_OutsideSpherePointingAway_NoIntersection

 public void RayInterSection_OutsideSpherePointingAway_NoIntersection()
 {
     var sphere = new BoundingSphere(new Point3D(0.2, 0.3, 0), 1.0);
     var ray = new Ray3D(sphere.Center + new Vector3D(0.2, 0.3, sphere.Radius), new Vector3D(1, 0.1, 0.1));
     Point3D[] result;
     Assert.IsFalse(sphere.RayIntersection(ray, out result));
 }
开发者ID:ORRNY66,项目名称:helix-toolkit,代码行数:7,代码来源:BoundingSphereTests.cs

示例2: RayInterSection_OnSpherePointingOut_OneIntersection

 public void RayInterSection_OnSpherePointingOut_OneIntersection()
 {
     var sphere = new BoundingSphere(new Point3D(0.2, 0.3, 0), 2.0);
     var ray = new Ray3D(sphere.Center + new Vector3D(0, 0, sphere.Radius), new Vector3D(1, 0.99, 0.87));
     Point3D[] result;
     Assert.IsTrue(sphere.RayIntersection(ray, out result));
     Assert.AreEqual(1, result.Length, "Number of intersections should be 1");
     Assert.AreEqual(sphere.Radius, sphere.Center.DistanceTo(result[0]), 1e-6, "Point is not on sphere.");
     Assert.AreEqual(0, ray.GetNearest(result[0]).DistanceTo(result[0]), 1e-6, "Point is not on ray.");
 }
开发者ID:ORRNY66,项目名称:helix-toolkit,代码行数:10,代码来源:BoundingSphereTests.cs

示例3: RayInterSection_OutsideSpherePointingToCenter_TwoIntersections

        public void RayInterSection_OutsideSpherePointingToCenter_TwoIntersections()
        {
            var sphere = new BoundingSphere(new Point3D(0.2, 0.3, 0), 1.0);
            var p = new Point3D(12, 23, 32);
            var ray = new Ray3D(p, sphere.Center - p);

            Point3D[] result;
            Assert.IsTrue(sphere.RayIntersection(ray, out result));
            Assert.AreEqual(sphere.Radius, sphere.Center.DistanceTo(result[0]), 1e-6, "Point 1 is not on sphere.");
            Assert.AreEqual(0, ray.GetNearest(result[0]).DistanceTo(result[0]), 1e-6, "Point 1" + result[0] + " is not on ray.");
            Assert.AreEqual(sphere.Radius, sphere.Center.DistanceTo(result[1]), 1e-6, "Point 2 is not on sphere.");
            Assert.AreEqual(0, ray.GetNearest(result[1]).DistanceTo(result[1]), 1e-6, "Point 2 " + result[0] + " is not on ray.");
            Assert.IsTrue(ray.Origin.DistanceTo(result[0]) < ray.Origin.DistanceTo(result[1]), "The points should be sorted by distance from ray origin.");
        }
开发者ID:ORRNY66,项目名称:helix-toolkit,代码行数:14,代码来源:BoundingSphereTests.cs

示例4: RayInterSection_OutsideAndTangentToSphere_OneIntersection

        public void RayInterSection_OutsideAndTangentToSphere_OneIntersection()
        {
            var sphere = new BoundingSphere(new Point3D(0.2, 0.3, 0), 1.0);
            var p = new Point3D(sphere.Center.X + sphere.Radius, sphere.Center.Y + sphere.Radius, sphere.Center.Z + 50);
            var p2 = new Point3D(sphere.Center.X + sphere.Radius, sphere.Center.Y, sphere.Center.Z);

            // ray tangent to sphere
            var ray = new Ray3D(p, p2 - p);
            Point3D[] result;
            Assert.IsTrue(sphere.RayIntersection(ray, out result), "No intersection");
            Assert.AreEqual(1, result.Length, "One intersection");
            Assert.AreEqual(sphere.Radius, result[0].DistanceTo(sphere.Center), 1e-8);
            Assert.AreEqual(0, ray.GetNearest(result[0]).DistanceTo(result[0]), 1e-6, "Point 1 is not on ray.");
        }
开发者ID:jcroa,项目名称:helix-toolkit,代码行数:14,代码来源:BoundingSphereTests.cs


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