46 const VECTOR2L d1( 2200000000LL, 2200000000LL );
47 const VECTOR2L d2( 2200000000LL, -2200000000LL );
55 const int64_t k = 3000000000LL;
64 constexpr int64_t lo = std::numeric_limits<int64_t>::min();
65 constexpr int64_t hi = std::numeric_limits<int64_t>::max();
77 VECTOR2I a( -1500000000, -1500000000 );
78 VECTOR2I b( 1500000001, 1500000000 );
79 VECTOR2I c( 1500000002, 1500000001 );
88 const VECTOR2I a( 0, 0 ), b( 1000000, 0 ), c( 0, 1000000 );
112 const double up = std::ldexp( 1.0, 64 ) + std::ldexp( 1.0, 12 );
118 BOOST_CHECK_EQUAL( WordsToDouble( 1, uint64_t( 1 ) << 11 ), std::ldexp( 1.0, 64 ) );
124 std::mt19937_64
rng( 4242 );
126 auto operand = [&]() -> int64_t
128 int64_t v =
static_cast<int64_t
>(
rng() );
130 return v >> (
rng() % 64 );
133 for(
int i = 0; i < 100000; i++ )
139 long double cross =
static_cast<long double>( a.
x ) * b.
y -
static_cast<long double>( a.
y ) * b.
x;
140 long double dot =
static_cast<long double>( a.
x ) * b.
x +
static_cast<long double>( a.
y ) * b.
y;
142 BOOST_REQUIRE_CLOSE_FRACTION(
ToDouble(
CrossWide( a, b ) ),
static_cast<double>( cross ), 1e-9 );
143 BOOST_REQUIRE_CLOSE_FRACTION(
ToDouble(
DotWide( a, b ) ),
static_cast<double>( dot ), 1e-9 );
148#if defined( __SIZEOF_INT128__ ) && !defined( _MSC_VER )
152 std::mt19937_64
rng( 987 );
154 for(
int i = 0; i < 300000; i++ )
156 unsigned __int128 mag = (
static_cast<unsigned __int128
>(
rng() ) << 64 ) |
rng();
161 mag &= ~( (
static_cast<unsigned __int128
>( 1 ) << (
rng() % 100 ) ) - 1 );
163 __int128 v =
static_cast<__int128
>( mag );
166 static_cast<double>( v ) );
Exact orientation and in-circle predicates over integer coordinates.
static thread_local boost::mt19937 rng
double WordsToDouble(int64_t aHi, uint64_t aLo)
Nearest double to hi * 2^64 + lo, ties to even.
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...
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL(result, "25.4")
BOOST_AUTO_TEST_CASE(CrossWideKnownValues)
constexpr int sign(T val)
VECTOR2< int32_t > VECTOR2I
VECTOR2< int64_t > VECTOR2L
128-bit integers for exact products of 64-bit coordinate deltas.
constexpr KI_INT128 DotWide(const VECTOR2L &aA, const VECTOR2L &aB)
Exact aA.x * aB.x + aA.y * aB.y.
double ToDouble(KI_INT128 aValue)
constexpr KI_INT128 CrossWide(const VECTOR2L &aA, const VECTOR2L &aB)
Exact aA.x * aB.y - aA.y * aB.x.