Fields
x: f64
y: f64
Implementations
Trait Implementations
sourceimpl AddAssign<Vector2> for Vector2
impl AddAssign<Vector2> for Vector2
sourcefn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Adds two vectors together and assigns the result back to the first.
Example:
let mut a = Vector2::new(1.0, 2.0);
let b = Vector2::new(3.0, 4.0);
a += b;
let expected = Vector2::new(4.0, 6.0);
assert_eq!(a, expected);
sourceimpl DivAssign<f64> for Vector2
impl DivAssign<f64> for Vector2
sourcefn div_assign(&mut self, other: f64)
fn div_assign(&mut self, other: f64)
Divides the vector with some scalar and assigns the result back into the vector
sourceimpl MulAssign<f64> for Vector2
impl MulAssign<f64> for Vector2
sourcefn mul_assign(&mut self, other: f64)
fn mul_assign(&mut self, other: f64)
Multiplies the vector with some scalar and assigns the result back onto the vector
Example:
let mut a = Vector2::new(3.0, 4.0);
a *= 3.0;
let expected = Vector2::new(9.0, 12.0);
assert_eq!(a, expected);
sourceimpl PartialOrd<Vector2> for Vector2
impl PartialOrd<Vector2> for Vector2
sourcefn partial_cmp(&self, other: &Vector2) -> Option<Ordering>
fn partial_cmp(&self, other: &Vector2) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
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 moresourceimpl Sub<Vector2> for Vector2
impl Sub<Vector2> for Vector2
sourceimpl SubAssign<Vector2> for Vector2
impl SubAssign<Vector2> for Vector2
sourcefn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
Subtracts two vectors from each other and assigns the result back to the first.
Example:
let mut a = Vector2::new(5.0, 8.0);
let b = Vector2::new(6.0, 4.0);
a -= b;
let expected = Vector2::new(-1.0, 4.0);
assert_eq!(a, expected);
sourceimpl Vector for Vector2
impl Vector for Vector2
sourcefn reflect(self, normal: Self) -> Self
fn reflect(self, normal: Self) -> Self
Reflects the vector along the normal
vector.
Example:
let a = Vector2::new(1.0, 2.0);
let n = Vector2::up();
let r = a.reflect(n);
assert_eq!(r, Vector2::new(1.0, -2.0));
type Scalar = f64
sourcefn normalized(self) -> Self
fn normalized(self) -> Self
Returns a vector with the same angle, but with a magnitude of 1
sourcefn sqr_magnitude(&self) -> Self::Scalar
fn sqr_magnitude(&self) -> Self::Scalar
Returns the magnitude squared
sourcefn clamp_magnitude(self, max_len: Self::Scalar) -> Self
fn clamp_magnitude(self, max_len: Self::Scalar) -> Self
Returns a new vector with a magnitude clamped to
max_len
.fn scale(self, other: Self) -> Self
sourcefn lerp_unclamped(self, other: Self, t: Self::Scalar) -> Self
fn lerp_unclamped(self, other: Self, t: Self::Scalar) -> Self
Performs a linear interpolation, where
t
isn’t clamped between 0 and 1. Read moreimpl Copy for Vector2
impl StructuralPartialEq for Vector2
Auto Trait Implementations
impl RefUnwindSafe for Vector2
impl Send for Vector2
impl Sync for Vector2
impl Unpin for Vector2
impl UnwindSafe for Vector2
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more