CelestialCalendar 1.0.0 · unreleased development @ 67a7c4c79a4a4a6aa7e703c9e6f0039ae34bee82
Loading...
Searching...
No Matches
astro::toolbox::Angle< Unit > Struct Template Reference

Represents an angle. More...

#include <toolbox.hpp>

Public Member Functions

constexpr Angle (const double value)
template<AngleUnit As>
constexpr operator Angle< As > () const
 Convert to the other unit — explicit, so a unit change never happens silently.
constexpr auto operator+ (const Angle< Unit > &other) const -> Angle< Unit >
constexpr auto operator- (const Angle< Unit > &other) const -> Angle< Unit >
constexpr auto operator- () const -> Angle< Unit >
constexpr auto operator* (const double other) const -> Angle< Unit >
constexpr auto operator/ (const double other) const -> Angle< Unit >
 Divide the angle by a bare (dimensionless) factor.
template<AngleUnit As>
constexpr auto as () const -> double
 Convert the angle to another unit.
constexpr auto normalize () const -> Angle< Unit >
 Normalize the angle to [0, 360) / [0, 2π), depending on the angle's unit.
constexpr auto deg () const -> double
 Return the angle in degrees.
constexpr auto rad () const -> double
 Return the angle in radians.

Static Public Member Functions

static constexpr auto from_arcmin (const double value) -> Angle< Unit >
 Build an angle from a count of arcminutes, carried in this angle's own unit.
static constexpr auto from_arcsec (const double value) -> Angle< Unit >
 Build an angle from a count of arcseconds, carried in this angle's own unit.

Detailed Description

template<AngleUnit Unit>
struct astro::toolbox::Angle< Unit >

Represents an angle.

Template Parameters
UnitThe angle's unit, either degree or radian.

Constructor & Destructor Documentation

◆ Angle()

template<AngleUnit Unit>
astro::toolbox::Angle< Unit >::Angle ( const double value)
inlineexplicitconstexpr

Member Function Documentation

◆ as()

template<AngleUnit Unit>
template<AngleUnit As>
auto astro::toolbox::Angle< Unit >::as ( ) const->double
inlinenodiscardconstexpr

Convert the angle to another unit.

Template Parameters
AsThe unit to convert to.
Returns
The converted angle.

◆ deg()

template<AngleUnit Unit>
auto astro::toolbox::Angle< Unit >::deg ( ) const->double
inlinenodiscardconstexpr

Return the angle in degrees.

◆ from_arcmin()

template<AngleUnit Unit>
constexpr auto astro::toolbox::Angle< Unit >::from_arcmin ( const double value) ->Angle< Unit >
inlinestaticnodiscardconstexpr

Build an angle from a count of arcminutes, carried in this angle's own unit.

Note
Arcminutes subdivide the degree, so the count lands in DEG and converts from there.

◆ from_arcsec()

template<AngleUnit Unit>
constexpr auto astro::toolbox::Angle< Unit >::from_arcsec ( const double value) ->Angle< Unit >
inlinestaticnodiscardconstexpr

Build an angle from a count of arcseconds, carried in this angle's own unit.

◆ normalize()

template<AngleUnit Unit>
auto astro::toolbox::Angle< Unit >::normalize ( ) const->Angle< Unit >
inlinenodiscardconstexpr

Normalize the angle to [0, 360) / [0, 2π), depending on the angle's unit.

Returns
The normalized angle. The returned angle is of the same unit as the original angle.
Exceptions
std::invalid_argumentIf the angle is not finite — inherited from normalize_deg / normalize_rad.

◆ operator Angle< As >()

template<AngleUnit Unit>
template<AngleUnit As>
astro::toolbox::Angle< Unit >::operator Angle< As > ( ) const
inlineexplicitconstexpr

Convert to the other unit — explicit, so a unit change never happens silently.

◆ operator*()

template<AngleUnit Unit>
auto astro::toolbox::Angle< Unit >::operator* ( const double other) const->Angle< Unit >
inlinenodiscardconstexpr

◆ operator+()

template<AngleUnit Unit>
auto astro::toolbox::Angle< Unit >::operator+ ( const Angle< Unit > & other) const->Angle< Unit >
inlinenodiscardconstexpr

◆ operator-() [1/2]

template<AngleUnit Unit>
auto astro::toolbox::Angle< Unit >::operator- ( ) const->Angle< Unit >
inlinenodiscardconstexpr

◆ operator-() [2/2]

template<AngleUnit Unit>
auto astro::toolbox::Angle< Unit >::operator- ( const Angle< Unit > & other) const->Angle< Unit >
inlinenodiscardconstexpr

◆ operator/()

template<AngleUnit Unit>
auto astro::toolbox::Angle< Unit >::operator/ ( const double other) const->Angle< Unit >
inlinenodiscardconstexpr

Divide the angle by a bare (dimensionless) factor.

Exceptions
std::invalid_argumentif the divisor is zero — an infinite angle is never the intent (#48).

◆ rad()

template<AngleUnit Unit>
auto astro::toolbox::Angle< Unit >::rad ( ) const->double
inlinenodiscardconstexpr

Return the angle in radians.


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