本文整理汇总了C#中Plane.Project方法的典型用法代码示例。如果您正苦于以下问题:C# Plane.Project方法的具体用法?C# Plane.Project怎么用?C# Plane.Project使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plane
的用法示例。
在下文中一共展示了Plane.Project方法的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: ProjectVectorOnTest
public void ProjectVectorOnTest()
{
var unitVector = UnitVector3D.ZAxis;
var rootPoint = new Point3D(0, 0, 1);
var plane = new Plane(unitVector, rootPoint);
var vector = new Vector3D(1, 0, 0);
var projectOn = plane.Project(vector);
AssertGeometry.AreEqual(new Vector3D(1, 0, 0), projectOn.Direction, float.Epsilon);
AssertGeometry.AreEqual(new Point3D(0, 0, 1), projectOn.ThroughPoint, float.Epsilon);
}
示例3: ProjectPoint
private void ProjectPoint(Point3D pointToProject, Point3D planeRootPoint, UnitVector3D planeNormal, Point3D projectedresult)
{
var plane = new Plane(planeNormal, planeRootPoint);
var projectOn = plane.Project(pointToProject);
AssertGeometry.AreEqual(projectedresult, projectOn, float.Epsilon);
}
示例4: ProjectLineOnTest
public void ProjectLineOnTest()
{
var unitVector = UnitVector3D.ZAxis;
var rootPoint = new Point3D(0, 0, 1);
var plane = new Plane(unitVector, rootPoint);
var line = new Line3D(new Point3D(0, 0, 0), new Point3D(1, 0, 0));
var projectOn = plane.Project(line);
AssertGeometry.AreEqual(new Line3D(new Point3D(0, 0, 1), new Point3D(1, 0, 1)), projectOn, float.Epsilon);
}