Struct speedy2d::dimen::Vector2 [−][src]
A vector containing two numeric values. This may represent a size or position.
Fields
x: T
The horizontal component of the vector.
y: T
The vertical component of the vector.
Implementations
impl<T> Vector2<T>
[src]
#[must_use]pub const fn new(x: T, y: T) -> Self
[src]
Instantiates a new Vector2
from the specified horizontal and vertical
components.
impl<T: PrimitiveZero> Vector2<T>
[src]
pub const ZERO: Vector2<T>
[src]
A constant representing a vector of zero magnitude. Each component is set to zero.
impl Vector2<f32>
[src]
#[must_use]pub fn magnitude_squared(&self) -> f32
[src]
Returns the magnitude of the vector, squared.
#[must_use]pub fn magnitude(&self) -> f32
[src]
Returns the magnitude of the vector.
#[must_use]pub fn normalize(&self) -> Option<Vector2<f32>>
[src]
Normalizes the vector so that the magnitude is 1.0
. If the current
magnitude of the vector is 0.0
, then None
is returned to avoid a
division by zero.
impl<T: Neg<Output = T> + Copy> Vector2<T>
[src]
#[must_use]pub fn rotate_90_degrees_clockwise(&self) -> Vector2<T>
[src]
Rotates the vector by 90 degrees in the clockwise direction.
#[must_use]pub fn rotate_90_degrees_anticlockwise(&self) -> Vector2<T>
[src]
Rotates the vector by 90 degrees in the anti-clockwise direction.
impl<T: AsPrimitive<f32>> Vector2<T>
[src]
#[must_use]pub fn into_f32(self) -> Vector2<f32>
[src]
Returns a new vector with each element cast to f32
, using the as
operator.
impl<T: AsPrimitive<i32>> Vector2<T>
[src]
#[must_use]pub fn into_i32(self) -> Vector2<i32>
[src]
Returns a new vector with each element cast to i32
, using the as
operator.
impl<T: TryInto<i32>> Vector2<T>
[src]
pub fn try_into_i32(self) -> Result<Vector2<i32>, T::Error>
[src]
Attempts to convert each element of this vector to an i32
, returning
an error if this fails.
Trait Implementations
impl<T: Copy + Add<Output = T>> Add<&'_ Vector2<T>> for Vector2<T>
[src]
type Output = Vector2<T>
The resulting type after applying the +
operator.
#[must_use]fn add(self, rhs: &Self) -> Self::Output
[src]
impl<T: Copy + Add<Output = T>> Add<Vector2<T>> for Vector2<T>
[src]
type Output = Vector2<T>
The resulting type after applying the +
operator.
#[must_use]fn add(self, rhs: Self) -> Self::Output
[src]
impl<T: Copy + Add<Output = T>> Add<Vector2<T>> for &Vector2<T>
[src]
type Output = Vector2<T>
The resulting type after applying the +
operator.
#[must_use]fn add(self, rhs: Vector2<T>) -> Self::Output
[src]
impl<T: Clone> Clone for Vector2<T>
[src]
impl<T: Copy> Copy for Vector2<T>
[src]
impl<T: Debug> Debug for Vector2<T>
[src]
impl<T: Copy + Div<Output = T>> Div<T> for &Vector2<T>
[src]
type Output = Vector2<T>
The resulting type after applying the /
operator.
#[must_use]fn div(self, rhs: T) -> Self::Output
[src]
impl<T: Copy + Div<Output = T>> Div<T> for Vector2<T>
[src]
type Output = Vector2<T>
The resulting type after applying the /
operator.
#[must_use]fn div(self, rhs: T) -> Self::Output
[src]
impl<T: Eq> Eq for Vector2<T>
[src]
impl<T> From<(T, T)> for Vector2<T> where
T: Copy,
[src]
T: Copy,
impl From<PhysicalSize<u32>> for Vector2<u32>
[src]
impl<T> From<Point<T>> for Vector2<T>
[src]
impl<T: Hash> Hash for Vector2<T>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T: Copy + Mul<Output = T>> Mul<T> for &Vector2<T>
[src]
type Output = Vector2<T>
The resulting type after applying the *
operator.
#[must_use]fn mul(self, rhs: T) -> Self::Output
[src]
impl<T: Copy + Mul<Output = T>> Mul<T> for Vector2<T>
[src]
type Output = Vector2<T>
The resulting type after applying the *
operator.
#[must_use]fn mul(self, rhs: T) -> Self::Output
[src]
impl<T: PartialEq> PartialEq<Vector2<T>> for Vector2<T>
[src]
impl<T: RoundFloat> RoundFloat for Vector2<T>
[src]
impl<T> StructuralEq for Vector2<T>
[src]
impl<T> StructuralPartialEq for Vector2<T>
[src]
impl<T: Copy + Sub<Output = T>> Sub<&'_ Vector2<T>> for Vector2<T>
[src]
type Output = Vector2<T>
The resulting type after applying the -
operator.
#[must_use]fn sub(self, rhs: &Self) -> Self::Output
[src]
impl<T: Copy + Sub<Output = T>> Sub<Vector2<T>> for Vector2<T>
[src]
type Output = Vector2<T>
The resulting type after applying the -
operator.
#[must_use]fn sub(self, rhs: Self) -> Self::Output
[src]
impl<T: Copy + Sub<Output = T>> Sub<Vector2<T>> for &Vector2<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Vector2<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Vector2<T> where
T: Send,
T: Send,
impl<T> Sync for Vector2<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Vector2<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Vector2<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,