pub struct Angle<T: Float = f32> { /* private fields */ }Expand description
This struct represents an angle in 2d space,
Implementations§
Source§impl<T: Float> Angle<T>
impl<T: Float> Angle<T>
Sourcepub fn map<U: Float>(&self, f: impl Fn(T) -> U) -> Angle<U>
pub fn map<U: Float>(&self, f: impl Fn(T) -> U) -> Angle<U>
Map inner value to a different type
Sourcepub fn acos(cos: T) -> Self
pub fn acos(cos: T) -> Self
Computes the arccosine of a number as an angle.
Return value is in radians in the range [0, pi] or NaN if the number is outside the range [-1, 1].
Sourcepub fn asin(sin: T) -> Self
pub fn asin(sin: T) -> Self
Computes the arcsine of a number as an angle.
Return value is in radians in the range [-pi/2, pi/2] or NaN if the number is outside the range [-1, 1].
Sourcepub fn atan(tan: T) -> Self
pub fn atan(tan: T) -> Self
Computes the arctangent of a number as an angle.
Return value is in radians in the range [-pi/2, pi/2];
Sourcepub fn atan2(y: T, x: T) -> Self
pub fn atan2(y: T, x: T) -> Self
Computes the four quadrant arctangent of self (y) and other (x) as an angle.
x = 0,y = 0:0x >= 0:arctan(y/x)->[-pi/2, pi/2]y >= 0:arctan(y/x) + pi->(pi/2, pi]y < 0:arctan(y/x) - pi->(-pi, -pi/2)
Sourcepub fn sin_cos(&self) -> (T, T)
pub fn sin_cos(&self) -> (T, T)
Simultaneously computes the sine and cosine of the angle.
Returns (sin(self), cos(self)).
Sourcepub fn from_radians(radians: T) -> Self
pub fn from_radians(radians: T) -> Self
Create angle from value in radians
Sourcepub fn from_degrees(degrees: T) -> Self
pub fn from_degrees(degrees: T) -> Self
Create angle from value in degrees
Sourcepub fn as_radians(&self) -> T
pub fn as_radians(&self) -> T
See angle value as radians
Sourcepub fn as_degrees(&self) -> T
pub fn as_degrees(&self) -> T
See angle value as degrees
Sourcepub fn normalized_2pi(&self) -> Self
pub fn normalized_2pi(&self) -> Self
Normalize the angle to be in range 0..2*pi.
Sourcepub fn normalized_pi(&self) -> Self
pub fn normalized_pi(&self) -> Self
Normalize the angle to be in range -pi..pi.
Sourcepub fn angle_from(&self, from: Self) -> Self
pub fn angle_from(&self, from: Self) -> Self
Calculates the angle between from and self in range -pi..pi.
Trait Implementations§
Source§impl<T: Float> AddAssign for Angle<T>
impl<T: Float> AddAssign for Angle<T>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreSource§impl<'de, T> Deserialize<'de> for Angle<T>where
T: Deserialize<'de> + Float,
impl<'de, T> Deserialize<'de> for Angle<T>where
T: Deserialize<'de> + Float,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<T: Float> Distribution<Angle<T>> for Standard
impl<T: Float> Distribution<Angle<T>> for Standard
Source§impl<T: Ord + Float> Ord for Angle<T>
impl<T: Ord + Float> Ord for Angle<T>
Source§impl<T: PartialOrd + Float> PartialOrd for Angle<T>
impl<T: PartialOrd + Float> PartialOrd for Angle<T>
Source§impl<T: Float> SubAssign for Angle<T>
impl<T: Float> SubAssign for Angle<T>
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read more