|
KiCad PCB EDA Suite
|
Arc geometry computed from a chord-based coordinate system. More...
#include <arc_chord_params.h>
Public Member Functions | |
| 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 | GetChordLength () const |
| Get the chord length (distance from start to end). | |
| double | GetHalfChord () const |
| Get half the chord length. | |
| VECTOR2D | GetChordUnitVec () const |
| Get the unit vector along the chord (from start to end). | |
| VECTOR2D | GetNormalUnitVec () const |
| Get the unit vector perpendicular to the chord, pointing toward the arc center. | |
| double | GetSagitta () const |
| Get the sagitta (perpendicular distance from chord midpoint to arc). | |
| double | GetRadius () const |
| Get the arc radius. | |
| double | GetCenterOffset () const |
| Get the distance from chord midpoint to arc center along the normal. | |
| VECTOR2D | GetChordMidpoint () const |
| Get the chord midpoint coordinates. | |
| VECTOR2D | GetCenterPoint () const |
| Get the arc center point. | |
| EDA_ANGLE | GetStartAngle () const |
| Get the angle from arc center to the start point. | |
| EDA_ANGLE | GetEndAngle () const |
| Get the angle from arc center to the end point. | |
| double | GetArcAngle () const |
| Get the arc angle (total angle swept by the arc) in radians. | |
| double | GetUx () const |
| double | GetUy () const |
| double | GetNx () const |
| double | GetNy () const |
| double | GetMidX () const |
| double | GetMidY () const |
Private Attributes | |
| double | m_chordLen = 0.0 |
| double | m_halfChord = 0.0 |
| double | m_ux = 0.0 |
| double | m_uy = 0.0 |
| Unit vector along chord (from start to end) | |
| double | m_nx = 0.0 |
| double | m_ny = 0.0 |
| Unit vector perpendicular to chord, toward arc center. | |
| double | m_sagitta = 0.0 |
| double | m_radius = 0.0 |
| double | m_centerOffset = 0.0 |
| Distance from chord midpoint to arc center along n. | |
| double | m_midx = 0.0 |
| double | m_midy = 0.0 |
| Chord midpoint coordinates. | |
| bool | m_valid = false |
Arc geometry computed from a chord-based coordinate system.
This class computes arc parameters using a coordinate system where:
This representation allows arc points to be generated without computing the center point explicitly, which provides better numerical stability for shallow arcs where the center point may be very far from the arc itself.
The class can compute the center point when needed via GetCenterPoint().
Definition at line 43 of file arc_chord_params.h.
| bool ARC_CHORD_PARAMS::Compute | ( | const VECTOR2I & | aStart, |
| const VECTOR2I & | aMid, | ||
| const VECTOR2I & | aEnd ) |
Compute arc geometry from three points defining the arc.
| aStart | Arc start point |
| aMid | Arc midpoint (a point on the arc, not the chord midpoint) |
| aEnd | Arc end point |
Definition at line 30 of file arc_chord_params.cpp.
References std::abs(), m_centerOffset, m_chordLen, m_halfChord, m_midx, m_midy, m_nx, m_ny, m_radius, m_sagitta, m_ux, m_uy, m_valid, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), ConvertArcToPolyline(), and TransformArcToPolygon().
| double ARC_CHORD_PARAMS::GetArcAngle | ( | ) | const |
Get the arc angle (total angle swept by the arc) in radians.
Definition at line 108 of file arc_chord_params.cpp.
References m_halfChord, M_PI, m_radius, and m_sagitta.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and ConvertArcToPolyline().
|
inline |
Get the distance from chord midpoint to arc center along the normal.
Definition at line 94 of file arc_chord_params.h.
References m_centerOffset.
Referenced by BOOST_AUTO_TEST_CASE(), and ConvertArcToPolyline().
| VECTOR2D ARC_CHORD_PARAMS::GetCenterPoint | ( | ) | const |
Get the arc center point.
Note: For shallow arcs, the center may be very far from the arc itself. Consider using the chord-based methods when possible for better numerical stability.
Definition at line 79 of file arc_chord_params.cpp.
References m_centerOffset, m_midx, m_midy, m_nx, and m_ny.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
|
inline |
Get the chord length (distance from start to end).
Definition at line 64 of file arc_chord_params.h.
References m_chordLen.
Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
|
inline |
Get the chord midpoint coordinates.
Definition at line 99 of file arc_chord_params.h.
References m_midx, and m_midy.
Referenced by BOOST_AUTO_TEST_CASE().
|
inline |
Get the unit vector along the chord (from start to end).
Definition at line 74 of file arc_chord_params.h.
Referenced by BOOST_AUTO_TEST_CASE().
| EDA_ANGLE ARC_CHORD_PARAMS::GetEndAngle | ( | ) | const |
Get the angle from arc center to the end point.
In the chord coordinate system, end is at u = +half_chord, so the direction from center to end is: sin(half_angle) * u - cos(half_angle) * n
Definition at line 97 of file arc_chord_params.cpp.
References m_centerOffset, m_halfChord, m_nx, m_ny, m_radius, m_ux, and m_uy.
Referenced by BOOST_AUTO_TEST_CASE(), and TransformArcToPolygon().
|
inline |
Get half the chord length.
Definition at line 69 of file arc_chord_params.h.
References m_halfChord.
|
inline |
Definition at line 135 of file arc_chord_params.h.
References m_midx.
Referenced by ConvertArcToPolyline().
|
inline |
Definition at line 136 of file arc_chord_params.h.
References m_midy.
Referenced by ConvertArcToPolyline().
|
inline |
Get the unit vector perpendicular to the chord, pointing toward the arc center.
Definition at line 79 of file arc_chord_params.h.
Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
|
inline |
Definition at line 133 of file arc_chord_params.h.
References m_nx.
Referenced by ConvertArcToPolyline().
|
inline |
Definition at line 134 of file arc_chord_params.h.
References m_ny.
Referenced by ConvertArcToPolyline().
|
inline |
Get the arc radius.
Definition at line 89 of file arc_chord_params.h.
References m_radius.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), ConvertArcToPolyline(), and TransformArcToPolygon().
|
inline |
Get the sagitta (perpendicular distance from chord midpoint to arc).
Definition at line 84 of file arc_chord_params.h.
References m_sagitta.
Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
| EDA_ANGLE ARC_CHORD_PARAMS::GetStartAngle | ( | ) | const |
Get the angle from arc center to the start point.
In the chord coordinate system, start is at u = -half_chord, so the direction from center to start is: -sin(half_angle) * u - cos(half_angle) * n
Definition at line 86 of file arc_chord_params.cpp.
References m_centerOffset, m_halfChord, m_nx, m_ny, m_radius, m_ux, and m_uy.
Referenced by BOOST_AUTO_TEST_CASE(), and TransformArcToPolygon().
|
inline |
Definition at line 131 of file arc_chord_params.h.
References m_ux.
Referenced by ConvertArcToPolyline().
|
inline |
Definition at line 132 of file arc_chord_params.h.
References m_uy.
Referenced by ConvertArcToPolyline().
|
inline |
Check if the parameters represent a valid arc.
Definition at line 59 of file arc_chord_params.h.
References m_valid.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
|
private |
Distance from chord midpoint to arc center along n.
Definition at line 145 of file arc_chord_params.h.
Referenced by Compute(), GetCenterOffset(), GetCenterPoint(), GetEndAngle(), and GetStartAngle().
|
private |
Definition at line 139 of file arc_chord_params.h.
Referenced by Compute(), and GetChordLength().
|
private |
Definition at line 140 of file arc_chord_params.h.
Referenced by Compute(), GetArcAngle(), GetEndAngle(), GetHalfChord(), and GetStartAngle().
|
private |
Definition at line 146 of file arc_chord_params.h.
Referenced by Compute(), GetCenterPoint(), GetChordMidpoint(), and GetMidX().
|
private |
Chord midpoint coordinates.
Definition at line 146 of file arc_chord_params.h.
Referenced by Compute(), GetCenterPoint(), GetChordMidpoint(), and GetMidY().
|
private |
Definition at line 142 of file arc_chord_params.h.
Referenced by Compute(), GetCenterPoint(), GetEndAngle(), GetNormalUnitVec(), GetNx(), and GetStartAngle().
|
private |
Unit vector perpendicular to chord, toward arc center.
Definition at line 142 of file arc_chord_params.h.
Referenced by Compute(), GetCenterPoint(), GetEndAngle(), GetNormalUnitVec(), GetNy(), and GetStartAngle().
|
private |
Definition at line 144 of file arc_chord_params.h.
Referenced by Compute(), GetArcAngle(), GetEndAngle(), GetRadius(), and GetStartAngle().
|
private |
Definition at line 143 of file arc_chord_params.h.
Referenced by Compute(), GetArcAngle(), and GetSagitta().
|
private |
Definition at line 141 of file arc_chord_params.h.
Referenced by Compute(), GetChordUnitVec(), GetEndAngle(), GetStartAngle(), and GetUx().
|
private |
Unit vector along chord (from start to end)
Definition at line 141 of file arc_chord_params.h.
Referenced by Compute(), GetChordUnitVec(), GetEndAngle(), GetStartAngle(), and GetUy().
|
private |
Definition at line 147 of file arc_chord_params.h.