Represents an angle value. More...
#include <SFML/System/Angle.hpp>
Public Member Functions | |
constexpr | Angle ()=default |
Default constructor. | |
constexpr float | asDegrees () const |
Return the angle's value in degrees. | |
constexpr float | asRadians () const |
Return the angle's value in radians. | |
constexpr Angle | wrapSigned () const |
Wrap to a range such that -180° <= angle < 180° | |
constexpr Angle | wrapUnsigned () const |
Wrap to a range such that 0° <= angle < 360° | |
Static Public Attributes | |
static const Angle | Zero |
Predefined 0 degree angle value. | |
Friends | |
constexpr Angle | degrees (float angle) |
Construct an angle value from a number of degrees. | |
constexpr Angle | radians (float angle) |
Construct an angle value from a number of radians. | |
Related Symbols | |
(Note that these are not member symbols.) | |
constexpr bool | operator== (Angle left, Angle right) |
Overload of operator== to compare two angle values. | |
constexpr bool | operator!= (Angle left, Angle right) |
Overload of operator!= to compare two angle values. | |
constexpr bool | operator< (Angle left, Angle right) |
Overload of operator< to compare two angle values. | |
constexpr bool | operator> (Angle left, Angle right) |
Overload of operator> to compare two angle values. | |
constexpr bool | operator<= (Angle left, Angle right) |
Overload of operator<= to compare two angle values. | |
constexpr bool | operator>= (Angle left, Angle right) |
Overload of operator>= to compare two angle values. | |
constexpr Angle | operator- (Angle right) |
Overload of unary operator- to negate an angle value. | |
constexpr Angle | operator+ (Angle left, Angle right) |
Overload of binary operator+ to add two angle values. | |
constexpr Angle & | operator+= (Angle &left, Angle right) |
Overload of binary operator+= to add/assign two angle values. | |
constexpr Angle | operator- (Angle left, Angle right) |
Overload of binary operator- to subtract two angle values. | |
constexpr Angle & | operator-= (Angle &left, Angle right) |
Overload of binary operator-= to subtract/assign two angle values. | |
constexpr Angle | operator* (Angle left, float right) |
Overload of binary operator* to scale an angle value. | |
constexpr Angle | operator* (float left, Angle right) |
Overload of binary operator* to scale an angle value. | |
constexpr Angle & | operator*= (Angle &left, float right) |
Overload of binary operator*= to scale/assign an angle value. | |
constexpr Angle | operator/ (Angle left, float right) |
Overload of binary operator/ to scale an angle value. | |
constexpr Angle & | operator/= (Angle &left, float right) |
Overload of binary operator/= to scale/assign an angle value. | |
constexpr float | operator/ (Angle left, Angle right) |
Overload of binary operator/ to compute the ratio of two angle values. | |
constexpr Angle | operator% (Angle left, Angle right) |
Overload of binary operator% to compute modulo of an angle value. | |
constexpr Angle & | operator%= (Angle &left, Angle right) |
Overload of binary operator%= to compute/assign remainder of an angle value. | |
constexpr Angle | operator""_deg (long double angle) |
User defined literal for angles in degrees, e.g. 10.5_deg | |
constexpr Angle | operator""_deg (unsigned long long int angle) |
User defined literal for angles in degrees, e.g. 90_deg | |
constexpr Angle | operator""_rad (long double angle) |
User defined literal for angles in radians, e.g. 0.1_rad | |
constexpr Angle | operator""_rad (unsigned long long int angle) |
User defined literal for angles in radians, e.g. 2_rad | |
Detailed Description
Represents an angle value.
sf::Angle
encapsulates an angle value in a flexible way.
It allows for defining an angle value either as a number of degrees or radians. It also works the other way around. You can read an angle value as either a number of degrees or radians.
By using such a flexible interface, the API doesn't impose any fixed type or unit for angle values and lets the user choose their own preferred representation.
Angle values support the usual mathematical operations. You can add or subtract two angles, multiply or divide an angle by a number, compare two angles, etc.
Usage example:
Constructor & Destructor Documentation
◆ Angle()
|
constexprdefault |
Default constructor.
Sets the angle value to zero.
Member Function Documentation
◆ asDegrees()
|
nodiscardconstexpr |
◆ asRadians()
|
nodiscardconstexpr |
◆ wrapSigned()
|
nodiscardconstexpr |
Wrap to a range such that -180° <= angle < 180°
Similar to a modulo operation, this returns a copy of the angle constrained to the range [-180°, 180°) == [-Pi, Pi). The resulting angle represents a rotation which is equivalent to *this
.
The name "signed" originates from the similarity to signed integers:
signed | unsigned | |
---|---|---|
char | [-128, 128) | [0, 256) |
Angle | [-180°, 180°) | [0°, 360°) |
- Returns
- Signed angle, wrapped to [-180°, 180°)
- See also
wrapUnsigned
◆ wrapUnsigned()
|
nodiscardconstexpr |
Wrap to a range such that 0° <= angle < 360°
Similar to a modulo operation, this returns a copy of the angle constrained to the range [0°, 360°) == [0, Tau) == [0, 2*Pi). The resulting angle represents a rotation which is equivalent to *this
.
The name "unsigned" originates from the similarity to unsigned integers:
signed | unsigned | |
---|---|---|
char | [-128, 128) | [0, 256) |
Angle | [-180°, 180°) | [0°, 360°) |
- Returns
- Unsigned angle, wrapped to [0°, 360°)
- See also
wrapSigned
Friends And Related Symbol Documentation
◆ degrees
|
friend |
◆ operator!=()
Overload of operator!=
to compare two angle values.
- Note
- Does not automatically wrap the angle value
- Parameters
-
left Left operand (an angle) right Right operand (an angle)
- Returns
true
if both angle values are different
◆ operator""_deg() [1/2]
|
related |
◆ operator""_deg() [2/2]
|
related |
◆ operator""_rad() [1/2]
|
related |
◆ operator""_rad() [2/2]
|
related |
◆ operator%()
Overload of binary operator%
to compute modulo of an angle value.
Right hand angle must be greater than zero.
Examples:
- Parameters
-
left Left operand (an angle) right Right operand (an angle)
- Returns
left
moduloright
◆ operator%=()
Overload of binary operator%=
to compute/assign remainder of an angle value.
- Parameters
-
left Left operand (an angle) right Right operand (an angle)
- Returns
left
moduloright
◆ operator*() [1/2]
Overload of binary operator*
to scale an angle value.
- Parameters
-
left Left operand (an angle) right Right operand (a number)
- Returns
left
multiplied byright
◆ operator*() [2/2]
Overload of binary operator*
to scale an angle value.
- Parameters
-
left Left operand (a number) right Right operand (an angle)
- Returns
left
multiplied byright
◆ operator*=()
Overload of binary operator*=
to scale/assign an angle value.
- Parameters
-
left Left operand (an angle) right Right operand (a number)
- Returns
left
multiplied byright
◆ operator+()
Overload of binary operator+
to add two angle values.
- Parameters
-
left Left operand (an angle) right Right operand (an angle)
- Returns
- Sum of the two angle values
◆ operator+=()
Overload of binary operator+=
to add/assign two angle values.
- Parameters
-
left Left operand (an angle) right Right operand (an angle)
- Returns
- Sum of the two angle values
◆ operator-() [1/2]
Overload of binary operator-
to subtract two angle values.
- Parameters
-
left Left operand (an angle) right Right operand (an angle)
- Returns
- Difference of the two angle values
◆ operator-() [2/2]
Overload of unary operator-
to negate an angle value.
Represents a rotation in the opposite direction.
- Parameters
-
right Right operand (an angle)
- Returns
- Negative of the angle value
◆ operator-=()
Overload of binary operator-=
to subtract/assign two angle values.
- Parameters
-
left Left operand (an angle) right Right operand (an angle)
- Returns
- Difference of the two angle values
◆ operator/() [1/2]
Overload of binary operator/
to compute the ratio of two angle values.
- Parameters
-
left Left operand (an angle) right Right operand (an angle)
- Returns
left
divided byright
◆ operator/() [2/2]
Overload of binary operator/
to scale an angle value.
- Parameters
-
left Left operand (an angle) right Right operand (a number)
- Returns
left
divided byright
◆ operator/=()
Overload of binary operator/=
to scale/assign an angle value.
- Parameters
-
left Left operand (an angle) right Right operand (a number)
- Returns
left
divided byright
◆ operator<()
Overload of operator<
to compare two angle values.
- Note
- Does not automatically wrap the angle value
- Parameters
-
left Left operand (an angle) right Right operand (an angle)
- Returns
true
if left is less than right
◆ operator<=()
Overload of operator<=
to compare two angle values.
- Note
- Does not automatically wrap the angle value
- Parameters
-
left Left operand (an angle) right Right operand (an angle)
- Returns
true
if left is less than or equal to right
◆ operator==()
Overload of operator==
to compare two angle values.
- Note
- Does not automatically wrap the angle value
- Parameters
-
left Left operand (an angle) right Right operand (an angle)
- Returns
true
if both angle values are equal
◆ operator>()
Overload of operator>
to compare two angle values.
- Note
- Does not automatically wrap the angle value
- Parameters
-
left Left operand (an angle) right Right operand (an angle)
- Returns
true
if left is greater than right
◆ operator>=()
Overload of operator>=
to compare two angle values.
- Note
- Does not automatically wrap the angle value
- Parameters
-
left Left operand (an angle) right Right operand (an angle)
- Returns
true
if left is greater than or equal to right
◆ radians
|
friend |
Member Data Documentation
◆ Zero
|
static |
The documentation for this class was generated from the following file: