pub struct Angle<T = f32>where
T: Float,{ /* private fields */ }
Expand description
This struct represents an angle in 2d space,
Implementations§
§impl<T> Angle<T>where
T: Float,
impl<T> Angle<T>where
T: Float,
pub fn map<U>(&self, f: impl Fn(T) -> U) -> Angle<U>where
U: Float,
pub fn map<U>(&self, f: impl Fn(T) -> U) -> Angle<U>where
U: Float,
Map inner value to a different type
pub fn acos(cos: T) -> Angle<T>
pub fn acos(cos: T) -> Angle<T>
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].
pub fn asin(sin: T) -> Angle<T>
pub fn asin(sin: T) -> Angle<T>
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].
pub fn atan(tan: T) -> Angle<T>
pub fn atan(tan: T) -> Angle<T>
Computes the arctangent of a number as an angle.
Return value is in radians in the range [-pi/2, pi/2];
pub fn atan2(y: T, x: T) -> Angle<T>
pub fn atan2(y: T, x: T) -> Angle<T>
Computes the four quadrant arctangent of self
(y
) and other
(x
) as an angle.
x = 0
,y = 0
:0
x >= 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)
pub fn sin(&self) -> T
pub fn sin(&self) -> T
Compute the sine
pub fn cos(&self) -> T
pub fn cos(&self) -> T
Compute the cosine
pub 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))
.
pub fn tan(self) -> T
pub fn tan(self) -> T
Computes the tangent of the angle.
pub fn from_radians(radians: T) -> Angle<T>
pub fn from_radians(radians: T) -> Angle<T>
Create angle from value in radians
pub fn from_degrees(degrees: T) -> Angle<T>
pub fn from_degrees(degrees: T) -> Angle<T>
Create angle from value in degrees
pub fn as_radians(&self) -> T
pub fn as_radians(&self) -> T
See angle value as radians
pub fn as_degrees(&self) -> T
pub fn as_degrees(&self) -> T
See angle value as degrees
pub fn normalized_2pi(&self) -> Angle<T>
pub fn normalized_2pi(&self) -> Angle<T>
Normalize the angle to be in range 0..2*pi
.
pub fn normalized_pi(&self) -> Angle<T>
pub fn normalized_pi(&self) -> Angle<T>
Normalize the angle to be in range -pi..pi
.
pub fn angle_from(&self, from: Angle<T>) -> Angle<T>
pub fn angle_from(&self, from: Angle<T>) -> Angle<T>
Calculates the angle between from
and self
in range -pi..pi
.
Trait Implementations§
§impl<T> AddAssign for Angle<T>where
T: Float,
impl<T> AddAssign for Angle<T>where
T: Float,
§fn add_assign(&mut self, rhs: Angle<T>)
fn add_assign(&mut self, rhs: Angle<T>)
+=
operation. Read more§impl<'de, T> Deserialize<'de> for Angle<T>where
T: Float + Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Angle<T>where
T: Float + Deserialize<'de>,
§fn deserialize<__D>(
__deserializer: __D
) -> Result<Angle<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Angle<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl<T> Distribution<Angle<T>> for Standardwhere
T: Float,
impl<T> Distribution<Angle<T>> for Standardwhere
T: Float,
§impl<T> Ord for Angle<T>
impl<T> Ord for Angle<T>
§impl<T> PartialOrd for Angle<T>where
T: PartialOrd + Float,
impl<T> PartialOrd for Angle<T>where
T: PartialOrd + Float,
§fn partial_cmp(&self, other: &Angle<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &Angle<T>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more§impl<T> Serialize for Angle<T>
impl<T> Serialize for Angle<T>
§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
§impl<T> SubAssign for Angle<T>where
T: Float,
impl<T> SubAssign for Angle<T>where
T: Float,
§fn sub_assign(&mut self, rhs: Angle<T>)
fn sub_assign(&mut self, rhs: Angle<T>)
-=
operation. Read moreimpl<T> Copy for Angle<T>
impl<T> Eq for Angle<T>
impl<T> StructuralEq for Angle<T>where
T: Float,
impl<T> StructuralPartialEq for Angle<T>where
T: Float,
Auto Trait Implementations§
impl<T> RefUnwindSafe for Angle<T>where
T: RefUnwindSafe,
impl<T> Send for Angle<T>where
T: Send,
impl<T> Sync for Angle<T>where
T: Sync,
impl<T> Unpin for Angle<T>where
T: Unpin,
impl<T> UnwindSafe for Angle<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Clamp for Twhere
T: PartialOrd,
impl<T> Clamp for Twhere
T: PartialOrd,
§fn clamp_range(self, range: impl FixedRangeBounds<Self>) -> Selfwhere
Self: Clone,
fn clamp_range(self, range: impl FixedRangeBounds<Self>) -> Selfwhere
Self: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.