Struct Line2
An unbounded line in two-dimensional Euclidean space.
struct Line2(T)
if (isGeoScalar!T);
Supported scalar types are int, long, float, double, and real.
A line can be constructed either from two points or from one point and a direction vector. Both construction forms are direct and infallible; they preserve the supplied scalar values without converting one representation into the other.
Line2 is finite and degenerate.
Degeneracy is exact:
- a point/point line is degenerate when both stored points are equal; - a point/direction line is degenerate when both direction components are zero.
No epsilon or tolerance is used.
Ordinary == and != are deliberately unavailable. Stored representation
equality does not express geometric line identity; geometric coincidence is
classified by the line-intersection API.
The retained point/point versus point/direction storage form is private.
Line2 exposes no representation-dependent point, direction, or storage-tag
accessor.
Constructors
| Name | Description |
|---|---|
this
(a, b)
|
Constructs an unbounded line from two points. |
this
(point, direction)
|
Constructs an unbounded line from a point and direction vector. |
Properties
| Name | Type | Description |
|---|---|---|
isDegenerate[get]
|
bool | True when this stored representation does not define a usable unbounded line. |
isFinite[get]
|
bool | True when every scalar stored by the selected representation is finite. |
Example
Example constructing lines through the public package API.
import geo;
alias P = Point2!double;
alias V = Vector2!double;
alias L = Line2!double;
auto fromPoints =
L(
P(1.0, 2.0),
P(4.0, 6.0)
);
auto fromDirection =
L(
P(1.0, 2.0),
V(3.0, 4.0)
);
assert(fromPoints .isFinite);
assert(!fromPoints .isDegenerate);
assert(fromDirection .isFinite);
assert(!fromDirection .isDegenerate);