lsst.geom  15.0-1-g417ea41+4
Public Member Functions | Friends | Related Functions | List of all members
lsst::geom::Angle Class Referencefinal

A class representing an angle. More...

#include <Angle.h>

Public Member Functions

constexpr Angle (double val, AngleUnit units=radians) noexcept
 Construct an Angle with the specified value (interpreted in the given units). More...
 
constexpr Angle () noexcept
 Construct the zero angle. More...
 
constexpr Angle (Angle const &other) noexcept=default
 Copy constructor. More...
 
constexpr Angle (Angle &&other) noexcept=default
 Move constructor. More...
 
Angleoperator= (Angle const &other) noexcept=default
 Copy assignment. More...
 
Angleoperator= (Angle &&other) noexcept=default
 Move assignment. More...
 
 ~Angle ()=default
 
constexpr operator double () const noexcept
 Convert an Angle to a double in radians. More...
 
constexpr double asAngularUnits (AngleUnit const &units) const noexcept
 Return an Angle's value in the specified units. More...
 
constexpr double asRadians () const noexcept
 Return an Angle's value in radians. More...
 
constexpr double asDegrees () const noexcept
 Return an Angle's value in degrees. More...
 
constexpr double asHours () const noexcept
 Return an Angle's value in hours. More...
 
constexpr double asArcminutes () const noexcept
 Return an Angle's value in arcminutes. More...
 
constexpr double asArcseconds () const noexcept
 Return an Angle's value in arcseconds. More...
 
Angle wrap () const noexcept
 Wrap this angle to the range [0, 2π). More...
 
Angle wrapCtr () const noexcept
 Wrap this angle to the range [-π, π). More...
 
Angle wrapNear (Angle const &refAng) const noexcept
 Wrap this angle to a value x such that -π ≤ x - refAng ≤ π, approximately. More...
 
Angle separation (Angle const &other) const noexcept
 The signed difference between two Angles. More...
 
Angleoperator*= (double const &d) noexcept
 Multiply this angle by the given factor. More...
 
Angleoperator*= (int const &d) noexcept
 Multiply this angle by the given factor. More...
 
Angleoperator+= (double const &d) noexcept
 Increase this angle by the given number of radians. More...
 
Angleoperator+= (int const &d) noexcept
 Increase this angle by the given number of radians. More...
 
Angleoperator-= (double const &d) noexcept
 Decrease this angle by the given number of radians. More...
 
Angleoperator-= (int const &d) noexcept
 Decrease this angle by the given number of radians. More...
 
constexpr bool operator== (const Angle &rhs) const noexcept
 Test if two Angles represent the same angle (without wrapping). More...
 
constexpr bool operator!= (const Angle &rhs) const noexcept
 Test if two Angles represent the same angle (without wrapping). More...
 
constexpr bool operator<= (const Angle &rhs) const noexcept
 Compare the sizes of two Angles (without wrapping). More...
 
constexpr bool operator>= (const Angle &rhs) const noexcept
 Compare the sizes of two Angles (without wrapping). More...
 
constexpr bool operator< (const Angle &rhs) const noexcept
 Compare the sizes of two Angles (without wrapping). More...
 
constexpr bool operator> (const Angle &rhs) const noexcept
 Compare the sizes of two Angles (without wrapping). More...
 

Friends

class AngleUnit
 

Related Functions

(Note that these are not member functions.)

constexpr Angle operator+ (Angle a, Angle d) noexcept
 Sum of two angles. More...
 
constexpr Angle operator- (Angle a, Angle d) noexcept
 Difference of two angles. More...
 
constexpr Angle operator* (Angle a, Angle d) noexcept
 Product of two angles. More...
 
constexpr Angle operator- (Angle angle)
 An angle in the opposite sense. More...
 
constexpr Angle operator/ (Angle a, int d) noexcept
 Ratio of an angle and a scalar. More...
 
constexpr Angle operator/ (Angle a, double d) noexcept
 Ratio of an angle and a scalar. More...
 
std::ostreamoperator<< (std::ostream &s, Angle a)
 Print an Angle to a stream. More...
 
template<typename T >
constexpr Angle operator* (T lhs, AngleUnit rhs) noexcept
 Use AngleUnit to convert a POD (e.g. int, double) to an Angle; e.g. 180*degrees. More...
 
constexpr Angle operator* (Angle a, double d) noexcept
 Product of an angle and a scalar. More...
 

Detailed Description

A class representing an angle.

Angles may be manipulated like doubles, and automatically converted to doubles, but they may not be constructed from doubles without calling a constructor or multiplying by an AngleUnit. Angles can be modified only by assignment; all other operations that transform an Angle return a new Angle instead.

Unless otherwise specified, all methods and associated operators shall not throw exceptions.

Definition at line 120 of file Angle.h.

Constructor & Destructor Documentation

◆ Angle() [1/4]

constexpr lsst::geom::Angle::Angle ( double  val,
AngleUnit  units = radians 
)
inlineexplicitnoexcept

Construct an Angle with the specified value (interpreted in the given units).

Parameters
valthe size of the angle
unitsthe units in which val is measured

Definition at line 129 of file Angle.h.

◆ Angle() [2/4]

constexpr lsst::geom::Angle::Angle ( )
inlinenoexcept

Construct the zero angle.

Definition at line 132 of file Angle.h.

◆ Angle() [3/4]

constexpr lsst::geom::Angle::Angle ( Angle const &  other)
defaultnoexcept

Copy constructor.

◆ Angle() [4/4]

constexpr lsst::geom::Angle::Angle ( Angle &&  other)
defaultnoexcept

Move constructor.

◆ ~Angle()

lsst::geom::Angle::~Angle ( )
default

Member Function Documentation

◆ asAngularUnits()

constexpr double lsst::geom::Angle::asAngularUnits ( AngleUnit const &  units) const
inlinenoexcept

Return an Angle's value in the specified units.

Parameters
unitsthe units in which the angle's value is desired (e.g. degrees).

Definition at line 156 of file Angle.h.

◆ asArcminutes()

constexpr double lsst::geom::Angle::asArcminutes ( ) const
inlinenoexcept

Return an Angle's value in arcminutes.

Definition at line 168 of file Angle.h.

◆ asArcseconds()

constexpr double lsst::geom::Angle::asArcseconds ( ) const
inlinenoexcept

Return an Angle's value in arcseconds.

Definition at line 171 of file Angle.h.

◆ asDegrees()

constexpr double lsst::geom::Angle::asDegrees ( ) const
inlinenoexcept

Return an Angle's value in degrees.

Definition at line 162 of file Angle.h.

◆ asHours()

constexpr double lsst::geom::Angle::asHours ( ) const
inlinenoexcept

Return an Angle's value in hours.

Definition at line 165 of file Angle.h.

◆ asRadians()

constexpr double lsst::geom::Angle::asRadians ( ) const
inlinenoexcept

Return an Angle's value in radians.

Definition at line 159 of file Angle.h.

◆ operator double()

constexpr lsst::geom::Angle::operator double ( ) const
inlinenoexcept

Convert an Angle to a double in radians.

Definition at line 149 of file Angle.h.

◆ operator!=()

constexpr bool lsst::geom::Angle::operator!= ( const Angle rhs) const
inlinenoexcept

Test if two Angles represent the same angle (without wrapping).

Definition at line 255 of file Angle.h.

◆ operator*=() [1/2]

Angle& lsst::geom::Angle::operator*= ( double const &  d)
inlinenoexcept

Multiply this angle by the given factor.

Definition at line 233 of file Angle.h.

◆ operator*=() [2/2]

Angle& lsst::geom::Angle::operator*= ( int const &  d)
inlinenoexcept

Multiply this angle by the given factor.

Definition at line 234 of file Angle.h.

◆ operator+=() [1/2]

Angle& lsst::geom::Angle::operator+= ( double const &  d)
inlinenoexcept

Increase this angle by the given number of radians.

Definition at line 238 of file Angle.h.

◆ operator+=() [2/2]

Angle& lsst::geom::Angle::operator+= ( int const &  d)
inlinenoexcept

Increase this angle by the given number of radians.

Definition at line 239 of file Angle.h.

◆ operator-=() [1/2]

Angle& lsst::geom::Angle::operator-= ( double const &  d)
inlinenoexcept

Decrease this angle by the given number of radians.

Definition at line 243 of file Angle.h.

◆ operator-=() [2/2]

Angle& lsst::geom::Angle::operator-= ( int const &  d)
inlinenoexcept

Decrease this angle by the given number of radians.

Definition at line 244 of file Angle.h.

◆ operator<()

constexpr bool lsst::geom::Angle::operator< ( const Angle rhs) const
inlinenoexcept

Compare the sizes of two Angles (without wrapping).

Definition at line 261 of file Angle.h.

◆ operator<=()

constexpr bool lsst::geom::Angle::operator<= ( const Angle rhs) const
inlinenoexcept

Compare the sizes of two Angles (without wrapping).

Definition at line 259 of file Angle.h.

◆ operator=() [1/2]

Angle& lsst::geom::Angle::operator= ( Angle const &  other)
defaultnoexcept

Copy assignment.

◆ operator=() [2/2]

Angle& lsst::geom::Angle::operator= ( Angle &&  other)
defaultnoexcept

Move assignment.

◆ operator==()

constexpr bool lsst::geom::Angle::operator== ( const Angle rhs) const
inlinenoexcept

Test if two Angles represent the same angle (without wrapping).

Definition at line 254 of file Angle.h.

◆ operator>()

constexpr bool lsst::geom::Angle::operator> ( const Angle rhs) const
inlinenoexcept

Compare the sizes of two Angles (without wrapping).

Definition at line 262 of file Angle.h.

◆ operator>=()

constexpr bool lsst::geom::Angle::operator>= ( const Angle rhs) const
inlinenoexcept

Compare the sizes of two Angles (without wrapping).

Definition at line 260 of file Angle.h.

◆ separation()

Angle lsst::geom::Angle::separation ( Angle const &  other) const
inlinenoexcept

The signed difference between two Angles.

Parameters
otherthe angle to which this angle will be compared
Returns
*this - other, wrapped to the range [-π, π)
Exception Safety
Shall not throw exceptions.

Definition at line 436 of file Angle.h.

◆ wrap()

Angle lsst::geom::Angle::wrap ( ) const
inlinenoexcept

Wrap this angle to the range [0, 2π).

Returns
an angle in the normalized interval.
Exception Safety
Shall not throw exceptions.
Warning
The upper limit is only guaranteed for radians; the upper limit may be slightly squishy for other units, due to roundoff errors. Whether there are any violations is unknown; please update this comment if you can prove that the limits are or are not valid for all supported units.

Definition at line 390 of file Angle.h.

◆ wrapCtr()

Angle lsst::geom::Angle::wrapCtr ( ) const
inlinenoexcept

Wrap this angle to the range [-π, π).

Returns
an angle in the normalized interval.
Exception Safety
Shall not throw exceptions.
Warning
Exact limits are only guaranteed for radians; limits for other units may be slightly squishy, due to roundoff errors. Whether there are any violations is unknown; please update this comment if you can prove that the limits are or are not valid for all supported units.

Definition at line 399 of file Angle.h.

◆ wrapNear()

Angle lsst::geom::Angle::wrapNear ( Angle const &  refAng) const
inlinenoexcept

Wrap this angle to a value x such that -π ≤ x - refAng ≤ π, approximately.

Parameters
refAngreference angle to match
Returns
an angle in the custom normalized interval.
Exception Safety
Shall not throw exceptions.
Warning
The only firm limit is -π ≤ x - refAng in radians. The upper limit in radians and both limits in other units are somewhat squishy, due to roundoff error.

Definition at line 418 of file Angle.h.

Friends And Related Function Documentation

◆ AngleUnit

friend class AngleUnit
friend

Definition at line 121 of file Angle.h.

◆ operator*() [1/3]

constexpr Angle operator* ( Angle  a,
Angle  d 
)
related

Product of two angles.

Warning
The result will be treated like an planar angle, not a solid angle.

Definition at line 309 of file Angle.h.

◆ operator*() [2/3]

constexpr Angle operator* ( Angle  a,
double  d 
)
related

Product of an angle and a scalar.

Definition at line 316 of file Angle.h.

◆ operator*() [3/3]

template<typename T >
constexpr Angle operator* ( lhs,
AngleUnit  rhs 
)
related

Use AngleUnit to convert a POD (e.g. int, double) to an Angle; e.g. 180*degrees.

Parameters
lhsthe value to convert
rhsthe conversion coefficient
Exception Safety
Shall not throw exceptions.

Definition at line 382 of file Angle.h.

◆ operator+()

constexpr Angle operator+ ( Angle  a,
Angle  d 
)
related

Sum of two angles.

Definition at line 295 of file Angle.h.

◆ operator-() [1/2]

constexpr Angle operator- ( Angle  a,
Angle  d 
)
related

Difference of two angles.

Definition at line 301 of file Angle.h.

◆ operator-() [2/2]

constexpr Angle operator- ( Angle  angle)
related

An angle in the opposite sense.

Definition at line 328 of file Angle.h.

◆ operator/() [1/2]

constexpr Angle operator/ ( Angle  a,
int  d 
)
related

Ratio of an angle and a scalar.

Definition at line 336 of file Angle.h.

◆ operator/() [2/2]

constexpr Angle operator/ ( Angle  a,
double  d 
)
related

Ratio of an angle and a scalar.

Definition at line 343 of file Angle.h.

◆ operator<<()

std::ostream & operator<< ( std::ostream s,
Angle  a 
)
related

Print an Angle to a stream.

The exact details of the string representation are unspecified and subject to change, but the following may be regarded as typical: "0.567 rad".

Parameters
sThe output stream.
aThe angle.
Exception Safety
Provides basic exception guarantee.

Definition at line 29 of file Angle.cc.


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