67 constexpr explicit EDA_ANGLE(
double aAngleInDegrees ) :
73 if( aVector.
x == 0.0 && aVector.
y == 0.0 )
77 else if( aVector.
y == 0.0 )
84 else if( aVector.
x == 0.0 )
86 if( aVector.
y >= 0.0 )
91 else if( aVector.
x == aVector.
y )
93 if( aVector.
x >= 0.0 )
98 else if( aVector.
x == -aVector.
y )
100 if( aVector.
x >= 0.0 )
182 if(
test.m_value == 0.0 ||
test.m_value == 180.0 )
184 else if(
test.m_value == 45.0 ||
test.m_value == 135.0 )
186 else if(
test.m_value == 225.0 ||
test.m_value == 315.0 )
188 else if(
test.m_value == 90.0 )
190 else if(
test.m_value == 270.0 )
201 if(
test.m_value == 0.0 )
203 else if(
test.m_value == 180.0 )
205 else if(
test.m_value == 90.0 ||
test.m_value == 270.0 )
207 else if(
test.m_value == 45.0 ||
test.m_value == 315.0 )
209 else if(
test.m_value == 135.0 ||
test.m_value == 225.0 )
315 double rounded =
KiROUND( angle.
AsDegrees() * pow( 10.0, digits ) ) / pow( 10.0, digits );
340 if( !std::isfinite( aValue ) )
343 if(
std::abs( aValue ) < 2.0 * aPeriod )
347 return std::fmod( aValue, aPeriod ) + std::copysign( aPeriod, aValue );
554 return aOrientation + aAngle;
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
EDA_ANGLE NormalizeNegative()
constexpr EDA_ANGLE(double aAngleInDegrees)
Construct an EDA_ANGLE in degrees.
int AsTenthsOfADegree() const
bool IsParallelTo(EDA_ANGLE aAngle) const
EDA_ANGLE Snapped(const EDA_ANGLE &aStep) const
Snap to the nearest integer multiple of aStep (returns *this if aStep <= 0).
bool IsHorizontal() const
static EDA_ANGLE Arctan2(double y, double x)
EDA_ANGLE KeepUpright() const
EDA_ANGLE & operator-=(const EDA_ANGLE &aAngle)
EDA_ANGLE Round(int digits) const
EDA_ANGLE & operator+=(const EDA_ANGLE &aAngle)
EDA_ANGLE(const VECTOR2D &aVector)
EDA_ANGLE(double aValue, EDA_ANGLE_T aAngleType)
Angles can be created in degrees, 1/10ths of a degree, or radians, and read as any of the angle types...
static double foldToTwoPeriods(double aValue, double aPeriod)
Exactly remove whole periods from values beyond two periods, keeping the sign, so the normalization l...
static constexpr double DEGREES_TO_RADIANS
bool IsCardinal90() const
double m_value
value in degrees
static EDA_ANGLE Arctan(double x)
static EDA_ANGLE Arcsin(double x)
EDA_ANGLE Normalized() const
static EDA_ANGLE Arccos(double x)
An "orientation", held as an angle constrained to the range [0, 360) degrees.
EDA_ANGLE GetAngle() const
EDA_ORIENTATION operator-() const
EDA_ORIENTATION & operator+=(const EDA_ANGLE &aAngle)
EDA_ORIENTATION(const EDA_ANGLE &aAngle)
EDA_ORIENTATION operator-(const EDA_ANGLE &aAngle) const
Subtract an EDA_ANGLE from this orientation, wrapping around the [0, 360) range.
void SetAngle(const EDA_ANGLE &aAngle)
EDA_ANGLE operator-(const EDA_ORIENTATION &aOther) const
The difference of two orientations is a signed rotation amount, not an orientation.
bool operator==(const EDA_ORIENTATION &aOther) const =default
EDA_ORIENTATION()=default
EDA_ORIENTATION & operator=(const EDA_ANGLE &aAngle)
Assign a plain angle, normalising it.
EDA_ORIENTATION operator+(const EDA_ANGLE &aAngle) const
Add an EDA_ANGLE to this orientation, wrapping around the [0, 360) range.
EDA_ORIENTATION & operator-=(const EDA_ANGLE &aAngle)
EDA_ANGLE operator/(const EDA_ANGLE &aAngleA, double aOperator)
bool operator>(const EDA_ANGLE &aAngleA, const EDA_ANGLE &aAngleB)
bool operator>=(const EDA_ANGLE &aAngleA, const EDA_ANGLE &aAngleB)
EDA_ANGLE operator*(const EDA_ANGLE &aAngleA, double aOperator)
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_90
bool operator<=(const EDA_ANGLE &aAngleA, const EDA_ANGLE &aAngleB)
std::ostream & operator<<(std::ostream &aStream, const EDA_ANGLE &aAngle)
EDA_ANGLE operator-(const EDA_ANGLE &aAngle)
bool operator<(const EDA_ANGLE &aAngleA, const EDA_ANGLE &aAngleB)
static constexpr EDA_ANGLE ANGLE_VERTICAL
bool operator==(const EDA_ANGLE &aAngleA, const EDA_ANGLE &aAngleB)
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
static constexpr EDA_ANGLE ANGLE_45
static constexpr EDA_ANGLE ANGLE_270
static constexpr EDA_ANGLE FULL_CIRCLE
static constexpr EDA_ANGLE ANGLE_360
static constexpr EDA_ANGLE ANGLE_180
EDA_ANGLE operator+(const EDA_ANGLE &aAngleA, const EDA_ANGLE &aAngleB)
static constexpr EDA_ANGLE ANGLE_135
bool operator!=(const EDA_ANGLE &aAngleA, const EDA_ANGLE &aAngleB)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
bool equals(glm::mat< L, C, T, Q > const &aFirst, glm::mat< L, C, T, Q > const &aSecond, T aEpsilon=static_cast< T >(FLT_EPSILON *10))
Template to compare two glm::mat<T> values for equality within a required epsilon.
VECTOR2< double > VECTOR2D