#[repr(C)]pub struct Vector2<S> {
pub x: S,
pub y: S,
}Expand description
A 2-dimensional vector.
This type is marked as #[repr(C)].
Fields
x: SThe x component of the vector.
y: SThe y component of the vector.
Implementations
sourceimpl<S> Vector2<S> where
S: BaseNum,
impl<S> Vector2<S> where
S: BaseNum,
Trait Implementations
sourceimpl<S> AbsDiffEq<Vector2<S>> for Vector2<S> where
S: BaseFloat,
impl<S> AbsDiffEq<Vector2<S>> for Vector2<S> where
S: BaseFloat,
type Epsilon = <S as AbsDiffEq<S>>::Epsilon
type Epsilon = <S as AbsDiffEq<S>>::Epsilon
Used for specifying relative comparisons.
sourcefn default_epsilon() -> <S as AbsDiffEq<S>>::Epsilon
fn default_epsilon() -> <S as AbsDiffEq<S>>::Epsilon
The default tolerance to use when testing values that are close together. Read more
sourcefn abs_diff_eq(
&self,
other: &Vector2<S>,
epsilon: <S as AbsDiffEq<S>>::Epsilon
) -> bool
fn abs_diff_eq(
&self,
other: &Vector2<S>,
epsilon: <S as AbsDiffEq<S>>::Epsilon
) -> bool
A test for equality that uses the absolute difference to compute the approximate equality of two numbers. Read more
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
The inverse of [AbsDiffEq::abs_diff_eq].
sourceimpl<S> AddAssign<Vector2<S>> for Vector2<S> where
S: BaseNum + AddAssign<S>,
impl<S> AddAssign<Vector2<S>> for Vector2<S> where
S: BaseNum + AddAssign<S>,
sourcefn add_assign(&mut self, other: Vector2<S>)
fn add_assign(&mut self, other: Vector2<S>)
Performs the += operation. Read more
sourceimpl<S> Array for Vector2<S> where
S: Copy,
impl<S> Array for Vector2<S> where
S: Copy,
type Element = S
sourcefn from_value(scalar: S) -> Vector2<S>
fn from_value(scalar: S) -> Vector2<S>
Construct a vector from a single value, replicating it. Read more
sourcefn 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.
sourcefn 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.
sourceimpl<S> DivAssign<S> for Vector2<S> where
S: BaseNum + DivAssign<S>,
impl<S> DivAssign<S> for Vector2<S> where
S: BaseNum + DivAssign<S>,
sourcefn div_assign(&mut self, scalar: S)
fn div_assign(&mut self, scalar: S)
Performs the /= operation. Read more
sourceimpl<S> ElementWise<S> for Vector2<S> where
S: BaseNum,
impl<S> ElementWise<S> for Vector2<S> where
S: BaseNum,
fn add_element_wise(self, rhs: S) -> Vector2<S>
fn sub_element_wise(self, rhs: S) -> Vector2<S>
fn mul_element_wise(self, rhs: S) -> Vector2<S>
fn div_element_wise(self, rhs: S) -> Vector2<S>
fn rem_element_wise(self, rhs: S) -> Vector2<S>
fn add_assign_element_wise(&mut self, rhs: S)
fn sub_assign_element_wise(&mut self, rhs: S)
fn mul_assign_element_wise(&mut self, rhs: S)
fn div_assign_element_wise(&mut self, rhs: S)
fn rem_assign_element_wise(&mut self, rhs: S)
sourceimpl<S> ElementWise<Vector2<S>> for Vector2<S> where
S: BaseNum,
impl<S> ElementWise<Vector2<S>> for Vector2<S> where
S: BaseNum,
fn add_element_wise(self, rhs: Vector2<S>) -> Vector2<S>
fn sub_element_wise(self, rhs: Vector2<S>) -> Vector2<S>
fn mul_element_wise(self, rhs: Vector2<S>) -> Vector2<S>
fn div_element_wise(self, rhs: Vector2<S>) -> Vector2<S>
fn rem_element_wise(self, rhs: Vector2<S>) -> Vector2<S>
fn add_assign_element_wise(&mut self, rhs: Vector2<S>)
fn sub_assign_element_wise(&mut self, rhs: Vector2<S>)
fn mul_assign_element_wise(&mut self, rhs: Vector2<S>)
fn div_assign_element_wise(&mut self, rhs: Vector2<S>)
fn rem_assign_element_wise(&mut self, rhs: Vector2<S>)
sourceimpl<S> InnerSpace for Vector2<S> where
S: BaseNum,
impl<S> InnerSpace for Vector2<S> where
S: BaseNum,
sourcefn angle(self, other: Vector2<S>) -> Rad<S> where
S: BaseFloat,
fn angle(self, other: Vector2<S>) -> Rad<S> where
S: BaseFloat,
Returns the angle between two vectors in radians.
sourcefn is_perpendicular(self, other: Self) -> bool where
Self::Scalar: UlpsEq<Self::Scalar>,
fn is_perpendicular(self, other: Self) -> bool where
Self::Scalar: UlpsEq<Self::Scalar>,
Returns true if the vector is perpendicular (at right angles) to the
other vector. Read more
sourcefn magnitude2(self) -> Self::Scalar
fn magnitude2(self) -> Self::Scalar
Returns the squared magnitude. Read more
sourcefn project_on(self, other: Self) -> Self
fn project_on(self, other: Self) -> Self
Returns the vector projection of the current inner space projected onto the supplied argument. Read more
sourcefn magnitude(self) -> Self::Scalar where
Self::Scalar: Float,
fn magnitude(self) -> Self::Scalar where
Self::Scalar: Float,
The distance from the tail to the tip of the vector.
sourcefn normalize(self) -> Self where
Self::Scalar: Float,
fn normalize(self) -> Self where
Self::Scalar: Float,
Returns a vector with the same direction, but with a magnitude of 1.
sourcefn normalize_to(self, magnitude: Self::Scalar) -> Self where
Self::Scalar: Float,
fn normalize_to(self, magnitude: Self::Scalar) -> Self where
Self::Scalar: Float,
Returns a vector with the same direction and a given magnitude.
sourceimpl<S> MetricSpace for Vector2<S> where
S: BaseNum,
impl<S> MetricSpace for Vector2<S> where
S: BaseNum,
sourceimpl<S> MulAssign<S> for Vector2<S> where
S: BaseNum + MulAssign<S>,
impl<S> MulAssign<S> for Vector2<S> where
S: BaseNum + MulAssign<S>,
sourcefn mul_assign(&mut self, scalar: S)
fn mul_assign(&mut self, scalar: S)
Performs the *= operation. Read more
sourceimpl<S> RelativeEq<Vector2<S>> for Vector2<S> where
S: BaseFloat,
impl<S> RelativeEq<Vector2<S>> for Vector2<S> where
S: BaseFloat,
sourcefn default_max_relative() -> <S as AbsDiffEq<S>>::Epsilon
fn default_max_relative() -> <S as AbsDiffEq<S>>::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
sourcefn relative_eq(
&self,
other: &Vector2<S>,
epsilon: <S as AbsDiffEq<S>>::Epsilon,
max_relative: <S as AbsDiffEq<S>>::Epsilon
) -> bool
fn relative_eq(
&self,
other: &Vector2<S>,
epsilon: <S as AbsDiffEq<S>>::Epsilon,
max_relative: <S as AbsDiffEq<S>>::Epsilon
) -> bool
A test for equality that uses a relative comparison if the values are far apart.
fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
The inverse of [RelativeEq::relative_eq].
sourceimpl<S> RemAssign<S> for Vector2<S> where
S: BaseNum + RemAssign<S>,
impl<S> RemAssign<S> for Vector2<S> where
S: BaseNum + RemAssign<S>,
sourcefn rem_assign(&mut self, scalar: S)
fn rem_assign(&mut self, scalar: S)
Performs the %= operation. Read more
sourceimpl<S> SubAssign<Vector2<S>> for Vector2<S> where
S: BaseNum + SubAssign<S>,
impl<S> SubAssign<Vector2<S>> for Vector2<S> where
S: BaseNum + SubAssign<S>,
sourcefn sub_assign(&mut self, other: Vector2<S>)
fn sub_assign(&mut self, other: Vector2<S>)
Performs the -= operation. Read more
sourceimpl<S> UlpsEq<Vector2<S>> for Vector2<S> where
S: BaseFloat,
impl<S> UlpsEq<Vector2<S>> for Vector2<S> where
S: BaseFloat,
sourcefn default_max_ulps() -> u32
fn default_max_ulps() -> u32
The default ULPs to tolerate when testing values that are far-apart. Read more
sourceimpl<S> VectorSpace for Vector2<S> where
S: BaseNum,
impl<S> VectorSpace for Vector2<S> where
S: BaseNum,
impl<T: BufferDataType + PrimitiveDataType> BufferDataType for Vector2<T>
impl<S> Copy for Vector2<S> where
S: Copy,
impl<S> Eq for Vector2<S> where
S: Eq,
impl<S> StructuralEq for Vector2<S>
impl<S> StructuralPartialEq for Vector2<S>
impl<T: TextureDataType + PrimitiveDataType> TextureDataType for Vector2<T>
impl<T: UniformDataType + PrimitiveDataType> UniformDataType for Vector2<T>
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key and return true if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more