RhinoCommon SDK

## IntersectionLineLine Method (Line, Line, Double, Double, Double, Boolean) |

Intersects two lines.

Syntax

public static bool LineLine( Line lineA, Line lineB, out double a, out double b, double tolerance, bool finiteSegments )

- lineA
- Type: Rhino.GeometryLine

First line for intersection. - lineB
- Type: Rhino.GeometryLine

Second line for intersection. - a
- Type: SystemDouble

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: SystemDouble

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: SystemDouble

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: SystemBoolean

If true, the input lines are treated as finite segments. If false, the input lines are treated as infinite lines.

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 } }

Version Information

See Also