本文整理汇总了C#中Plane.SignedDistanceTo方法的典型用法代码示例。如果您正苦于以下问题:C# Plane.SignedDistanceTo方法的具体用法?C# Plane.SignedDistanceTo怎么用?C# Plane.SignedDistanceTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plane
的用法示例。
在下文中一共展示了Plane.SignedDistanceTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IntersectionWith
/// <summary>
/// Find intersection between Line3D and Plane
/// http://geomalgorithms.com/a05-_intersect-1.html
/// </summary>
/// <param name="line"></param>
/// <param name="tolerance"></param>
/// <returns>Intersection Point or null</returns>
public static Point3D IntersectionWith(Plane plane, Line3D line, double tolerance = float.Epsilon)
{
if (line.Direction.IsPerpendicularTo(plane.Normal)) { //either parallel or lies in the plane
Point3D projectedPoint = plane.Project(line.StartPoint, line.Direction);
if (projectedPoint == line.StartPoint) { //Line lies in the plane
throw new InvalidOperationException("Line lies in the plane"); //Not sure what should be done here
} else { // Line and plane are parallel
throw new InvalidOperationException("NULLLLLLL");
}
}
var d = plane.SignedDistanceTo(line.StartPoint);
var u = line.StartPoint.VectorTo(line.EndPoint);
var t = -1 * d / u.DotProduct(plane.Normal);
if (t > 1 || t < 0) { // They are not intersected
throw new InvalidOperationException("NULLLLLLL");
}
return line.StartPoint + (t * u);
}
示例2: SignedDistanceToPoint
public void SignedDistanceToPoint(string prps, string pns, string ps, double expected)
{
var plane = new Plane(UnitVector3D.Parse(pns), Point3D.Parse(prps));
var p = Point3D.Parse(ps);
Assert.AreEqual(expected, plane.SignedDistanceTo(p), 1E-6);
}
示例3: SignedDistanceToRay
public void SignedDistanceToRay(string prps, string pns, string rayThroughPointString, string rayDirectionString, double expectedValue)
{
var plane = new Plane(UnitVector3D.Parse(pns), Point3D.Parse(prps));
var otherPlane = new Ray3D(Point3D.Parse(rayThroughPointString), UnitVector3D.Parse(rayDirectionString));
Assert.AreEqual(expectedValue, plane.SignedDistanceTo(otherPlane), 1E-6);
}
示例4: SignedDistanceToOtherPlane
public void SignedDistanceToOtherPlane(string prps, string pns, string otherPlaneRootPointString, string otherPlaneNormalString, double expectedValue)
{
var plane = new Plane(UnitVector3D.Parse(pns), Point3D.Parse(prps));
var otherPlane = new Plane(UnitVector3D.Parse(otherPlaneNormalString), Point3D.Parse(otherPlaneRootPointString));
Assert.AreEqual(expectedValue, plane.SignedDistanceTo(otherPlane), 1E-6);
}