#[repr(C)]
pub struct V2d<T> { pub x: T, pub y: T, }
Expand description

Generic 2D vector type. See Vf2d and Vi2d for more information.

Don’t use this generic struct directly. Prefer using Vf2d (alias for V2d<f32>) and Vi2d (alias for V2d<i32>) instead. This struct is only exported to show available functions and implemented traits.

Fields§

§x: T§y: T

Implementations§

source§

impl<T> V2d<T>

source

pub fn new(x: T, y: T) -> Self

Creates new V2d struct.

source§

impl V2d<i32>

source

pub fn mag(&self) -> i32

Returns magnitude (or length) of a vector.

source

pub fn mag2(&self) -> i32

Returns magnitude squared.

source

pub fn norm(&self) -> Self

Returns vector norm.

source

pub fn perp(&self) -> Self

Returns perpendicular vector.

source

pub fn dot(&self, rhs: Vi2d) -> i32

Returns dot product of two vectors.

source

pub fn cross(&self, rhs: Vi2d) -> i32

Returns cross product of two vectors.

source§

impl V2d<f32>

source

pub fn mag(&self) -> f32

Returns magnitude (or length) of a vector.

source

pub fn mag2(&self) -> f32

Returns magnitude squared.

source

pub fn norm(&self) -> Self

Returns vector norm.

source

pub fn perp(&self) -> Self

Returns perpendicular vector.

source

pub fn dot(&self, rhs: Vf2d) -> f32

Returns dot product of two vectors.

source

pub fn cross(&self, rhs: Vf2d) -> f32

Returns cross product of two vectors.

Trait Implementations§

source§

impl<T: Add<Output = T>> Add<V2d<T>> for V2d<T>

§

type Output = V2d<T>

The resulting type after applying the + operator.
source§

fn add(self, other: Self) -> Self::Output

Performs the + operation. Read more
source§

impl<T: AddAssign> AddAssign<V2d<T>> for V2d<T>

source§

fn add_assign(&mut self, other: Self)

Performs the += operation. Read more
source§

impl<T: Clone> Clone for V2d<T>

source§

fn clone(&self) -> V2d<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for V2d<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: Default> Default for V2d<T>

source§

fn default() -> V2d<T>

Returns the “default value” for a type. Read more
source§

impl<T: Display + Debug> Display for V2d<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: Div<Output = T>> Div<V2d<T>> for V2d<T>

§

type Output = V2d<T>

The resulting type after applying the / operator.
source§

fn div(self, other: Self) -> Self::Output

Performs the / operation. Read more
source§

impl<T: DivAssign> DivAssign<V2d<T>> for V2d<T>

source§

fn div_assign(&mut self, other: Self)

Performs the /= operation. Read more
source§

impl<T> From<(T, T)> for V2d<T>

source§

fn from(tuple: (T, T)) -> Self

Converts to this type from the input type.
source§

impl<T: Mul<Output = T>> Mul<V2d<T>> for V2d<T>

§

type Output = V2d<T>

The resulting type after applying the * operator.
source§

fn mul(self, other: Self) -> Self::Output

Performs the * operation. Read more
source§

impl<T: MulAssign> MulAssign<V2d<T>> for V2d<T>

source§

fn mul_assign(&mut self, other: Self)

Performs the *= operation. Read more
source§

impl<T: PartialEq> PartialEq<V2d<T>> for V2d<T>

source§

fn eq(&self, other: &V2d<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Sub<Output = T>> Sub<V2d<T>> for V2d<T>

§

type Output = V2d<T>

The resulting type after applying the - operator.
source§

fn sub(self, other: Self) -> Self::Output

Performs the - operation. Read more
source§

impl<T: SubAssign> SubAssign<V2d<T>> for V2d<T>

source§

fn sub_assign(&mut self, other: Self)

Performs the -= operation. Read more
source§

impl<T: Copy> Copy for V2d<T>

source§

impl<T> StructuralPartialEq for V2d<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for V2d<T>where T: RefUnwindSafe,

§

impl<T> Send for V2d<T>where T: Send,

§

impl<T> Sync for V2d<T>where T: Sync,

§

impl<T> Unpin for V2d<T>where T: Unpin,

§

impl<T> UnwindSafe for V2d<T>where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.