Struct embedded_graphics::geometry::Angle

source ·
pub struct Angle(/* private fields */);
Expand description

Angle.

Angle is used to define the value of an angle.

§Examples

§Create an Angle from a value

use embedded_graphics::geometry::{Angle, AngleUnit};
use core::f32::consts::PI;

// Create an angle using the `from_degrees` constructor method
let angle_a = Angle::from_degrees(10.0);
let angle_b = Angle::from_radians(PI);

// Angles can also be created using the [AngleUnit] trait
let angle_c = 30.0.deg();
let angle_d = PI.rad();

Implementations§

source§

impl Angle

source

pub fn from_degrees(angle: f32) -> Self

Creates an angle defined in degrees.

source

pub fn from_radians(angle: f32) -> Self

Creates an angle defined in radians.

source

pub fn zero() -> Self

Creates a zero degree angle.

source

pub fn abs(self) -> Self

Compute the absolute value of the angle.

source

pub fn normalize(self) -> Self

Normalize the angle to less than one full rotation (ie. in the range 0..360).

source

pub fn to_degrees(self) -> f32

Return numerical value of the angle in degree

source

pub fn to_radians(self) -> f32

Return numerical value of the angle in radian

Trait Implementations§

source§

impl Add for Angle

§

type Output = Angle

The resulting type after applying the + operator.
source§

fn add(self, other: Angle) -> Angle

Performs the + operation. Read more
source§

impl AddAssign for Angle

source§

fn add_assign(&mut self, other: Angle)

Performs the += operation. Read more
source§

impl Clone for Angle

source§

fn clone(&self) -> Angle

Returns a copy of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Angle

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Neg for Angle

§

type Output = Angle

The resulting type after applying the - operator.
source§

fn neg(self) -> Angle

Performs the unary - operation. Read more
source§

impl PartialEq for Angle

source§

fn eq(&self, other: &Angle) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Angle

source§

fn partial_cmp(&self, other: &Angle) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Sub for Angle

§

type Output = Angle

The resulting type after applying the - operator.
source§

fn sub(self, other: Angle) -> Angle

Performs the - operation. Read more
source§

impl SubAssign for Angle

source§

fn sub_assign(&mut self, other: Angle)

Performs the -= operation. Read more
source§

impl Copy for Angle

source§

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§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Az for T

source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

source§

impl<T> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.