21#include <boost/test/data/test_case.hpp>
39 BOOST_CHECK( !params.
IsValid() );
43 BOOST_CHECK( !params.
IsValid() );
47 BOOST_CHECK( !params.
IsValid() );
68 BOOST_CHECK( params.
IsValid() );
78 BOOST_CHECK_SMALL(
center.x, 1.0 );
79 BOOST_CHECK_SMALL(
center.y, 1.0 );
86 double expectedSagitta =
radius * ( 1.0 - std::sqrt( 2.0 ) / 2.0 );
87 BOOST_CHECK_CLOSE( params.
GetSagitta(), expectedSagitta, 0.1 );
104 BOOST_CHECK( params.
IsValid() );
114 BOOST_CHECK_SMALL(
center.x, 1.0 );
115 BOOST_CHECK_SMALL(
center.y, 1.0 );
138 double arcAngleRad = 10.0 *
M_PI / 180.0;
139 double halfAngle = arcAngleRad / 2.0;
149 BOOST_CHECK( params.
IsValid() );
155 BOOST_CHECK_CLOSE( params.
GetArcAngle(), arcAngleRad, 1.0 );
159 BOOST_CHECK_SMALL(
center.x, 100.0 );
160 BOOST_CHECK_SMALL(
center.y, 100.0 );
182 BOOST_CHECK_CLOSE( startAngle.
AsDegrees(), 0.0, 1.0 );
204 VECTOR2I mid( cx + midCoord, cy + midCoord );
208 BOOST_CHECK( params.
IsValid() );
215 BOOST_CHECK_CLOSE(
center.x, cx, 0.1 );
216 BOOST_CHECK_CLOSE(
center.y, cy, 0.1 );
261 BOOST_CHECK_CLOSE( normalCCW.
y, -normalCW.
y, 0.1 );
281 BOOST_CHECK_CLOSE( chordMid.
x, 500000.0, 0.001 );
282 BOOST_CHECK_CLOSE( chordMid.
y, 0.0, 0.001 );
301 double uLen = std::sqrt( u.
x * u.
x + u.
y * u.
y );
302 BOOST_CHECK_CLOSE( uLen, 1.0, 0.0001 );
306 double nLen = std::sqrt( n.
x * n.
x + n.
y * n.
y );
307 BOOST_CHECK_CLOSE( nLen, 1.0, 0.0001 );
310 double dot = u.
x * n.
x + u.
y * n.
y;
311 BOOST_CHECK_SMALL( dot, 0.0001 );
329 VECTOR2I mid( -midCoord, -midCoord );
333 BOOST_CHECK( params.
IsValid() );
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Arc geometry computed from a chord-based coordinate system.
double GetRadius() const
Get the arc radius.
EDA_ANGLE GetEndAngle() const
Get the angle from arc center to the end point.
double GetChordLength() const
Get the chord length (distance from start to end).
double GetSagitta() const
Get the sagitta (perpendicular distance from chord midpoint to arc).
VECTOR2D GetNormalUnitVec() const
Get the unit vector perpendicular to the chord, pointing toward the arc center.
VECTOR2D GetChordMidpoint() const
Get the chord midpoint coordinates.
bool Compute(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Compute arc geometry from three points defining the arc.
bool IsValid() const
Check if the parameters represent a valid arc.
double GetCenterOffset() const
Get the distance from chord midpoint to arc center along the normal.
VECTOR2D GetCenterPoint() const
Get the arc center point.
double GetArcAngle() const
Get the arc angle (total angle swept by the arc) in radians.
VECTOR2D GetChordUnitVec() const
Get the unit vector along the chord (from start to end).
EDA_ANGLE GetStartAngle() const
Get the angle from arc center to the start point.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_CASE(DegenerateCases)
Test that degenerate cases (collinear points) return invalid.
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D