pub struct Angle(/* private fields */);
Expand description
An measurement of distance between two rays sharing a common endpoint, in degrees.
Angle::degrees(1)
is equivalent to 1/360th
of a full rotation. This type
is commonly used to represent the amount of rotation to perform.
Internally, this type ensures that the angle represented using a
Fraction
is always within the range of 0..=360°
(degrees). This ensures
that comparing two angles is efficient and deterministic.
use figures::Angle;
assert_eq!(Angle::degrees(-90).into_degrees::<f32>(), 270.);
assert_eq!(Angle::degrees(-90), Angle::degrees(270));
Because this type uses a Fraction
internally, it will perform integer
math on integer types. The order of operations may impact the amount of
precision the final result contains.
§Working with Radians
Because π is an irrational number, this type internally uses degrees for
representation. Angles represented in radians can be converted using
Angle::radians
/Angle::radians_f
.
Implementations§
source§impl Angle
impl Angle
sourcepub const fn degrees(degrees: i16) -> Self
pub const fn degrees(degrees: i16) -> Self
Returns an angle for degrees
, where 360 degrees is equal to one full
rotation.
The value will be normalized to the range of 0..360
.
sourcepub fn degrees_fraction(degrees: Fraction) -> Self
pub fn degrees_fraction(degrees: Fraction) -> Self
Returns an angle for radians
, where 2π
is equal to one full
rotation.
The value will be normalized to the range of 0..2π
.
sourcepub fn degrees_f(degrees: f32) -> Self
pub fn degrees_f(degrees: f32) -> Self
Returns an angle for degrees
, where 360 degrees is equal to one full
rotation.
The value will be normalized to the range of 0..360
.
sourcepub fn radians(radians: Fraction) -> Self
pub fn radians(radians: Fraction) -> Self
Returns an angle for radians
, where 2π
is equal to one full
rotation.
The value will be normalized to the range of 0..2π
.
sourcepub fn radians_f(radians: f32) -> Self
pub fn radians_f(radians: f32) -> Self
Returns an angle for radians
, where 2π
is equal to one full
rotation.
The value will be normalized to the range of 0..2π
.
sourcepub fn into_raidans<Representation>(self) -> Representation
pub fn into_raidans<Representation>(self) -> Representation
Returns this angle as represented in radians, where 2π
is equal to one
full rotation.
sourcepub fn into_raidans_f(self) -> f32
pub fn into_raidans_f(self) -> f32
Returns this angle as represented in radians, where 2π
is equal to one
full rotation.
sourcepub fn into_degrees<Representation>(self) -> Representation
pub fn into_degrees<Representation>(self) -> Representation
Returns this angle as represented in degrees, where 360 degrees is equal to one full rotation.
Trait Implementations§
source§impl AddAssign<f32> for Angle
impl AddAssign<f32> for Angle
source§fn add_assign(&mut self, rhs: f32)
fn add_assign(&mut self, rhs: f32)
+=
operation. Read moresource§impl AddAssign<i16> for Angle
impl AddAssign<i16> for Angle
source§fn add_assign(&mut self, rhs: i16)
fn add_assign(&mut self, rhs: i16)
+=
operation. Read moresource§impl AddAssign for Angle
impl AddAssign for Angle
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+=
operation. Read moresource§impl<'de> Deserialize<'de> for Angle
impl<'de> Deserialize<'de> for Angle
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 DivAssign<f32> for Angle
impl DivAssign<f32> for Angle
source§fn div_assign(&mut self, rhs: f32)
fn div_assign(&mut self, rhs: f32)
/=
operation. Read moresource§impl DivAssign<i16> for Angle
impl DivAssign<i16> for Angle
source§fn div_assign(&mut self, rhs: i16)
fn div_assign(&mut self, rhs: i16)
/=
operation. Read moresource§impl DivAssign for Angle
impl DivAssign for Angle
source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
/=
operation. Read moresource§impl MulAssign<f32> for Angle
impl MulAssign<f32> for Angle
source§fn mul_assign(&mut self, rhs: f32)
fn mul_assign(&mut self, rhs: f32)
*=
operation. Read moresource§impl MulAssign<i16> for Angle
impl MulAssign<i16> for Angle
source§fn mul_assign(&mut self, rhs: i16)
fn mul_assign(&mut self, rhs: i16)
*=
operation. Read moresource§impl MulAssign for Angle
impl MulAssign for Angle
source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*=
operation. Read moresource§impl Ord for Angle
impl Ord for Angle
source§impl PartialEq for Angle
impl PartialEq for Angle
source§impl PartialOrd for Angle
impl PartialOrd for Angle
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 moresource§impl SubAssign<f32> for Angle
impl SubAssign<f32> for Angle
source§fn sub_assign(&mut self, rhs: f32)
fn sub_assign(&mut self, rhs: f32)
-=
operation. Read moresource§impl SubAssign<i16> for Angle
impl SubAssign<i16> for Angle
source§fn sub_assign(&mut self, rhs: i16)
fn sub_assign(&mut self, rhs: i16)
-=
operation. Read moresource§impl SubAssign for Angle
impl SubAssign for Angle
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-=
operation. Read moreimpl Copy for Angle
impl Eq for Angle
impl StructuralPartialEq for Angle
Auto Trait Implementations§
impl Freeze for Angle
impl RefUnwindSafe for Angle
impl Send for Angle
impl Sync for Angle
impl Unpin for Angle
impl UnwindSafe for Angle
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<A> Cast for A
impl<A> Cast for A
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§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.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<Unit> IntoComponents<Unit> for Unitwhere
Unit: Copy,
impl<Unit> IntoComponents<Unit> for Unitwhere
Unit: Copy,
source§fn into_components(self) -> (Unit, Unit)
fn into_components(self) -> (Unit, Unit)
source§fn to_vec<Type>(self) -> Typewhere
Type: FromComponents<Unit>,
fn to_vec<Type>(self) -> Typewhere
Type: FromComponents<Unit>,
FromComponents
and
IntoComponents
.