#include <rll/euclid/angle.h>
template <typename T, typename = std:: enable_if_t<is_num_v<T>>>
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 not0
. - 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::auto as() const → U constexpr
enable_if_t<is_num_v<T>>> - 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::auto cast() const → angle<U> constexpr
enable_if_t<is_num_v<T>>> - 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::auto operator*(U const& other) const → angle constexpr
enable_if_t<is_num_v<T>>> - Returns
this * other
. - auto operator*=(angle const& other) → angle& constexpr
- Returns
this *= other
. -
template <typename U, typename = std::auto operator*=(U const& other) → angle& constexpr
enable_if_t<is_num_v<T>>> - 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::auto operator+(U const& other) const → angle constexpr
enable_if_t<is_num_v<T>>> - 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::auto operator+=(U const& other) → angle& constexpr
enable_if_t<is_num_v<T>>> - 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::auto operator-(U const& other) const → angle constexpr
enable_if_t<is_num_v<T>>> - 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::auto operator-=(U const& other) → angle& constexpr
enable_if_t<is_num_v<T>>> - Returns
this -= other
. - auto operator/(angle const& other) const → angle constexpr
- Returns
this / other
. -
template <typename U, typename = std::auto operator/(U const& other) const → angle constexpr
enable_if_t<is_num_v<T>>> - Returns
this / other
. - auto operator/=(angle const& other) → angle& constexpr
- Returns
this /= other
. -
template <typename U, typename = std::auto operator/=(U const& other) → angle& constexpr
enable_if_t<is_num_v<T>>> - 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. |
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>
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>
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) constexpr
Returns this *= other
.
Parameters | |
---|---|
other | The other value. |
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) constexpr
Returns this += other
.
Parameters | |
---|---|
other | The other value. |
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) constexpr
Returns this -= other
.
Parameters | |
---|---|
other | The other value. |
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) constexpr
Returns this /= other
.
Parameters | |
---|---|
other | The other value. |
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 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 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:: 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. |
---|