本文整理汇总了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));
}
示例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.");
}
示例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.");
}
示例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.");
}