Function segmentLength
Euclidean length of a segment.
Uses the same metric computation policy as point-to-point distance.
In particular:
- integer coordinate differences are obtained without signed overflow; - int, long and float geometry compute in double; - real geometry computes in real; - hypot is used indirectly through distance().
Floating-point non-finite coordinates follow the same arithmetic semantics as distance().
This is a metric computation, not an exact topological predicate.
No allocation is performed.
Complexity
O(1) time and O(1) auxiliary space.
Example
Example computing the Euclidean length of a segment.
import geo;
const segment =
Segment2!double(
Point2!double(0.0, 0.0),
Point2!double(3.0, 4.0)
);
assert(segmentLength(segment) == 5.0);