本文整理汇总了C#中Sphere.IntersectDistance方法的典型用法代码示例。如果您正苦于以下问题:C# Sphere.IntersectDistance方法的具体用法?C# Sphere.IntersectDistance怎么用?C# Sphere.IntersectDistance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sphere
的用法示例。
在下文中一共展示了Sphere.IntersectDistance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Sphere_IntersectDistance_gives_correct_distance
public void Sphere_IntersectDistance_gives_correct_distance()
{
Ray ray = new Ray(new Point(0.0f, -12.0f, 4.2f), new Vector(1.0f, 0.0f, 0.0f));
var centre = new Point(50.0f, -12.0f, 4.2f);
var radius = 10.0f;
var s = new Sphere(centre, radius);
var distance = s.IntersectDistance(ray);
Assert.AreEqual(40.0f, distance, EPSILON);
}
示例2: Sphere_IntersectDistance_negative_value_given_nonintersecting_ray
public void Sphere_IntersectDistance_negative_value_given_nonintersecting_ray()
{
Ray ray = new Ray(new Point(0.0f, 0.0f, 0.0f), new Vector(1.0f, 0.0f, 0.0f));
var centre = new Point(50.0f, -12.0f, 4.2f);
var radius = 10.0f;
var s = new Sphere(centre, radius);
var distance = s.IntersectDistance(ray);
Assert.IsTrue(distance < 0.0f);
}
示例3: Sphere_IntersectDistance_throws_given_null_ray
public void Sphere_IntersectDistance_throws_given_null_ray()
{
Ray ray = null;
var centre = new Point(50.0f, -12.0f, 4.2f);
var radius = 10.0f;
var s = new Sphere(centre, radius);
s.IntersectDistance(ray);
}