KiCad PCB EDA Suite
Loading...
Searching...
No Matches
arc_chord_params.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#ifndef ARC_CHORD_PARAMS_H
25#define ARC_CHORD_PARAMS_H
26
27#include <geometry/eda_angle.h>
28#include <math/vector2d.h>
29
44{
45public:
54 bool Compute( const VECTOR2I& aStart, const VECTOR2I& aMid, const VECTOR2I& aEnd );
55
59 bool IsValid() const { return m_valid; }
60
64 double GetChordLength() const { return m_chordLen; }
65
69 double GetHalfChord() const { return m_halfChord; }
70
74 VECTOR2D GetChordUnitVec() const { return VECTOR2D( m_ux, m_uy ); }
75
79 VECTOR2D GetNormalUnitVec() const { return VECTOR2D( m_nx, m_ny ); }
80
84 double GetSagitta() const { return m_sagitta; }
85
89 double GetRadius() const { return m_radius; }
90
94 double GetCenterOffset() const { return m_centerOffset; }
95
100
107 VECTOR2D GetCenterPoint() const;
108
115 EDA_ANGLE GetStartAngle() const;
116
123 EDA_ANGLE GetEndAngle() const;
124
128 double GetArcAngle() const;
129
130 // Direct access to internal parameters for performance-critical code
131 double GetUx() const { return m_ux; }
132 double GetUy() const { return m_uy; }
133 double GetNx() const { return m_nx; }
134 double GetNy() const { return m_ny; }
135 double GetMidX() const { return m_midx; }
136 double GetMidY() const { return m_midy; }
137
138private:
139 double m_chordLen = 0.0;
140 double m_halfChord = 0.0;
141 double m_ux = 0.0, m_uy = 0.0;
142 double m_nx = 0.0, m_ny = 0.0;
143 double m_sagitta = 0.0;
144 double m_radius = 0.0;
145 double m_centerOffset = 0.0;
146 double m_midx = 0.0, m_midy = 0.0;
147 bool m_valid = false;
148};
149
150#endif // ARC_CHORD_PARAMS_H
Arc geometry computed from a chord-based coordinate system.
double GetMidY() const
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).
double GetMidX() const
VECTOR2D GetNormalUnitVec() const
Get the unit vector perpendicular to the chord, pointing toward the arc center.
VECTOR2D GetChordMidpoint() const
Get the chord midpoint coordinates.
double m_ny
Unit vector perpendicular to chord, toward arc center.
bool Compute(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Compute arc geometry from three points defining the arc.
double GetNx() const
bool IsValid() const
Check if the parameters represent a valid arc.
double GetUy() const
double GetCenterOffset() const
Get the distance from chord midpoint to arc center along the normal.
double m_midy
Chord midpoint coordinates.
double m_uy
Unit vector along chord (from start to end)
double GetHalfChord() const
Get half the chord length.
VECTOR2D GetCenterPoint() const
Get the arc center point.
double GetArcAngle() const
Get the arc angle (total angle swept by the arc) in radians.
double m_centerOffset
Distance from chord midpoint to arc center along n.
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.
double GetUx() const
double GetNy() const
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695
VECTOR2< double > VECTOR2D
Definition vector2d.h:694