[−][src]Struct integer_angles::Angle
Implements an angle structure where angles are stored as integers.
Also keeps track of if the angle is going clockwise or counter-clockwise. It also stores
a full circle different from a 0 degree arc. This gets rid of precision issues when
storing angles as pi
can be represented exactly if you change the units.
Methods
impl Angle
[src]
pub fn is_zero(&self) -> bool
[src]
Is this angle zero?
use integer_angles::Angle; assert!(Angle::zero().is_zero()); assert!(!Angle::pi().is_zero());
pub fn pi_over(n: i64) -> Angle
[src]
Divide pi by some number, and return the result
use integer_angles::Angle; assert_eq!(Angle::pi_over(2) * 2, Angle::pi());
pub fn zero() -> Angle
[src]
Create a 0-degree angle
use integer_angles::Angle; assert_eq!(Angle::zero() * 2, Angle::zero());
pub fn pi_2() -> Angle
[src]
Create an angle of pi over two counter-clockwise (for convenience).
use integer_angles::Angle; assert_eq!(Angle::pi_2(), Angle::pi_over(2)); assert_eq!(Angle::pi_2() * 2, Angle::pi());
pub fn pi() -> Angle
[src]
Create an angle of pi counter-clockwise.
use integer_angles::Angle; assert_eq!(Angle::pi() / 2, Angle::pi_2());
pub fn two_pi() -> Angle
[src]
Create an angle that is two_pi
radians counter-clockwise.
use integer_angles::Angle; assert_eq!(Angle::two_pi() * 2, Angle::pi() * 2);
pub fn units(&self) -> Option<u64>
[src]
Get the number of units in this angle. This will be some number between 0 and 2^64 - 1
where a full circle is 2^64 units. If this represents a full cirle, None
will be
returned.
use integer_angles::Angle; assert_eq!(Angle::zero().units(), Some(0)); assert_eq!(Angle::two_pi().units(), None);
pub fn clockwise(&self) -> bool
[src]
Is this angle clockwise or counter-clockwise?
use integer_angles::Angle; assert_eq!(Angle::pi().clockwise(), false); assert_eq!((-Angle::pi()).clockwise(), true);
pub fn cos<T: RealField>(&self) -> T
[src]
Returns the cosine of the angle.
use integer_angles::Angle; assert_eq!(Angle::zero().cos::<f64>(), 1.0f64); assert_eq!(Angle::pi_2().cos::<f64>(), 0.0f64); assert_eq!(Angle::pi().cos::<f64>(), -1.0f64); assert_eq!((Angle::pi_2() * 3).cos::<f64>(), 0.0f64); assert_eq!(Angle::two_pi().cos::<f64>(), 1.0f64);
pub fn sin<T: RealField>(&self) -> T
[src]
Returns the cosine of the angle.
use integer_angles::Angle; assert_eq!(Angle::zero().sin::<f64>(), 0.0f64); assert_eq!(Angle::pi_2().sin::<f64>(), 1.0f64); assert_eq!(Angle::pi().sin::<f64>(), 0.0f64); assert_eq!((3 * Angle::pi_2()).sin::<f64>(), -1.0f64); assert_eq!(Angle::two_pi().sin::<f64>(), 0.0f64);
pub fn tan<T: RealField>(&self) -> T
[src]
Returns the tangent of the angle.
use integer_angles::Angle; assert_eq!(Angle::pi_over(4).tan::<f64>(), 1.0f64);
pub fn acos<T: RealField>(x: T) -> Angle
[src]
Compute the arccos of the number.
use integer_angles::Angle; assert_eq!(Angle::acos(0.0f64), Angle::pi_over(2));
pub fn asin<T: RealField>(x: T) -> Angle
[src]
Compute the arcsin of the number.
use integer_angles::Angle; assert_eq!(Angle::asin(0.5f64).sin::<f64>(), 0.5f64);
pub fn atan<T: RealField>(x: T) -> Angle
[src]
Compute the arctan of the number.
use integer_angles::Angle; assert_eq!(Angle::atan(1.0f64), Angle::pi_over(4));
pub fn atan2<T: RealField>(y: T, x: T) -> Option<Angle>
[src]
Compute the atan(y / x) but keeping the sign of y and x.
use integer_angles::Angle; assert_eq!(Angle::atan2(1.0f64, 0.0).unwrap(), Angle::pi_2());
pub fn into<T: RealField>(self) -> T
[src]
Convert the angle into radians. This can lose precision pretty easily
use integer_angles::Angle; use nalgebra::RealField; assert_eq!(Angle::pi().into::<f64>(), f64::pi());
Trait Implementations
impl Add<Angle> for Angle
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, other: Self) -> Self
[src]
impl AddAssign<Angle> for Angle
[src]
fn add_assign(&mut self, other: Self)
[src]
impl Clone for Angle
[src]
impl Copy for Angle
[src]
impl Debug for Angle
[src]
impl Default for Angle
[src]
impl<'de> Deserialize<'de> for Angle
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Div<i64> for Angle
[src]
type Output = Angle
The resulting type after applying the /
operator.
fn div(self, rhs: i64) -> Angle
[src]
impl DivAssign<i64> for Angle
[src]
fn div_assign(&mut self, rhs: i64)
[src]
impl<T: RealField> From<T> for Angle
[src]
fn from(real: T) -> Angle
[src]
Convert from radians into an angle.
use integer_angles::Angle; use nalgebra::RealField; assert_eq!(Angle::from(f64::pi()), Angle::pi());
impl Mul<Angle> for i64
[src]
type Output = Angle
The resulting type after applying the *
operator.
fn mul(self, rhs: Angle) -> Angle
[src]
impl Mul<i64> for Angle
[src]
type Output = Angle
The resulting type after applying the *
operator.
fn mul(self, rhs: i64) -> Self
[src]
impl MulAssign<i64> for Angle
[src]
fn mul_assign(&mut self, rhs: i64)
[src]
impl Neg for Angle
[src]
type Output = Angle
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
impl PartialEq<Angle> for Angle
[src]
impl PartialOrd<Angle> for Angle
[src]
fn partial_cmp(&self, other: &Angle) -> Option<Ordering>
[src]
fn lt(&self, other: &Angle) -> bool
[src]
fn le(&self, other: &Angle) -> bool
[src]
fn gt(&self, other: &Angle) -> bool
[src]
fn ge(&self, other: &Angle) -> bool
[src]
impl Serialize for Angle
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralPartialEq for Angle
[src]
impl Sub<Angle> for Angle
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, other: Self) -> Self
[src]
impl SubAssign<Angle> for Angle
[src]
fn sub_assign(&mut self, other: Self)
[src]
Auto Trait Implementations
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,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, Right> ClosedAdd<Right> for T where
T: Add<Right, Output = T> + AddAssign<Right>,
T: Add<Right, Output = T> + AddAssign<Right>,
impl<T, Right> ClosedDiv<Right> for T where
T: Div<Right, Output = T> + DivAssign<Right>,
T: Div<Right, Output = T> + DivAssign<Right>,
impl<T, Right> ClosedMul<Right> for T where
T: Mul<Right, Output = T> + MulAssign<Right>,
T: Mul<Right, Output = T> + MulAssign<Right>,
impl<T> ClosedNeg for T where
T: Neg<Output = T>,
T: Neg<Output = T>,
impl<T, Right> ClosedSub<Right> for T where
T: Sub<Right, Output = T> + SubAssign<Right>,
T: Sub<Right, Output = T> + SubAssign<Right>,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> Scalar for T where
T: PartialEq<T> + Copy + Any + Debug,
[src]
T: PartialEq<T> + Copy + Any + Debug,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn is_in_subset(&self) -> bool
unsafe fn to_subset_unchecked(&self) -> SS
fn from_subset(element: &SS) -> SP
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
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>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
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>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,