template <typename T, typename = std::enable_if_t<is_num_v<T>>>
rll::angle struct

Newtype describing an angle.

Template parameters
T Number type. Must satisfy concept rolly::concepts::num. Default is f32.

Stores an angle in radians.

Public types

using number_type = T
Underlying number type.

Public static functions

static auto from(number_type value, angle_unit u) →  angle constexpr
Constructs an angle from another unit.
static auto from_degrees(number_type degrees) →  angle constexpr
Constructs an angle from degrees.
static auto from_radians(number_type radians) →  angle constexpr
Constructs an angle from radians.
static auto half_pi() →  angle constexpr
Constructs an angle with value pi/2.
static auto pi() →  angle constexpr
Constructs an angle with value pi.
static auto quarter_pi() →  angle constexpr
Constructs an angle with value pi/4.
static auto third_pi() →  angle constexpr
Constructs an angle with value pi/3.
static auto two_pi() →  angle constexpr
Constructs an angle with value 2pi.
static auto zero() →  angle constexpr
Constructs an zero angle.

Constructors, destructors, conversion operators

angle() constexpr
Constructs an empty angle.
angle(number_type const value) explicit constexpr
Constructs an angle from a numeric value.
angle(angle const&) defaulted constexpr
Copy constructor.
angle(angle&&) defaulted constexpr
Move constructor.
operator bool() const explicit constexpr
Returns true if underlying value is not 0.
operator number_type() const explicit constexpr
Returns the underlying value as number_type.
~angle() defaulted
Default destructor.

Public functions

auto acos() const →  number_type
Returns the arc cosine of this angle.
auto angle_to(angle const& other) const →  angle constexpr
Returns the shortest signed angle between two angles.
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
auto as() const →  U constexpr
Returns this numeric newtype as number in another numeric representation.
auto as_f32() const →  f32 constexpr
Returns this angle as 32-bit floating-point number.
auto as_f64() const →  f64 constexpr
Returns this angle as 64-bit floating-point number.
auto asin() const →  number_type
Returns the arc sine of this angle.
auto atan() const →  number_type
Returns the arc tangent of this angle.
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
auto cast() const →  angle<U> constexpr
Casts the angle to another numeric type.
auto cos() const →  number_type
Returns the cosine of this angle.
auto degrees() const →  number_type constexpr
Returns the angle in degrees.
auto in(angle_unit u) const →  number_type constexpr
Returns the angle in the given unit.
auto is_finite() const →  bool
Returns true if this angle is a finite number.
auto lerp(angle const& other, T t) const →  angle
Linear interpolation between two angles, using the shortest path.
auto operator!=(angle const& other) const →  bool constexpr
Compares this and other angle with rolly::math::approx_eq for inequality.
auto operator*() const →  number_type constexpr
Returns the underlying numeric scalar.
auto operator*(angle const& other) const →  angle constexpr
Returns this * other.
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
auto operator*(U const& other) const →  angle constexpr
Returns this * other.
auto operator*=(angle const& other) →  angle& constexpr
Returns this *= other.
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
auto operator*=(U const& other) →  angle& constexpr
Returns this *= other.
auto operator+() const →  angle constexpr
Returns this.
auto operator+(angle const& other) const →  angle constexpr
Returns this + other.
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
auto operator+(U const& other) const →  angle constexpr
Returns this + other.
auto operator++() →  T& constexpr
Increments the underlying value by 1.
auto operator++(int) →  T& constexpr
Increments the underlying value by 1.
auto operator+=(angle const& other) →  angle& constexpr
Returns this += other.
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
auto operator+=(U const& other) →  angle& constexpr
Returns this += other.
auto operator-() const →  angle constexpr
Returns -this.
auto operator-(angle const& other) const →  angle constexpr
Returns this - other.
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
auto operator-(U const& other) const →  angle constexpr
Returns this - other.
auto operator--() →  T& constexpr
Decrements the underlying value by 1.
auto operator--(int) →  T& constexpr
Decrements the underlying value by 1.
auto operator-=(angle const& other) →  angle& constexpr
Returns this -= other.
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
auto operator-=(U const& other) →  angle& constexpr
Returns this -= other.
auto operator/(angle const& other) const →  angle constexpr
Returns this / other.
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
auto operator/(U const& other) const →  angle constexpr
Returns this / other.
auto operator/=(angle const& other) →  angle& constexpr
Returns this /= other.
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
auto operator/=(U const& other) →  angle& constexpr
Returns this /= other.
auto operator<(angle const& other) const →  bool constexpr
Compares this and other angle for less than.
auto operator<=(angle const& other) const →  bool constexpr
Compares this and other angle for less than or equal to.
auto operator=(angle const&) →  angle& defaulted constexpr
Copy assignment.
auto operator=(angle&&) →  angle& defaulted constexpr
Move assignment.
auto operator==(angle const& other) const →  bool constexpr
Compares this and other angle with rolly::math::approx_eq for equality.
auto operator>(angle const& other) const →  bool constexpr
Compares this and other angle for greater than.
auto operator>=(angle const& other) const →  bool constexpr
Compares this and other angle for greater than or equal to.
auto positive() const →  angle constexpr
Returns this angle as number in range [0, 2pi).
auto radians() const →  number_type constexpr
Returns the angle in radians.
auto signed_() const →  angle constexpr
Returns this angle as number in range [-pi, pi).
auto sin() const →  number_type
Returns the sine of this angle.
auto sin_cos() const →  std::pair<T, T> constexpr
Returns the sine and cosine of the angle.
auto tan() const →  number_type
Returns the tangent of this angle.
auto to_string() const →  std::string
Returns string representation of the angle.
auto value() const →  number_type constexpr
Returns the underlying numeric scalar value.

Friends

auto operator<<(std::ostream& os, angle const& a) →  std::ostream&

Function documentation

template <typename T, typename _2>
static angle rll::angle::from(number_type value, angle_unit u) constexpr

Constructs an angle from another unit.

Parameters
value Numeric value.
u Unit.
Returns Constructed angle.

template <typename T, typename _2>
static angle rll::angle::from_degrees(number_type degrees) constexpr

Constructs an angle from degrees.

Parameters
degrees Angle in degrees.
Returns Constructed angle.

template <typename T, typename _2>
static angle rll::angle::from_radians(number_type radians) constexpr

Constructs an angle from radians.

Parameters
radians Angle in radians.
Returns Constructed angle.

template <typename T, typename _2>
rll::angle::angle() constexpr

Constructs an empty angle.

template <typename T, typename _2>
rll::angle::angle(number_type const value) explicit constexpr

Constructs an angle from a numeric value.

Parameters
value Numeric value.

template <typename T, typename _2>
angle rll::angle::angle_to(angle const& other) const constexpr

Returns the shortest signed angle between two angles.

Parameters
other Other angle
Returns Takes wrapping and signs into account.

template <typename T, typename _2>
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
U rll::angle::as() const constexpr

Returns this numeric newtype as number in another numeric representation.

Template parameters
U Number type. Must satisfy concept num.

template <typename T, typename _2>
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
angle<U> rll::angle::cast() const constexpr

Casts the angle to another numeric type.

Template parameters
U Target numeric type.
Returns Cast angle.

template <typename T, typename _2>
number_type rll::angle::degrees() const constexpr

Returns the angle in degrees.

template <typename T, typename _2>
number_type rll::angle::in(angle_unit u) const constexpr

Returns the angle in the given unit.

Parameters
u Unit to return the angle in.
Returns Angle in the given unit.

template <typename T, typename _2>
angle rll::angle::lerp(angle const& other, T t) const

Linear interpolation between two angles, using the shortest path.

Parameters
other Other angle
t Interpolation factor
Returns Interpolated angle

template <typename T, typename _2>
bool rll::angle::operator!=(angle const& other) const constexpr

Compares this and other angle with rolly::math::approx_eq for inequality.

Parameters
other Other angle.
Returns true if both angles are not approximately equal, false otherwise.

template <typename T, typename _2>
number_type rll::angle::operator*() const constexpr

Returns the underlying numeric scalar.

Returns The underlying numeric scalar.

template <typename T, typename _2>
angle rll::angle::operator*(angle const& other) const constexpr

Returns this * other.

Parameters
other The other value.

template <typename T, typename _2>
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
angle rll::angle::operator*(U const& other) const constexpr

Returns this * other.

Template parameters
U Right hand side numeric type.
Parameters
other The other value.

template <typename T, typename _2>
angle& rll::angle::operator*=(angle const& other) constexpr

Returns this *= other.

Parameters
other The other value.

template <typename T, typename _2>
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
angle& rll::angle::operator*=(U const& other) constexpr

Returns this *= other.

Template parameters
U Right hand side numeric type.
Parameters
other The other value.

template <typename T, typename _2>
angle rll::angle::operator+(angle const& other) const constexpr

Returns this + other.

Parameters
other The other value.

template <typename T, typename _2>
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
angle rll::angle::operator+(U const& other) const constexpr

Returns this + other.

Template parameters
U Right hand side numeric type.
Parameters
other The other value.

template <typename T, typename _2>
angle& rll::angle::operator+=(angle const& other) constexpr

Returns this += other.

Parameters
other The other value.

template <typename T, typename _2>
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
angle& rll::angle::operator+=(U const& other) constexpr

Returns this += other.

Template parameters
U Right hand side numeric type.
Parameters
other The other value.

template <typename T, typename _2>
angle rll::angle::operator-(angle const& other) const constexpr

Returns this - other.

Parameters
other The other value.

template <typename T, typename _2>
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
angle rll::angle::operator-(U const& other) const constexpr

Returns this - other.

Template parameters
U Right hand side numeric type.
Parameters
other The other value.

template <typename T, typename _2>
angle& rll::angle::operator-=(angle const& other) constexpr

Returns this -= other.

Parameters
other The other value.

template <typename T, typename _2>
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
angle& rll::angle::operator-=(U const& other) constexpr

Returns this -= other.

Template parameters
U Right hand side numeric type.
Parameters
other The other value.

template <typename T, typename _2>
angle rll::angle::operator/(angle const& other) const constexpr

Returns this / other.

Parameters
other The other value.

template <typename T, typename _2>
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
angle rll::angle::operator/(U const& other) const constexpr

Returns this / other.

Template parameters
U Right hand side numeric type.
Parameters
other The other value.

template <typename T, typename _2>
angle& rll::angle::operator/=(angle const& other) constexpr

Returns this /= other.

Parameters
other The other value.

template <typename T, typename _2>
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
angle& rll::angle::operator/=(U const& other) constexpr

Returns this /= other.

Template parameters
U Right hand side numeric type.
Parameters
other The other value.

template <typename T, typename _2>
bool rll::angle::operator<(angle const& other) const constexpr

Compares this and other angle for less than.

Parameters
other Other angle.
Returns true if this angle is less than other, false otherwise.

template <typename T, typename _2>
bool rll::angle::operator<=(angle const& other) const constexpr

Compares this and other angle for less than or equal to.

Parameters
other Other angle.
Returns true if this angle is less than or equal to other, false otherwise.

template <typename T, typename _2>
bool rll::angle::operator==(angle const& other) const constexpr

Compares this and other angle with rolly::math::approx_eq for equality.

Parameters
other Other angle.
Returns true if both angles are approximately equal, false otherwise.

template <typename T, typename _2>
bool rll::angle::operator>(angle const& other) const constexpr

Compares this and other angle for greater than.

Parameters
other Other angle.
Returns true if this angle is greater than other, false otherwise.

template <typename T, typename _2>
bool rll::angle::operator>=(angle const& other) const constexpr

Compares this and other angle for greater than or equal to.

Parameters
other Other angle.
Returns true if this angle is greater than or equal to other, false otherwise.

template <typename T, typename _2>
number_type rll::angle::radians() const constexpr

Returns the angle in radians.

template <typename T, typename _2>
std::pair<T, T> rll::angle::sin_cos() const constexpr

Returns the sine and cosine of the angle.

Returns Pair of sine and cosine.

template <typename T, typename _2>
std::string rll::angle::to_string() const

Returns string representation of the angle.

Returns String representation of the object.

Angle is represented in degrees. If the underlying number type is floating point, it is rounded to two decimal places.

template <typename T, typename _2>
number_type rll::angle::value() const constexpr

Returns the underlying numeric scalar value.

Returns The underlying numeric scalar value.