orientation - multiple declarations

Function orientation

Exact orientation predicate for Point2!int.

Orientation2 orientation(
  Point2!(int) a,
  Point2!(int) b,
  Point2!(int) c
) pure nothrow @nogc @safe;

Returns the mathematically exact orientation over the complete int coordinate domain.

No signed subtraction or multiplication overflow is permitted in the implementation.

A degenerate directed line with a == b is valid and classifies every c as collinear.

No allocation is performed.

Complexity

O(1) time and O(1) auxiliary space.

Function orientation

Exact orientation predicate for Point2!long.

Orientation2 orientation(
  Point2!(long) a,
  Point2!(long) b,
  Point2!(long) c
) pure nothrow @nogc @safe;

Returns the mathematically exact orientation over the complete long coordinate domain.

Product magnitudes are evaluated with exact 128-bit arithmetic. The determinant itself is not materialized; only its sign is determined.

A degenerate directed line with a == b is valid and classifies every c as collinear.

No allocation is performed.

Complexity

O(1) time and O(1) auxiliary space.

Function orientation

Robust orientation predicate for Point2!double.

Orientation2 orientation(
  Point2!(double) a,
  Point2!(double) b,
  Point2!(double) c
) pure nothrow @nogc @safe;

Preconditions

all coordinates are finite.

Returns the mathematically exact orientation of c relative to the directed line a -> b.

Internally the implementation uses:

- a certified floating-point filter; - exact expansion arithmetic for uncertain ordinary cases; - an exact full-range dyadic fallback for extreme finite inputs.

A degenerate directed line with a == b is valid and classifies every c as collinear.

No allocation is performed.

Complexity

O(1) time and O(1) auxiliary space.

Function orientation

Robust orientation predicate for Point2!float.

Orientation2 orientation(
  Point2!(float) a,
  Point2!(float) b,
  Point2!(float) c
) pure nothrow @nogc @safe;

Preconditions

all coordinates are finite.

Every finite IEEE binary32 value is exactly representable as binary64. The coordinates are therefore promoted exactly to double and evaluated by the complete robust binary64 orientation backend.

No predicate information is lost by this promotion.

A degenerate directed line with a == b is valid and classifies every c as collinear.

No allocation is performed.

Complexity

O(1) time and O(1) auxiliary space.

Example

Example using the public package API.

import geo;

alias P = Point2!double;

assert(
    orientation(
        P(0.0, 0.0),
        P(1.0, 0.0),
        P(0.0, 1.0)
    ) == Orientation2.left
);

assert(
    orientation(
        P(0.0, 0.0),
        P(1.0, 0.0),
        P(0.5, 0.0)
    ) == Orientation2.collinear
);