pub struct Vector2<S> {
pub x: S,
pub y: S,
}
Fields§
§x: S
§y: S
Implementations§
Trait Implementations§
source§impl<S: Copy> Array for Vector2<S>
impl<S: Copy> Array for Vector2<S>
type Element = S
source§fn min(self) -> Swhere
S: PartialOrd,
fn min(self) -> Swhere S: PartialOrd,
The minimum element of the array.
source§fn max(self) -> Swhere
S: PartialOrd,
fn max(self) -> Swhere S: PartialOrd,
The maximum element of the array.
source§fn as_mut_ptr(&mut self) -> *mut Self::Element
fn as_mut_ptr(&mut self) -> *mut Self::Element
Get a mutable pointer to the first element of the array.
source§fn swap_elements(&mut self, i: usize, j: usize)
fn swap_elements(&mut self, i: usize, j: usize)
Swap the elements at indices
i
and j
in-place.source§impl<S: BaseFloat> EuclideanVector for Vector2<S>
impl<S: BaseFloat> EuclideanVector for Vector2<S>
source§fn angle(self, other: Vector2<S>) -> Rad<S>
fn angle(self, other: Vector2<S>) -> Rad<S>
The angle between the vector and
other
, in radians.source§fn is_perpendicular(self, other: Self) -> bool
fn is_perpendicular(self, other: Self) -> bool
Returns
true
if the vector is perpendicular (at right angles) to the
other vector.source§fn length2(self) -> Self::Scalar
fn length2(self) -> Self::Scalar
Returns the squared length of the vector. This does not perform an
expensive square root operation like in the
length
method and can
therefore be more efficient for comparing the lengths of two vectors.source§fn normalize(self) -> Self
fn normalize(self) -> Self
Returns a vector with the same direction, but with a
length
(or
norm
) of 1
.source§fn normalize_to(self, length: Self::Scalar) -> Self
fn normalize_to(self, length: Self::Scalar) -> Self
Returns a vector with the same direction and a given
length
.source§fn lerp(self, other: Self, amount: Self::Scalar) -> Self
fn lerp(self, other: Self, amount: Self::Scalar) -> Self
Returns the result of linarly interpolating the length of the vector
towards the length of
other
by the specified amount.source§fn normalize_self(&mut self)
fn normalize_self(&mut self)
Normalises the vector to a length of
1
.source§fn normalize_self_to(&mut self, length: Self::Scalar)
fn normalize_self_to(&mut self, length: Self::Scalar)
Normalizes the vector to
length
.source§impl<S: PartialEq> PartialEq<Vector2<S>> for Vector2<S>
impl<S: PartialEq> PartialEq<Vector2<S>> for Vector2<S>
source§impl<S: BaseNum> Vector for Vector2<S>
impl<S: BaseNum> Vector for Vector2<S>
source§fn from_value(scalar: S) -> Vector2<S>
fn from_value(scalar: S) -> Vector2<S>
Construct a vector from a single value, replicating it.
source§fn sub_s(self, scalar: S) -> Vector2<S>
fn sub_s(self, scalar: S) -> Vector2<S>
Subtract a scalar from this vector, returning a new vector.
source§fn mul_s(self, scalar: S) -> Vector2<S>
fn mul_s(self, scalar: S) -> Vector2<S>
Multiply this vector by a scalar, returning a new vector.
source§fn div_s(self, scalar: S) -> Vector2<S>
fn div_s(self, scalar: S) -> Vector2<S>
Divide this vector by a scalar, returning a new vector.
source§fn rem_s(self, scalar: S) -> Vector2<S>
fn rem_s(self, scalar: S) -> Vector2<S>
Take the remainder of this vector by a scalar, returning a new vector.
source§fn add_v(self, v: Vector2<S>) -> Vector2<S>
fn add_v(self, v: Vector2<S>) -> Vector2<S>
Add this vector to another, returning a new vector.
source§fn sub_v(self, v: Vector2<S>) -> Vector2<S>
fn sub_v(self, v: Vector2<S>) -> Vector2<S>
Subtract another vector from this one, returning a new vector.
source§fn mul_v(self, v: Vector2<S>) -> Vector2<S>
fn mul_v(self, v: Vector2<S>) -> Vector2<S>
Multiply this vector by another, returning a new vector.
source§fn div_v(self, v: Vector2<S>) -> Vector2<S>
fn div_v(self, v: Vector2<S>) -> Vector2<S>
Divide this vector by another, returning a new vector.
source§fn rem_v(self, v: Vector2<S>) -> Vector2<S>
fn rem_v(self, v: Vector2<S>) -> Vector2<S>
Take the remainder of this vector by another, returning a new scalar.
source§fn add_self_s(&mut self, scalar: S)
fn add_self_s(&mut self, scalar: S)
Add a scalar to this vector in-place.
source§fn sub_self_s(&mut self, scalar: S)
fn sub_self_s(&mut self, scalar: S)
Subtract a scalar from this vector, in-place.
source§fn mul_self_s(&mut self, scalar: S)
fn mul_self_s(&mut self, scalar: S)
Multiply this vector by a scalar, in-place.
source§fn div_self_s(&mut self, scalar: S)
fn div_self_s(&mut self, scalar: S)
Divide this vector by a scalar, in-place.
source§fn rem_self_s(&mut self, scalar: S)
fn rem_self_s(&mut self, scalar: S)
Take the remainder of this vector by a scalar, in-place.
source§fn add_self_v(&mut self, v: Vector2<S>)
fn add_self_v(&mut self, v: Vector2<S>)
Add another vector to this one, in-place.
source§fn sub_self_v(&mut self, v: Vector2<S>)
fn sub_self_v(&mut self, v: Vector2<S>)
Subtract another vector from this one, in-place.
source§fn mul_self_v(&mut self, v: Vector2<S>)
fn mul_self_v(&mut self, v: Vector2<S>)
Multiply this matrix by another, in-place.
source§fn div_self_v(&mut self, v: Vector2<S>)
fn div_self_v(&mut self, v: Vector2<S>)
Divide this matrix by anothor, in-place.
source§fn rem_self_v(&mut self, v: Vector2<S>)
fn rem_self_v(&mut self, v: Vector2<S>)
Take the remainder of this vector by another, in-place.
impl<S: Copy> Copy for Vector2<S>
impl<S: Eq> Eq for Vector2<S>
impl<S> StructuralEq for Vector2<S>
impl<S> StructuralPartialEq for Vector2<S>
Auto Trait Implementations§
impl<S> RefUnwindSafe for Vector2<S>where S: RefUnwindSafe,
impl<S> Send for Vector2<S>where S: Send,
impl<S> Sync for Vector2<S>where S: Sync,
impl<S> Unpin for Vector2<S>where S: Unpin,
impl<S> UnwindSafe for Vector2<S>where S: 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