[][src]Struct hektor::Vec2

#[repr(C)]
pub struct Vec2 { /* fields omitted */ }

A 2-dimensional vector.

This is two f32 values, x and y.

Methods

impl Vec2[src]

pub fn x(self) -> f32[src]

Gets the x component of this vector.

pub fn y(self) -> f32[src]

Gets the y component of this vector.

pub fn x_mut(&mut self) -> &mut f32[src]

&mut to the x component of this vector.

pub fn y_mut(&mut self) -> &mut f32[src]

&mut to the y component of this vector.

impl Vec2[src]

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

Makes a new Vec2

pub fn splat(v: f32) -> Self[src]

Splats the given value across all components.

pub fn to_vec3(self, z: f32) -> Vec3[src]

Extends this 2d vec into a 3d vec with the z given.

impl Vec2[src]

pub fn dot(self, rhs: Self) -> f32[src]

Dot product.

This is the sum of the component-wise multiplication of the two values. Order doesn't matter. Positive dot product means the vectors are pointing in the same general direction, zero dot product means they're perpendicular, and negative dot product means they have opposite general direction.

pub fn length(self) -> f32[src]

The length / magnitude of the vector.

  • sqrt(x^2 + y^2)

pub fn length2(self) -> f32[src]

The squared length / magnitude of the vector.

  • x^2 + y^2 + z^2

pub fn normalize(self) -> Self[src]

Generates a new vector where the length is 1.0

Or, well, as close as it can get. Floating point, and all that.

impl Vec2[src]

pub fn xx(self) -> Self[src]

Swizzle: obtains the xx combination

pub fn xy(self) -> Self[src]

Swizzle: obtains the xy combination

pub fn yx(self) -> Self[src]

Swizzle: obtains the yx combination

pub fn yy(self) -> Self[src]

Swizzle: obtains the yy combination

Trait Implementations

impl Display for Vec2[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

Display formats without labels like a 2-tuple.

Passes the formatter along to the fields, so you can use any normal f32 Display format arguments that you like.

impl Debug for Vec2[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

Passes the formatter along to the fields, so you can use any normal f32 Debug format arguments that you like.

impl UpperExp for Vec2[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

UpperExp formats like Display, but with the upper exponent.

Passes the formatter along to the fields, so you can use any normal f32 UpperExp format arguments that you like.

impl LowerExp for Vec2[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

LowerExp formats like Display, but with the lower exponent.

Passes the formatter along to the fields, so you can use any normal f32 LowerExp format arguments that you like.

impl PartialEq<Vec2> for Vec2[src]

impl Add<Vec2> for Vec2[src]

type Output = Self

The resulting type after applying the + operator.

impl Add<f32> for Vec2[src]

type Output = Self

The resulting type after applying the + operator.

impl Add<Vec2> for f32[src]

type Output = Vec2

The resulting type after applying the + operator.

impl Sub<Vec2> for Vec2[src]

type Output = Self

The resulting type after applying the - operator.

impl Sub<f32> for Vec2[src]

type Output = Self

The resulting type after applying the - operator.

impl Sub<Vec2> for f32[src]

type Output = Vec2

The resulting type after applying the - operator.

impl Mul<f32> for Vec2[src]

type Output = Self

The resulting type after applying the * operator.

impl Mul<Vec2> for f32[src]

type Output = Vec2

The resulting type after applying the * operator.

impl Mul<Vec2> for Vec2[src]

type Output = Self

The resulting type after applying the * operator.

fn mul(self, rhs: Self) -> Self[src]

Non-mathematical component-wise multiplication (GLSL-style)

impl Mul<Vec2> for Mat2[src]

type Output = Vec2

The resulting type after applying the * operator.

impl Neg for Vec2[src]

type Output = Self

The resulting type after applying the - operator.

impl AddAssign<Vec2> for Vec2[src]

impl AddAssign<f32> for Vec2[src]

impl SubAssign<Vec2> for Vec2[src]

impl SubAssign<f32> for Vec2[src]

impl MulAssign<f32> for Vec2[src]

impl MulAssign<Vec2> for Vec2[src]

impl Index<usize> for Vec2[src]

type Output = f32

The returned type after indexing.

impl IndexMut<usize> for Vec2[src]

impl Copy for Vec2[src]

impl AsRef<[f32; 2]> for Vec2[src]

impl AsMut<[f32; 2]> for Vec2[src]

impl From<[f32; 2]> for Vec2[src]

impl From<Vec2> for [f32; 2][src]

impl Clone for Vec2[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Default for Vec2[src]

impl Pod for Vec2[src]

impl Zeroable for Vec2[src]

fn zeroed() -> Self[src]

Calls zeroed. Read more

Auto Trait Implementations

impl Unpin for Vec2

impl Sync for Vec2

impl Send for Vec2

Blanket Implementations

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]