#[repr(C)]pub struct Vector2D<S = f32, Unit = ()> {
pub x: S,
pub y: S,
/* private fields */
}
Expand description
2D vector.
Fields§
§x: S
§y: S
Implementations§
Source§impl<S: Sized, U: Copy> Vector2D<S, U>
impl<S: Sized, U: Copy> Vector2D<S, U>
pub const fn new(x: S, y: S) -> Self
Sourcepub fn magnitude(self) -> Swhere
S: Float,
pub fn magnitude(self) -> Swhere
S: Float,
The distance from the tail to the tip of the vector.
Sourcepub fn dot(a: Self, b: Self) -> <S as Add>::Output
pub fn dot(a: Self, b: Self) -> <S as Add>::Output
Dot product of two vectors.
use rgx::math::*;
let v1 = Vector4D::<i32, ()>::new(1, 3, -5, 4);
let v2 = Vector4D::<i32, ()>::new(4, -2, -1, 3);
assert_eq!(v1 * v2, 15);
pub fn map<F, T>(self, f: F) -> Vector2D<T>where
F: FnMut(S) -> T,
Trait Implementations§
Source§impl<T> AddAssign<Vector2D<T>> for Rect<T>
impl<T> AddAssign<Vector2D<T>> for Rect<T>
Source§fn add_assign(&mut self, vec: Vector2D<T>)
fn add_assign(&mut self, vec: Vector2D<T>)
Performs the
+=
operation. Read moreSource§impl Mul<Vector2D> for Transform2D
impl Mul<Vector2D> for Transform2D
Source§impl Mul<Vector2D> for Transform3D<f32>
Transform a Vector2D
with a Transform3D
.
impl Mul<Vector2D> for Transform3D<f32>
Transform a Vector2D
with a Transform3D
.
use rgx::math::*;
let m = Transform3D::from_translation(Vector3D::new(8., 8., 0.));
let v = Vector2D::new(1., 1.);
assert_eq!(m * v, Vector2D::new(9., 9.));
Source§impl<T> SubAssign<Vector2D<T>> for Rect<T>
impl<T> SubAssign<Vector2D<T>> for Rect<T>
Source§fn sub_assign(&mut self, vec: Vector2D<T>)
fn sub_assign(&mut self, vec: Vector2D<T>)
Performs the
-=
operation. Read moreimpl<S: Copy, Unit: Copy> Copy for Vector2D<S, Unit>
impl<S: Eq, U> Eq for Vector2D<S, U>
Auto Trait Implementations§
impl<S, Unit> Freeze for Vector2D<S, Unit>where
S: Freeze,
impl<S, Unit> RefUnwindSafe for Vector2D<S, Unit>where
S: RefUnwindSafe,
Unit: RefUnwindSafe,
impl<S, Unit> Send for Vector2D<S, Unit>
impl<S, Unit> Sync for Vector2D<S, Unit>
impl<S, Unit> Unpin for Vector2D<S, Unit>
impl<S, Unit> UnwindSafe for Vector2D<S, Unit>where
S: UnwindSafe,
Unit: 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