M_Rhino_Geometry_Intersect_Intersection_LineLine_1 - mcneel/rhinocommon-api-docs GitHub Wiki
Intersects two lines.
Namespace: Rhino.Geometry.Intersect
Assembly: RhinoCommon (in RhinoCommon.dll) Version: Rhino 6.0
C#
public static bool LineLine(
Line lineA,
Line lineB,
out double a,
out double b,
double tolerance,
bool finiteSegments
)
VB
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
- 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.
Type: Boolean
true if a closest point can be calculated and the result passes the tolerance parameter test; otherwise false.
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:
C#
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
}
}
VB
Dim rc As Boolean = Intersect.LineLine(lineA, lineB, a, b, tolerance, segments)
If (rc) Then
Dim angle_tol As Double = RhinoMath.ToRadians(1.0) 'or whatever
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
Supported in: 6.0.16224.21491, 5D58w
Intersection Class
LineLine Overload
Rhino.Geometry.Intersect Namespace