Struct euler::Vec2

source ·
#[repr(C)]
pub struct Vec2 { pub x: f32, pub y: f32, }
Expand description

Single-precision 2D vector.

Fields§

§x: f32§y: f32

Implementations§

source§

impl Vec2

source

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

Full constructor.

source

pub fn zero() -> Self

Zero constructor.

source§

impl Vec2

source

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

Returns the dot product of two vectors.

source

pub fn length(self) -> f32

Returns the length (magnitude) of the vector.

source

pub fn squared_length(self) -> f32

Returns the squared length of the vector.

source

pub fn normalize(self) -> Vec2

Scales the vector to unit length.

Panics

Panics if the vector is zero.

source§

impl Vec2

source

pub fn angle(self, rhs: Vec2) -> f32

Returns the acute angle between two vectors.

Panics

Panics if self is the zero vector.

Trait Implementations§

source§

impl Add<Vec2> for Vec2

§

type Output = Vec2

The resulting type after applying the + operator.
source§

fn add(self, rhs: Vec2) -> Self::Output

Performs the + operation. Read more
source§

impl AddAssign<Vec2> for Vec2

source§

fn add_assign(&mut self, rhs: Vec2)

Performs the += operation. Read more
source§

impl ApproxEq for Vec2

§

type Epsilon = <Vector2<f32> as ApproxEq>::Epsilon

Used for specifying relative comparisons.
source§

fn default_epsilon() -> Self::Epsilon

The default tolerance to use when testing values that are close together. Read more
source§

fn default_max_relative() -> Self::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
source§

fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart. Read more
source§

fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
source§

fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool

A test for equality that uses units in the last place (ULP) if the values are far apart.
source§

fn relative_ne( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool

The inverse of ApproxEq::relative_eq.
source§

fn ulps_ne(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool

The inverse of ApproxEq::ulps_eq.
source§

impl AsRef<[f32; 2]> for Vec2

source§

fn as_ref(&self) -> &[f32; 2]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for Vec2

source§

fn clone(&self) -> Vec2

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 Debug for Vec2

source§

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

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

impl Default for Vec2

source§

fn default() -> Vec2

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

impl Display for Vec2

source§

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

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

impl Div<f32> for Vec2

§

type Output = Vec2

The resulting type after applying the / operator.
source§

fn div(self, arg: f32) -> Self::Output

Performs the / operation. Read more
source§

impl DivAssign<f32> for Vec2

source§

fn div_assign(&mut self, rhs: f32)

Performs the /= operation. Read more
source§

impl From<[f32; 2]> for Vec2

source§

fn from(array: [f32; 2]) -> Self

Converts to this type from the input type.
source§

impl From<DVec2> for Vec2

source§

fn from(arg: DVec2) -> Self

Converts to this type from the input type.
source§

impl From<Vec2> for DVec2

source§

fn from(arg: Vec2) -> Self

Converts to this type from the input type.
source§

impl From<f32> for Vec2

source§

fn from(arg: f32) -> Self

Converts to this type from the input type.
source§

impl From<f64> for Vec2

source§

fn from(arg: f64) -> Self

Converts to this type from the input type.
source§

impl Into<[f32; 2]> for Vec2

source§

fn into(self) -> [f32; 2]

Converts this type into the (usually inferred) input type.
source§

impl<'a> Mul<Vec2> for &'a Mat2

§

type Output = Vec2

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Vec2) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Vec2> for Mat2

§

type Output = Vec2

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Vec2) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Vec2> for f32

§

type Output = Vec2

The resulting type after applying the * operator.
source§

fn mul(self, arg: Vec2) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<f32> for Vec2

§

type Output = Vec2

The resulting type after applying the * operator.
source§

fn mul(self, arg: f32) -> Self::Output

Performs the * operation. Read more
source§

impl MulAssign<f32> for Vec2

source§

fn mul_assign(&mut self, rhs: f32)

Performs the *= operation. Read more
source§

impl PartialEq<Vec2> for Vec2

source§

fn eq(&self, other: &Vec2) -> 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 Sub<Vec2> for Vec2

§

type Output = Vec2

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Vec2) -> Self::Output

Performs the - operation. Read more
source§

impl SubAssign<Vec2> for Vec2

source§

fn sub_assign(&mut self, rhs: Vec2)

Performs the -= operation. Read more
source§

impl<'a> Sum<&'a Vec2> for Vec2

source§

fn sum<I>(iter: I) -> Selfwhere I: Iterator<Item = &'a Self>,

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl Sum<Vec2> for Vec2

source§

fn sum<I>(iter: I) -> Selfwhere I: Iterator<Item = Self>,

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl Copy for Vec2

source§

impl StructuralPartialEq for Vec2

Auto Trait Implementations§

§

impl RefUnwindSafe for Vec2

§

impl Send for Vec2

§

impl Sync for Vec2

§

impl Unpin for Vec2

§

impl UnwindSafe for Vec2

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.