#[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 normalize(self) -> Selfwhere
S: One + Float + Div + Mul,
pub fn normalize(self) -> Selfwhere S: One + Float + Div + Mul,
Returns a vector with the same direction and a given magnitude.
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>::Outputwhere
S: Mul<Output = S> + Add,
pub fn dot(a: Self, b: Self) -> <S as Add>::Outputwhere S: Mul<Output = S> + Add,
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>where
T: Add<Output = T> + Copy,
impl<T> AddAssign<Vector2D<T, ()>> for Rect<T>where T: Add<Output = T> + Copy,
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<f32, ()>> for Transform3D<f32>
impl Mul<Vector2D<f32, ()>> 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<S: PartialEq, U> PartialEq<Vector2D<S, U>> for Vector2D<S, U>
impl<S: PartialEq, U> PartialEq<Vector2D<S, U>> for Vector2D<S, U>
source§impl<T> SubAssign<Vector2D<T, ()>> for Rect<T>where
T: Sub<Output = T> + Copy,
impl<T> SubAssign<Vector2D<T, ()>> for Rect<T>where T: Sub<Output = T> + Copy,
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> RefUnwindSafe for Vector2D<S, Unit>where S: RefUnwindSafe, Unit: RefUnwindSafe,
impl<S, Unit> Send for Vector2D<S, Unit>where S: Send, Unit: Send,
impl<S, Unit> Sync for Vector2D<S, Unit>where S: Sync, Unit: Sync,
impl<S, Unit> Unpin for Vector2D<S, Unit>where S: Unpin, Unit: Unpin,
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