Function lineIntersectionKind
Classifies the exact topological relationship of two unbounded lines.
LineIntersectionKind lineIntersectionKind(T)(
Line2!T first,
Line2!T second
) pure nothrow @nogc @safe
if (isIntersectionScalar!T);
Preconditions
- first is finite and nondegenerate;
- second is finite and nondegenerate.
The operation is exact over int, long, float, and double.
real is deliberately outside the robust-topology scalar domain.
Returns
LineIntersectionKind for distinct parallel lines,
LineIntersectionKind for a unique intersection, and
LineIntersectionKind for the same unbounded line.
No allocation is performed.
Complexity
O(1) time and O(1) auxiliary space.
Example
Example classifying unbounded lines through the public package API.
import geo;
alias P = Point2!double;
alias V = Vector2!double;
alias L = Line2!double;
auto horizontal =
L(
P(0.0, 0.0),
P(10.0, 0.0)
);
auto vertical =
L(
P(5.0, -10.0),
V(0.0, 20.0)
);
assert(
lineIntersectionKind(
horizontal,
vertical
) ==
LineIntersectionKind .point
);
assert(
lineIntersectionKind(
horizontal,
L(
P(0.0, 2.0),
V(-20.0, 0.0)
)
) ==
LineIntersectionKind .none
);
assert(
lineIntersectionKind(
horizontal,
L(
P(3.0, 0.0),
V(-7.0, 0.0)
)
) ==
LineIntersectionKind .coincident
);