pub struct Angle<F> { /* private fields */ }Expand description
Represents a point on the circle as a unit-agnostic angle.
The parameter F is the floating-point type used to store the value.
§Behaviour
Two different values of the same point on the circle are the same Angle.
let a = Angle::from_degrees(90.0);
let b = Angle::from_degrees(450.0);
assert_eq!(a, b);§Why doesn’t it implement PartialOrd ?
Because Angles represent points on the circle (i.e., not a numerical value), they cannot be ordered.
§The NaN angle
An angle can be NaN in the following cases:
- Create an angle from a non-finite value;
let a = Angle::from_radians(f32::INFINITY);
assert!(a.is_nan());
let b = Angle::from_radians(f32::NAN);
assert!(b.is_nan());- Doing an operation that result into a non-finite value;
let a = Angle::DEG_90;
let b = a / 0.0;
assert!(b.is_nan());Implementations§
Source§impl<F: Float> Angle<F>
impl<F: Float> Angle<F>
Sourcepub const RAD_FRAC_PI_2: Self
pub const RAD_FRAC_PI_2: Self
The angle of π/2 radians.
Sourcepub const RAD_FRAC_PI_3: Self
pub const RAD_FRAC_PI_3: Self
The angle of π/3 radians.
Sourcepub const RAD_FRAC_PI_4: Self
pub const RAD_FRAC_PI_4: Self
The angle of π/4 radians.
Sourcepub const RAD_FRAC_PI_6: Self
pub const RAD_FRAC_PI_6: Self
The angle of π/6 radians.
Sourcepub const RAD_FRAC_PI_8: Self
pub const RAD_FRAC_PI_8: Self
The angle of π/8 radians.
Source§impl<F> Angle<F>
impl<F> Angle<F>
Sourcepub const fn from_radians_unchecked(radians: F) -> Self
pub const fn from_radians_unchecked(radians: F) -> Self
Creates a new angle from a value in radians assuming it is already in
the the range (-π, π].
Source§impl<F: Float> Angle<F>
impl<F: Float> Angle<F>
Sourcepub fn from_radians(radians: F) -> Self
pub fn from_radians(radians: F) -> Self
Creates a new angle from a value in radians.
Sourcepub fn from_degrees(degrees: F) -> Self
pub fn from_degrees(degrees: F) -> Self
Creates a new angle from a value in degrees.
Sourcepub fn from_turns(turns: F) -> Self
pub fn from_turns(turns: F) -> Self
Creates a new angle from a value in turns.
Sourcepub fn from_gradians(gradians: F) -> Self
pub fn from_gradians(gradians: F) -> Self
Creates a new angle from a value in gradians.
Source§impl<F: Copy> Angle<F>
impl<F: Copy> Angle<F>
Sourcepub const fn to_radians(self) -> F
pub const fn to_radians(self) -> F
The value of the angle in radians.
This value is in the range (-π, π].
Source§impl<F: Float> Angle<F>
impl<F: Float> Angle<F>
Sourcepub fn to_degrees(self) -> F
pub fn to_degrees(self) -> F
The value of the angle in degrees.
This value is in the range (-180, 180].
Sourcepub fn to_turns(self) -> F
pub fn to_turns(self) -> F
The value of the angle in turns.
This value is in the range (-0.5, 0.5].
Sourcepub fn to_gradians(self) -> F
pub fn to_gradians(self) -> F
The value of the angle in gradians.
This value is in the range (-200, 200].
Source§impl<F: Float> Angle<F>
impl<F: Float> Angle<F>
Sourcepub fn is_nan(self) -> bool
pub fn is_nan(self) -> bool
Returns true if this angle is NaN.
See Angle documentation for more details.
Source§impl<F: Copy> Angle<F>
impl<F: Copy> Angle<F>
Sourcepub const fn to_unbounded(self) -> AngleUnbounded<F>
pub const fn to_unbounded(self) -> AngleUnbounded<F>
Converts this angle into an unbounded angle in the main range.
Trait Implementations§
Source§impl<F: Float> AddAssign<&Angle<F>> for Angle<F>
impl<F: Float> AddAssign<&Angle<F>> for Angle<F>
Source§fn add_assign(&mut self, other: &Angle<F>)
fn add_assign(&mut self, other: &Angle<F>)
+= operation. Read moreSource§impl<F: Float> AddAssign for Angle<F>
impl<F: Float> AddAssign for Angle<F>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreSource§impl<'de, F: Float + Deserialize<'de>> Deserialize<'de> for Angle<F>
Available on crate feature serde only.
impl<'de, F: Float + Deserialize<'de>> Deserialize<'de> for Angle<F>
serde only.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<F: Float> Distribution<Angle<F>> for Standardwhere
Self: Distribution<F>,
Available on crate feature rand only.
impl<F: Float> Distribution<Angle<F>> for Standardwhere
Self: Distribution<F>,
rand only.Source§impl<F: Float> DivAssign<&F> for Angle<F>
impl<F: Float> DivAssign<&F> for Angle<F>
Source§fn div_assign(&mut self, other: &F)
fn div_assign(&mut self, other: &F)
/= operation. Read moreSource§impl<F: Float> DivAssign<F> for Angle<F>
impl<F: Float> DivAssign<F> for Angle<F>
Source§fn div_assign(&mut self, rhs: F)
fn div_assign(&mut self, rhs: F)
/= operation. Read moreSource§impl<F: Float> From<AngleUnbounded<F>> for Angle<F>
impl<F: Float> From<AngleUnbounded<F>> for Angle<F>
Source§fn from(angle: AngleUnbounded<F>) -> Self
fn from(angle: AngleUnbounded<F>) -> Self
Source§impl<F: Float> MulAssign<&F> for Angle<F>
impl<F: Float> MulAssign<&F> for Angle<F>
Source§fn mul_assign(&mut self, other: &F)
fn mul_assign(&mut self, other: &F)
*= operation. Read moreSource§impl<F: Float> MulAssign<F> for Angle<F>
impl<F: Float> MulAssign<F> for Angle<F>
Source§fn mul_assign(&mut self, rhs: F)
fn mul_assign(&mut self, rhs: F)
*= operation. Read moreSource§impl<F> SampleRange<Angle<F>> for RangeInclusive<Angle<F>>
Available on crate feature rand only.
impl<F> SampleRange<Angle<F>> for RangeInclusive<Angle<F>>
rand only.Source§impl<F> SampleUniform for Angle<F>
Available on crate feature rand only.
impl<F> SampleUniform for Angle<F>
rand only.Source§type Sampler = UniformAngle<F>
type Sampler = UniformAngle<F>
UniformSampler implementation supporting type X.Source§impl<F: Float> SubAssign<&Angle<F>> for Angle<F>
impl<F: Float> SubAssign<&Angle<F>> for Angle<F>
Source§fn sub_assign(&mut self, other: &Angle<F>)
fn sub_assign(&mut self, other: &Angle<F>)
-= operation. Read moreSource§impl<F: Float> SubAssign for Angle<F>
impl<F: Float> SubAssign for Angle<F>
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read moreimpl<F: Copy> Copy for Angle<F>
impl<F: Eq> Eq for Angle<F>
impl<F> StructuralPartialEq for Angle<F>
Auto Trait Implementations§
impl<F> Freeze for Angle<F>where
F: Freeze,
impl<F> RefUnwindSafe for Angle<F>where
F: RefUnwindSafe,
impl<F> Send for Angle<F>where
F: Send,
impl<F> Sync for Angle<F>where
F: Sync,
impl<F> Unpin for Angle<F>where
F: Unpin,
impl<F> UnwindSafe for Angle<F>where
F: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Borrowed> SampleBorrow<Borrowed> for Borrowedwhere
Borrowed: SampleUniform,
impl<Borrowed> SampleBorrow<Borrowed> for Borrowedwhere
Borrowed: SampleUniform,
Source§fn borrow(&self) -> &Borrowed
fn borrow(&self) -> &Borrowed
Borrow::borrow