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

An "orientation", held as an angle constrained to the range [0, 360) degrees. More...

#include <eda_angle.h>

Public Member Functions

 EDA_ORIENTATION ()=default
 
 EDA_ORIENTATION (const EDA_ANGLE &aAngle)
 
EDA_ORIENTATION & operator= (const EDA_ANGLE &aAngle)
 Assign a plain angle, normalising it.
 
bool operator== (const EDA_ORIENTATION &aOther) const =default
 
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) const
 Subtract an EDA_ANGLE from this orientation, wrapping around the [0, 360) range.
 
EDA_ORIENTATION operator- () const
 
EDA_ANGLE operator- (const EDA_ORIENTATION &aOther) const
 The difference of two orientations is a signed rotation amount, not an orientation.
 
EDA_ORIENTATION & operator+= (const EDA_ANGLE &aAngle)
 
EDA_ORIENTATION & operator-= (const EDA_ANGLE &aAngle)
 
EDA_ANGLE GetAngle () const
 
void SetAngle (const EDA_ANGLE &aAngle)
 

Private Attributes

EDA_ANGLE m_angle
 

Detailed Description

An "orientation", held as an angle constrained to the range [0, 360) degrees.

This makes sure that orientations are always in their normalized form, which keeps equality, serialisation and display stable.

Adding or subtracting EDA_ANGLEs and negation wrap around the [0, 360) range.

There is no meaningful multiplication: e.g. 45 and 405 are the same orientation, yet their halves are 22.5 and 202.5. In the same way that there's no such thing as "3 x East".

Do not use this class for angle magnitudes such as an arc extent or an angular spacing, because those are not constrained to [0, 360). In particular, arc extent has a meaningful value of 360 degrees that is distinct from 0.

Definition at line 472 of file eda_angle.h.

Constructor & Destructor Documentation

◆ EDA_ORIENTATION() [1/2]

EDA_ORIENTATION::EDA_ORIENTATION ( )
default

◆ EDA_ORIENTATION() [2/2]

EDA_ORIENTATION::EDA_ORIENTATION ( const EDA_ANGLE & aAngle)
inlineexplicit

Definition at line 477 of file eda_angle.h.

References SetAngle().

Member Function Documentation

◆ GetAngle()

◆ operator+()

EDA_ORIENTATION EDA_ORIENTATION::operator+ ( const EDA_ANGLE & aAngle) const
inline

Add an EDA_ANGLE to this orientation, wrapping around the [0, 360) range.

Definition at line 493 of file eda_angle.h.

References EDA_ORIENTATION(), and m_angle.

◆ operator+=()

EDA_ORIENTATION & EDA_ORIENTATION::operator+= ( const EDA_ANGLE & aAngle)
inline

Definition at line 521 of file eda_angle.h.

References EDA_ORIENTATION(), m_angle, and SetAngle().

◆ operator-() [1/3]

EDA_ORIENTATION EDA_ORIENTATION::operator- ( ) const
inline

Definition at line 506 of file eda_angle.h.

References EDA_ORIENTATION(), and m_angle.

◆ operator-() [2/3]

EDA_ORIENTATION EDA_ORIENTATION::operator- ( const EDA_ANGLE & aAngle) const
inline

Subtract an EDA_ANGLE from this orientation, wrapping around the [0, 360) range.

Definition at line 501 of file eda_angle.h.

References EDA_ORIENTATION(), and m_angle.

◆ operator-() [3/3]

EDA_ANGLE EDA_ORIENTATION::operator- ( const EDA_ORIENTATION & aOther) const
inline

The difference of two orientations is a signed rotation amount, not an orientation.

The sign of the result indicates the direction of the difference of the two orientations.

Definition at line 516 of file eda_angle.h.

References EDA_ORIENTATION(), and m_angle.

◆ operator-=()

EDA_ORIENTATION & EDA_ORIENTATION::operator-= ( const EDA_ANGLE & aAngle)
inline

Definition at line 527 of file eda_angle.h.

References EDA_ORIENTATION(), m_angle, and SetAngle().

◆ operator=()

EDA_ORIENTATION & EDA_ORIENTATION::operator= ( const EDA_ANGLE & aAngle)
inline

Assign a plain angle, normalising it.

Definition at line 482 of file eda_angle.h.

References EDA_ORIENTATION(), and SetAngle().

◆ operator==()

bool EDA_ORIENTATION::operator== ( const EDA_ORIENTATION & aOther) const
default

References EDA_ORIENTATION().

◆ SetAngle()

void EDA_ORIENTATION::SetAngle ( const EDA_ANGLE & aAngle)
inline

Definition at line 535 of file eda_angle.h.

References ANGLE_0, and m_angle.

Referenced by BOOST_AUTO_TEST_CASE(), EDA_ORIENTATION(), operator+=(), operator-=(), and operator=().

Member Data Documentation

◆ m_angle

EDA_ANGLE EDA_ORIENTATION::m_angle
private

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