KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ARC_CHORD_PARAMS Class Reference

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
 

Detailed Description

Arc geometry computed from a chord-based coordinate system.

This class computes arc parameters using a coordinate system where:

  • u: unit vector along the chord from start to end
  • n: unit vector perpendicular to the chord, pointing toward the arc center

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.

Member Function Documentation

◆ Compute()

bool ARC_CHORD_PARAMS::Compute ( const VECTOR2I & aStart,
const VECTOR2I & aMid,
const VECTOR2I & aEnd )

Compute arc geometry from three points defining the arc.

Parameters
aStartArc start point
aMidArc midpoint (a point on the arc, not the chord midpoint)
aEndArc end point
Returns
true if valid arc geometry was computed, false if degenerate (collinear points)

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().

◆ GetArcAngle()

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().

◆ GetCenterOffset()

double ARC_CHORD_PARAMS::GetCenterOffset ( ) const
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().

◆ GetCenterPoint()

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().

◆ GetChordLength()

double ARC_CHORD_PARAMS::GetChordLength ( ) const
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().

◆ GetChordMidpoint()

VECTOR2D ARC_CHORD_PARAMS::GetChordMidpoint ( ) const
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().

◆ GetChordUnitVec()

VECTOR2D ARC_CHORD_PARAMS::GetChordUnitVec ( ) const
inline

Get the unit vector along the chord (from start to end).

Definition at line 74 of file arc_chord_params.h.

References m_ux, and m_uy.

Referenced by BOOST_AUTO_TEST_CASE().

◆ GetEndAngle()

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().

◆ GetHalfChord()

double ARC_CHORD_PARAMS::GetHalfChord ( ) const
inline

Get half the chord length.

Definition at line 69 of file arc_chord_params.h.

References m_halfChord.

◆ GetMidX()

double ARC_CHORD_PARAMS::GetMidX ( ) const
inline

Definition at line 135 of file arc_chord_params.h.

References m_midx.

Referenced by ConvertArcToPolyline().

◆ GetMidY()

double ARC_CHORD_PARAMS::GetMidY ( ) const
inline

Definition at line 136 of file arc_chord_params.h.

References m_midy.

Referenced by ConvertArcToPolyline().

◆ GetNormalUnitVec()

VECTOR2D ARC_CHORD_PARAMS::GetNormalUnitVec ( ) const
inline

Get the unit vector perpendicular to the chord, pointing toward the arc center.

Definition at line 79 of file arc_chord_params.h.

References m_nx, and m_ny.

Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ GetNx()

double ARC_CHORD_PARAMS::GetNx ( ) const
inline

Definition at line 133 of file arc_chord_params.h.

References m_nx.

Referenced by ConvertArcToPolyline().

◆ GetNy()

double ARC_CHORD_PARAMS::GetNy ( ) const
inline

Definition at line 134 of file arc_chord_params.h.

References m_ny.

Referenced by ConvertArcToPolyline().

◆ GetRadius()

double ARC_CHORD_PARAMS::GetRadius ( ) const
inline

◆ GetSagitta()

double ARC_CHORD_PARAMS::GetSagitta ( ) const
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().

◆ GetStartAngle()

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().

◆ GetUx()

double ARC_CHORD_PARAMS::GetUx ( ) const
inline

Definition at line 131 of file arc_chord_params.h.

References m_ux.

Referenced by ConvertArcToPolyline().

◆ GetUy()

double ARC_CHORD_PARAMS::GetUy ( ) const
inline

Definition at line 132 of file arc_chord_params.h.

References m_uy.

Referenced by ConvertArcToPolyline().

◆ IsValid()

bool ARC_CHORD_PARAMS::IsValid ( ) const
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().

Member Data Documentation

◆ m_centerOffset

double ARC_CHORD_PARAMS::m_centerOffset = 0.0
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().

◆ m_chordLen

double ARC_CHORD_PARAMS::m_chordLen = 0.0
private

Definition at line 139 of file arc_chord_params.h.

Referenced by Compute(), and GetChordLength().

◆ m_halfChord

double ARC_CHORD_PARAMS::m_halfChord = 0.0
private

Definition at line 140 of file arc_chord_params.h.

Referenced by Compute(), GetArcAngle(), GetEndAngle(), GetHalfChord(), and GetStartAngle().

◆ m_midx

double ARC_CHORD_PARAMS::m_midx = 0.0
private

Definition at line 146 of file arc_chord_params.h.

Referenced by Compute(), GetCenterPoint(), GetChordMidpoint(), and GetMidX().

◆ m_midy

double ARC_CHORD_PARAMS::m_midy = 0.0
private

Chord midpoint coordinates.

Definition at line 146 of file arc_chord_params.h.

Referenced by Compute(), GetCenterPoint(), GetChordMidpoint(), and GetMidY().

◆ m_nx

double ARC_CHORD_PARAMS::m_nx = 0.0
private

◆ m_ny

double ARC_CHORD_PARAMS::m_ny = 0.0
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().

◆ m_radius

double ARC_CHORD_PARAMS::m_radius = 0.0
private

Definition at line 144 of file arc_chord_params.h.

Referenced by Compute(), GetArcAngle(), GetEndAngle(), GetRadius(), and GetStartAngle().

◆ m_sagitta

double ARC_CHORD_PARAMS::m_sagitta = 0.0
private

Definition at line 143 of file arc_chord_params.h.

Referenced by Compute(), GetArcAngle(), and GetSagitta().

◆ m_ux

double ARC_CHORD_PARAMS::m_ux = 0.0
private

Definition at line 141 of file arc_chord_params.h.

Referenced by Compute(), GetChordUnitVec(), GetEndAngle(), GetStartAngle(), and GetUx().

◆ m_uy

double ARC_CHORD_PARAMS::m_uy = 0.0
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().

◆ m_valid

bool ARC_CHORD_PARAMS::m_valid = false
private

Definition at line 147 of file arc_chord_params.h.

Referenced by Compute(), and IsValid().


The documentation for this class was generated from the following files: