40 int64_t abX =
static_cast<int64_t
>( b.
x ) - a.
x;
41 int64_t abY =
static_cast<int64_t
>( b.
y ) - a.
y;
42 int64_t acX =
static_cast<int64_t
>( c.
x ) - a.
x;
43 int64_t acY =
static_cast<int64_t
>( c.
y ) - a.
y;
45#if defined( __SIZEOF_INT128__ )
46 __int128 cross =
static_cast<__int128
>( abX ) * acY -
static_cast<__int128
>( abY ) * acX;
48 double cross =
static_cast<double>( abX ) *
static_cast<double>( acY )
49 -
static_cast<double>( abY ) *
static_cast<double>( acX );
52 return cross > 0 ? 1 : ( cross < 0 ? -1 : 0 );
63 double paX =
static_cast<double>( a.
x ) - p.
x, paY =
static_cast<double>( a.
y ) - p.
y;
64 double pbX =
static_cast<double>( b.
x ) - p.
x, pbY =
static_cast<double>( b.
y ) - p.
y;
65 double pcX =
static_cast<double>( c.
x ) - p.
x, pcY =
static_cast<double>( c.
y ) - p.
y;
67 double paSq = paX * paX + paY * paY;
68 double pbSq = pbX * pbX + pbY * pbY;
69 double pcSq = pcX * pcX + pcY * pcY;
71 double det = paX * ( pbY * pcSq - pbSq * pcY ) - paY * ( pbX * pcSq - pbSq * pcX )
72 + paSq * ( pbX * pcY - pbY * pcX );
73 double sumSq = paSq + pbSq + pcSq;
75 return det <= 1e-13 * sumSq * sumSq;
85#if defined( __SIZEOF_INT128__ )
87 int64_t paX =
static_cast<int64_t
>( a.
x ) - p.
x, paY =
static_cast<int64_t
>( a.
y ) - p.
y;
88 int64_t pbX =
static_cast<int64_t
>( b.
x ) - p.
x, pbY =
static_cast<int64_t
>( b.
y ) - p.
y;
89 int64_t pcX =
static_cast<int64_t
>( c.
x ) - p.
x, pcY =
static_cast<int64_t
>( c.
y ) - p.
y;
92 constexpr int64_t kMaxSafeDiff = 1500000000LL;
101 __int128 paSq =
static_cast<__int128
>( paX ) * paX +
static_cast<__int128
>( paY ) * paY;
102 __int128 pbSq =
static_cast<__int128
>( pbX ) * pbX +
static_cast<__int128
>( pbY ) * pbY;
103 __int128 pcSq =
static_cast<__int128
>( pcX ) * pcX +
static_cast<__int128
>( pcY ) * pcY;
105 __int128 det =
static_cast<__int128
>( paX ) * ( pbY * pcSq - pbSq * pcY )
106 -
static_cast<__int128
>( paY ) * ( pbX * pcSq - pbSq * pcX )
107 + paSq * (
static_cast<__int128
>( pbX ) * pcY -
static_cast<__int128
>( pbY ) * pcX );
119 double abX =
static_cast<double>( b.
x ) - a.
x, abY =
static_cast<double>( b.
y ) - a.
y;
120 double bcX =
static_cast<double>( c.
x ) - b.
x, bcY =
static_cast<double>( c.
y ) - b.
y;
121 double caX =
static_cast<double>( a.
x ) - c.
x, caY =
static_cast<double>( a.
y ) - c.
y;
123 double abSquared = abX * abX + abY * abY;
124 double bcSquared = bcX * bcX + bcY * bcY;
125 double caSquared = caX * caX + caY * caY;
127 double longestSquared = std::max( { abSquared, bcSquared, caSquared } );
128 double shortestSquared = std::min( { abSquared, bcSquared, caSquared } );
130 return shortestSquared > 0.0 && longestSquared > 100.0 * shortestSquared;
bool inCircleLegalDouble(const VECTOR2I &a, const VECTOR2I &b, const VECTOR2I &c, const VECTOR2I &p)
Filtered-double legality test; the tie margin treats a near-cocircular quad as legal to keep a flip l...
int OrientationSign(const VECTOR2I &a, const VECTOR2I &b, const VECTOR2I &c)
Orientation of triangle (a, b, c): +1 counter-clockwise, -1 clockwise, 0 collinear.
bool InCircleDelaunayLegal(const VECTOR2I &a, const VECTOR2I &b, const VECTOR2I &c, const VECTOR2I &p)
True when p is outside the circumcircle of CCW triangle (a, b, c): the shared edge is already Delauna...
bool IsSliverTriangle(const VECTOR2I &a, const VECTOR2I &b, const VECTOR2I &c)
A triangle is a sliver when its longest edge exceeds ten times its shortest.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
VECTOR2< int32_t > VECTOR2I