Support Forum       G3D Web Page     
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
G3D::CompassDirection Class Reference

Azimuth measured in degrees from 0 = North = -z, increasing clockwise in the ZX plane. More...

Public Member Functions

 CompassDirection (const Any &a)
 
 CompassDirection (float degrees=0)
 Initialize from a compass reading. More...
 
CompassDirection clockwise90Degrees () const
 Synonym for right90Degrees() More...
 
CompassDirection counterclockwise90Degrees () const
 Synonym for left90Degrees() More...
 
CompassDirection left90Degrees () const
 
const StringnearestCompassPointAbbreviation () const
 
const StringnearestCompassPointName () const
 Compounded cardinal and ordinal description, e.g., "Southwest by South". More...
 
 operator Vector3 () const
 Return a vector in the XZ plane pointing along this compass direction. More...
 
bool operator!= (CompassDirection c) const
 True if these are not the same direction modulo 360 degrees. More...
 
CompassDirectionoperator+= (CompassDelta d)
 
CompassDirection operator- () const
 Points in the opposite direction. More...
 
CompassDelta operator- (CompassDirection other) const
 Returns the angle measure of the arc from this to other, going the shorter way around the circle (e.g., -45 instead of +135). More...
 
CompassDirectionoperator-= (CompassDelta d)
 
bool operator== (CompassDirection c) const
 True if these are the same direction modulo 360 degrees. More...
 
CompassDirection port90Degrees () const
 Synonym for left90Degrees() More...
 
CompassDirection right90Degrees () const
 
CompassDirection starboard90Degrees () const
 Synonym for right90Degrees() More...
 
Any toAny () const
 
Matrix3 toHeadingMatrix3 () const
 Rotation matrix to produce this compass direction as a heading for an object that normally faces along its -z axis. More...
 
float value () const
 Always returns a number on the interval [0, 360) More...
 
float zxRadians () const
 Returns the angle in radians in the ZX plane, measured counter-clockwise from the Z axis. More...
 

Static Public Member Functions

static CompassDirection east ()
 
static CompassDirection north ()
 
static CompassDirection south ()
 
static CompassDirection west ()
 

Protected Attributes

float m_angleDegrees
 

Detailed Description

Azimuth measured in degrees from 0 = North = -z, increasing clockwise in the ZX plane.

Because the standard compass conventions are very different from G3D (and most 3D) conventions, this class helps avoid errors when modeling simulations that naturally use compass directions (e.g., boats and planes).

This class does not model differences between true North and magnetic North, or between heading and course.

To avoid ambiguity, no comparison operators (beyond equality) are provided. Use a CompassDelta if you wish to compare directions.

The internal storage is in floating point degrees, so all small integers are exactly represented.

See also
CompassDelta, CompassBearing

Constructor & Destructor Documentation

◆ CompassDirection() [1/2]

G3D::CompassDirection::CompassDirection ( const Any a)

◆ CompassDirection() [2/2]

G3D::CompassDirection::CompassDirection ( float  degrees = 0)
inlineexplicit

Initialize from a compass reading.

Member Function Documentation

◆ clockwise90Degrees()

CompassDirection G3D::CompassDirection::clockwise90Degrees ( ) const
inline

Synonym for right90Degrees()

◆ counterclockwise90Degrees()

CompassDirection G3D::CompassDirection::counterclockwise90Degrees ( ) const
inline

Synonym for left90Degrees()

◆ east()

static CompassDirection G3D::CompassDirection::east ( )
inlinestatic

◆ left90Degrees()

CompassDirection G3D::CompassDirection::left90Degrees ( ) const
inline

◆ nearestCompassPointAbbreviation()

const String& G3D::CompassDirection::nearestCompassPointAbbreviation ( ) const

◆ nearestCompassPointName()

const String& G3D::CompassDirection::nearestCompassPointName ( ) const

Compounded cardinal and ordinal description, e.g., "Southwest by South".

Referenced Code: http://en.wikipedia.org/wiki/Boxing_the_compass

◆ north()

static CompassDirection G3D::CompassDirection::north ( )
inlinestatic

◆ operator Vector3()

G3D::CompassDirection::operator Vector3 ( ) const

Return a vector in the XZ plane pointing along this compass direction.

◆ operator!=()

bool G3D::CompassDirection::operator!= ( CompassDirection  c) const
inline

True if these are not the same direction modulo 360 degrees.

◆ operator+=()

CompassDirection& G3D::CompassDirection::operator+= ( CompassDelta  d)
inline

◆ operator-() [1/2]

CompassDirection G3D::CompassDirection::operator- ( ) const
inline

Points in the opposite direction.

◆ operator-() [2/2]

CompassDelta G3D::CompassDirection::operator- ( CompassDirection  other) const
inline

Returns the angle measure of the arc from this to other, going the shorter way around the circle (e.g., -45 instead of +135).

◆ operator-=()

CompassDirection& G3D::CompassDirection::operator-= ( CompassDelta  d)
inline

◆ operator==()

bool G3D::CompassDirection::operator== ( CompassDirection  c) const
inline

True if these are the same direction modulo 360 degrees.

◆ port90Degrees()

CompassDirection G3D::CompassDirection::port90Degrees ( ) const
inline

Synonym for left90Degrees()

◆ right90Degrees()

CompassDirection G3D::CompassDirection::right90Degrees ( ) const
inline

◆ south()

static CompassDirection G3D::CompassDirection::south ( )
inlinestatic

◆ starboard90Degrees()

CompassDirection G3D::CompassDirection::starboard90Degrees ( ) const
inline

Synonym for right90Degrees()

◆ toAny()

Any G3D::CompassDirection::toAny ( ) const

◆ toHeadingMatrix3()

Matrix3 G3D::CompassDirection::toHeadingMatrix3 ( ) const

Rotation matrix to produce this compass direction as a heading for an object that normally faces along its -z axis.

See also
CoordinateFrame::rotation

◆ value()

float G3D::CompassDirection::value ( ) const
inline

Always returns a number on the interval [0, 360)

Referenced by operator!=(), and operator==().

◆ west()

static CompassDirection G3D::CompassDirection::west ( )
inlinestatic

◆ zxRadians()

float G3D::CompassDirection::zxRadians ( ) const
inline

Returns the angle in radians in the ZX plane, measured counter-clockwise from the Z axis.

i.e., the canonical yaw angle in G3D. The result is not bounded to any particular range; use wrap() to accomplish that.

Member Data Documentation

◆ m_angleDegrees

float G3D::CompassDirection::m_angleDegrees
protected

documentation generated on Wed Nov 24 2021 08:01:54 using doxygen 1.8.15