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

Intersects two lines.

**Namespace:** Rhino.Geometry.Intersect**Assembly:** RhinoCommon (in RhinoCommon.dll) Version: 5.1.50000.0 (5.0.20693.0)

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

Public Shared Function LineLine (
lineA As Line,
lineB As Line,
<OutAttribute> ByRef a As Double,
<OutAttribute> ByRef b As Double,
tolerance As Double,
finiteSegments As Boolean
) As Boolean

#### Parameters

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

#### 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);
double parallel_tol = Math.Cos(angle_tol);
if ( Math.Abs(lineA.UnitTangent * lineB.UnitTangent) >= parallel_tol )
{
... do whatever you think is appropriate
}
}

Dim rc As Boolean = Intersect.LineLine(lineA, lineB, a, b, tolerance, segments)
If (rc) Then
Dim angle_tol As Double = RhinoMath.ToRadians(1.0)
Dim parallel_tolerance As Double = Math.Cos(angle_tol)
If (Math.Abs(lineA.UnitTangent * lineB.UnitTangent) >= parallel_tolerance) Then
... do whatever you think is appropriate
End If
End If

See Also