pub struct XYVec<T> { /* private fields */ }Implementations§
source§impl<T: VecInner> XYVec<T>
impl<T: VecInner> XYVec<T>
pub fn new(inner: [T; 2]) -> Self
sourcepub fn scale_by(&self, d: T) -> Self
pub fn scale_by(&self, d: T) -> Self
use xyzvec::XYVec;
use approx::assert_relative_eq;
let v = XYVec::new([1.0f64, -0.5f64]);
let scaled_v = v.scale_by(5.0);
assert_relative_eq!(scaled_v.x(), 5.0);
assert_relative_eq!(scaled_v.y(), -2.5);sourcepub fn div_by(&self, d: T) -> Self
pub fn div_by(&self, d: T) -> Self
use xyzvec::XYVec;
use approx::assert_relative_eq;
let v = XYVec::new([1.0f64, -0.5f64]);
let scaled_v = v.div_by(0.2);
assert_relative_eq!(scaled_v.x(), 5.0);
assert_relative_eq!(scaled_v.y(), -2.5);sourcepub fn l2_norm_sqd(&self) -> T
pub fn l2_norm_sqd(&self) -> T
use xyzvec::XYVec;
use approx::assert_relative_eq;
sourcepub fn cross_prod(&self, other: Self) -> T
pub fn cross_prod(&self, other: Self) -> T
use xyzvec::XYVec;
use approx::assert_relative_eq;
let v = XYVec::new([1.0f64, -0.5f64]);
let w = XYVec::new([-2.0f64, 0.0f64]);
assert_relative_eq!(v.cross_prod(w), -1.0);sourcepub fn cross_prod_sqd(&self, other: Self) -> T
pub fn cross_prod_sqd(&self, other: Self) -> T
use xyzvec::XYVec;
use approx::assert_relative_eq;
let v = XYVec::new([1.0f64, -0.5f64]);
let w = XYVec::new([-2.0f64, 0.0f64]);
assert_relative_eq!(v.cross_prod_sqd(w), 1.0);sourcepub fn dot_prod(&self, other: Self) -> T
pub fn dot_prod(&self, other: Self) -> T
use xyzvec::XYVec;
use approx::assert_relative_eq;
let v = XYVec::new([1.0f64, -0.5f64]);
let w = XYVec::new([-2.0f64, 0.0f64]);
assert_relative_eq!(v.dot_prod(w), -2.0);sourcepub fn translate_by(&self, x: T, y: T) -> Self
pub fn translate_by(&self, x: T, y: T) -> Self
use xyzvec::XYVec;
use approx::assert_relative_eq;
let v = XYVec::new([1.0f64, -0.5f64]);
let scaled_v = v.translate_by(1.0, 1.0);
assert_relative_eq!(scaled_v.x(), 2.0);
assert_relative_eq!(scaled_v.y(), 0.5);Trait Implementations§
source§impl<T: VecInner> AddAssign for XYVec<T>
impl<T: VecInner> AddAssign for XYVec<T>
source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Performs the
+= operation. Read moresource§impl<T: VecInner> FromIterator<T> for XYVec<T>
impl<T: VecInner> FromIterator<T> for XYVec<T>
Build XYVec from iterator of size two. TODO: check for errors better
source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more
source§impl<T: PartialEq> PartialEq for XYVec<T>
impl<T: PartialEq> PartialEq for XYVec<T>
source§impl<T: VecInner> SubAssign for XYVec<T>
impl<T: VecInner> SubAssign for XYVec<T>
source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
Performs the
-= operation. Read moreimpl<T: Copy> Copy for XYVec<T>
impl<T> StructuralPartialEq for XYVec<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for XYVec<T>where
T: RefUnwindSafe,
impl<T> Send for XYVec<T>where
T: Send,
impl<T> Sync for XYVec<T>where
T: Sync,
impl<T> Unpin for XYVec<T>where
T: Unpin,
impl<T> UnwindSafe for XYVec<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
Mutably borrows from an owned value. Read more
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
source§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Performs the conversion.
source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Performs the conversion.
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.