Intersection.LineLine (Line, Line, Double., Double., Double, Boolean)
Intersects two lines.
Namespace: Rhino.Geometry.Intersect
Assembly: RhinoCommon (in RhinoCommon.dll)
**Since:**5.0
Syntax
public static bool LineLine( Line lineA, Line lineB, out double a, out double b, double tolerance, bool finiteSegments)
Parameters
lineA
Type: Rhino.Geometry.Line
First line for intersection.
lineB
Type: Rhino.Geometry.Line
Second line for intersection.
a
Type:System.Double.
Parameter on lineA that is closest to LineB. The shortest distance between the lines is the chord from lineA.PointAt(a) to lineB.PointAt(b)
b
Type:System.Double.
Parameter on lineB that is closest to LineA. The shortest distance between the lines is the chord from lineA.PointAt(a) to lineB.PointAt(b)
tolerance
Type:System.Double
If tolerance > 0.0, then an intersection is reported only if the distance between the points is <= tolerance. If tolerance <= 0.0, then the closest point between the lines is reported.
finiteSegments
Type:System.Boolean
If true, the input lines are treated as finite segments. If false, the input lines are treated as infinite lines.
Return Value
Type:Boolean
true if a closest point can be calculated and the result passes the tolerance parameter test; otherwise false.
Remarks
If the lines are exactly parallel, meaning the system of equations used to find a and b has no numerical solution, then false is returned. If the lines are nearly parallel, which is often numerically true even if you think the lines look exactly parallel, then the closest points are found and true is returned. So, if you care about weeding out “parallel” lines, then you need to do something like the following:
bool rc = Intersect.LineLine(lineA, lineB, out a, out b, tolerance, segments);if (rc){ double angle_tol = RhinoMath.ToRadians(1.0); // or whatever double parallel_tol = Math.Cos(angle_tol); if ( Math.Abs(lineA.UnitTangent * lineB.UnitTangent) >= parallel_tol ) { ... do whatever you think is appropriate }}