35 return ( aA - aB ).EuclideanNorm();
55 return s.
Cross( m ) > 0.0 ? 1 : -1;
68 BOOST_CHECK_SMALL( dist( aSol.
mid, aSol.
start ) - dist( aSol.
mid, aSol.
end ), aTol );
87 BOOST_CHECK_SMALL( dist( p,
VECTOR2D( 0, 0 ) ) - dist( p,
VECTOR2D( 1000000, 1000000 ) ), 1.0 );
99 checkConsistent( sol, start,
end );
100 BOOST_CHECK_SMALL( sol.
center.
x, 1.5 );
101 BOOST_CHECK_SMALL( sol.
center.
y, 1.5 );
102 BOOST_CHECK_SMALL( sol.
radius - 1000000.0, 1.5 );
103 BOOST_CHECK_LE( dist( sol.
mid,
VECTOR2D( 707107, 707107 ) ), 1.5 );
104 BOOST_CHECK_SMALL( sweepDegrees( sol ) - 90.0, 1e-2 );
116 checkConsistent( sol, start,
end );
117 BOOST_CHECK_SMALL( sweepDegrees( sol ) - 270.0, 1e-2 );
118 BOOST_CHECK_LE( dist( sol.
mid,
VECTOR2D( -707107, -707107 ) ), 1.5 );
126 const VECTOR2I on( 707107, 707107 );
151 checkConsistent(
up, start,
end );
152 checkConsistent(
down, start,
end );
153 BOOST_CHECK_GT(
up.mid.y, 0 );
154 BOOST_CHECK_LT(
down.mid.y, 0 );
178 checkConsistent( sol, start,
end );
180 BOOST_CHECK_CLOSE( sol.
radius, 5.0e14, 1e-3 );
187 const VECTOR2I start( -2000000000, 0 );
194 BOOST_CHECK_CLOSE( sol.
radius, 2.0e18, 1e-6 );
200 const VECTOR2I start( -2000000000, 0 );
205 checkConsistent( sol, start,
end, 4.0 );
207 BOOST_CHECK_CLOSE( sol.
radius, ( 4.0e18 + 2.25e18 ) / 3.0e9, 1e-6 );
214 const VECTOR2I a( -1000000000, -1000000000 );
215 const VECTOR2I b( 1000000000, 1000000000 );
218 checkConsistent( through, a, b, 4.0 );
219 BOOST_CHECK_SMALL( sweepDegrees( through ) - 180.0, 1e-2 );
222 checkConsistent( mid, a, b, 4.0 );
225 checkConsistent(
center, a, b, 4.0 );
226 BOOST_CHECK_SMALL( sweepDegrees(
center ) - 180.0, 1e-2 );
229 checkConsistent( tangent, a, b, 4.0 );
230 BOOST_CHECK( std::isfinite( tangent.
center.
x ) && std::isfinite( tangent.
center.
y ) );
244 checkConsistent( sol, start,
end );
246 BOOST_CHECK_CLOSE( sol.
radius, ( 500000.0 * 500000.0 + 300000.0 * 300000.0 ) / 600000.0, 1e-6 );
251 checkConsistent( sol, start,
end );
258 const VECTOR2I start( 123457, -98765 );
263 checkConsistent( sol, start,
end );
282 checkConsistent( sol, start,
end );
283 BOOST_CHECK_LE( dist( sol.
center,
VECTOR2D( 500000, 500000 ) ), 1e-6 );
284 BOOST_CHECK_SMALL( sweepDegrees( sol ) - 90.0, 1e-2 );
285 BOOST_CHECK_LE( dist( sol.
mid,
VECTOR2D( 500000, 500000 - 707107 ) ), 1.5 );
296 checkConsistent( sol, start,
end );
297 BOOST_CHECK_SMALL( sweepDegrees( sol ) - 270.0, 1e-2 );
298 BOOST_CHECK_LE( dist( sol.
mid,
VECTOR2D( 500000, 500000 + 707107 ) ), 1.5 );
303 checkConsistent( below, start,
end );
304 BOOST_CHECK_SMALL( sweepDegrees( below ) - 90.0, 1e-2 );
305 BOOST_CHECK_GT( below.
mid.
y, 0 );
317 checkConsistent( minor, start,
end );
318 checkConsistent( major, start,
end );
319 BOOST_CHECK_SMALL( sweepDegrees( minor ) - 180.0, 1e-2 );
320 BOOST_CHECK_SMALL( sweepDegrees( major ) - 180.0, 1e-2 );
340 const VECTOR2I start( 250000, -130000 );
344 const VECTOR2D unit = tangent / tangent.EuclideanNorm();
347 for(
int degrees = 5; degrees < 360; degrees += 10 )
349 for(
double radius : { 3000.0, 400000.0, 90000000.0 } )
351 const double a = degrees *
M_PI / 180.0;
353 start.
y +
KiROUND(
radius * ( unit.
x * std::sin( a ) + unit.
y * std::cos( a ) ) ) );
359 checkConsistent( sol, start,
end, 2.0 );
362 const VECTOR2D travel =
static_cast<double>( orientation( sol ) ) *
VECTOR2D( -radial.
y, radial.
x );
364 BOOST_CHECK_SMALL( radial.
Dot( unit ) * sol.
radius, 1.0 );
365 BOOST_CHECK_GT( travel.
Dot( unit ), 0.999999 );
378 BOOST_CHECK_SMALL( sweepDegrees(
ArcFromStartTangentEnd( start, { 1, 0 }, { 100000, 100000 } ) ) - 90.0, 1e-2 );
381 BOOST_CHECK_SMALL( sweepDegrees(
ArcFromStartTangentEnd( start, { 1, 0 }, { -100000, 100000 } ) ) - 270.0, 1e-2 );
392 BOOST_CHECK_GT(
left.center.y, 0.0 );
393 BOOST_CHECK_LT(
right.center.y, 0.0 );
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
constexpr extended_type Cross(const VECTOR2< T > &aVector) const
Compute cross product of self with aVector.
constexpr extended_type Dot(const VECTOR2< T > &aVector) const
Compute dot product of self with aVector.
Construction helpers for the interactive arc drawing modes.
ARC_SOLUTION ArcFromStartEndCenterDrag(const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCursor, bool aMajor)
Arc from aStart to aEnd centered on aCursor projected onto the chord bisector.
VECTOR2I ProjectToChordBisector(const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCursor)
Project aCursor onto the perpendicular bisector of the chord aStart - aEnd.
ARC_SOLUTION ArcFromStartTangentEnd(const VECTOR2I &aStart, const VECTOR2D &aTangent, const VECTOR2I &aEnd)
Arc leaving aStart along aTangent and ending at aEnd.
ARC_SOLUTION ArcFromStartEndMidDrag(const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCursor)
Arc from aStart to aEnd whose midpoint is aCursor projected onto the chord bisector.
ARC_SOLUTION ArcThroughPoints(const VECTOR2I &aStart, const VECTOR2I &aOnArc, const VECTOR2I &aEnd)
Arc from aStart to aEnd that passes through aOnArc.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
bool valid
False for degenerate input (collinear points, zero chord, etc)
VECTOR2I mid
The point on the arc halfway along the sweep.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_CASE(ProjectLandsOnBisector)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
BOOST_TEST_CONTEXT("Test Clearance")
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D