Struct ochre::Vec2[][src]

pub struct Vec2 {
    pub x: f32,
    pub y: f32,
}

A 2-dimensional vector.

Fields

x: f32y: f32

Implementations

impl Vec2[src]

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

Constructs a 2-dimensional vector.

pub fn dot(self, other: Vec2) -> f32[src]

Computes the dot product between two vectors.

pub fn cross(self, other: Vec2) -> f32[src]

Considering the two given vectors as 3-dimensional vectors lying in the XY-plane, finds the z-coordinate of their cross product.

pub fn distance(self, other: Vec2) -> f32[src]

Computes the distance between two points.

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

Computes the length of a vector.

pub fn normalized(self) -> Vec2[src]

Finds the vector with the same direction and a length of 1.

pub fn lerp(t: f32, a: Vec2, b: Vec2) -> Vec2[src]

Linearly interpolates between two vectors by the parameter t.

pub fn min(self, other: Vec2) -> Vec2[src]

Finds the componentwise minimum of two vectors.

pub fn max(self, other: Vec2) -> Vec2[src]

Finds the componentwise maximum of two vectors.

Trait Implementations

impl Add<Vec2> for Vec2[src]

type Output = Vec2

The resulting type after applying the + operator.

impl AddAssign<Vec2> for Vec2[src]

impl Clone for Vec2[src]

impl Copy for Vec2[src]

impl Debug for Vec2[src]

impl Mul<Vec2> for Mat2x2[src]

type Output = Vec2

The resulting type after applying the * operator.

impl Mul<f32> for Vec2[src]

type Output = Vec2

The resulting type after applying the * operator.

impl PartialEq<Vec2> for Vec2[src]

impl StructuralPartialEq for Vec2[src]

impl Sub<Vec2> for Vec2[src]

type Output = Vec2

The resulting type after applying the - operator.

impl SubAssign<Vec2> for Vec2[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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> 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.