Trait mafs::Vec2

source ·
pub trait Vec2<S>where
    Self: VecOps<S>,
    S: Float + ScalarOps<Self>,{
Show 17 methods // Required methods fn new(x: S, y: S) -> Self; fn as_array(&self) -> &[S; 2]; fn as_mut_array(&mut self) -> &mut [S; 2]; fn add_componentwise(&self, rhs: Self) -> Self; fn sub_componentwise(&self, rhs: Self) -> Self; fn mul_componentwise(&self, rhs: Self) -> Self; fn div_componentwise(&self, rhs: Self) -> Self; fn min_componentwise(&self, rhs: Self) -> Self; fn max_componentwise(&self, rhs: Self) -> Self; fn floor(&self) -> Self; fn min_reduce(&self) -> S; fn max_reduce(&self) -> S; fn eq_reduce(&self, rhs: Self) -> bool; fn dot(&self, rhs: Self) -> S; // Provided methods fn splat(value: S) -> Self { ... } fn norm(&self) -> S { ... } fn normalize(&self) -> Self { ... }
}
Expand description

Methods on two-dimensional vectors.

  • S is the type of the vector’s components.

Required Methods§

source

fn new(x: S, y: S) -> Self

Create a new two-dimensional vector.

source

fn as_array(&self) -> &[S; 2]

Convert to an array. Can also use the indexing operator [].

source

fn as_mut_array(&mut self) -> &mut [S; 2]

Convert to a mutable array. Can also use the indexing operator[].

source

fn add_componentwise(&self, rhs: Self) -> Self

Add component by component. Can also use the + operator.

source

fn sub_componentwise(&self, rhs: Self) -> Self

Subtract component by component. Can also use the - operator.

source

fn mul_componentwise(&self, rhs: Self) -> Self

Multiply component by component. Can also use the * operator.

source

fn div_componentwise(&self, rhs: Self) -> Self

Divide component by component. Can also use the / operator.

source

fn min_componentwise(&self, rhs: Self) -> Self

For each lane, select the smallest component of the two.

source

fn max_componentwise(&self, rhs: Self) -> Self

For each lane, select the largest component of the two.

source

fn floor(&self) -> Self

Round down all components to an integer value.

source

fn min_reduce(&self) -> S

Smallest of the four components.

source

fn max_reduce(&self) -> S

Largest of the four components.

source

fn eq_reduce(&self, rhs: Self) -> bool

Equality of a vector to another on all components.

source

fn dot(&self, rhs: Self) -> S

Dot product.

Provided Methods§

source

fn splat(value: S) -> Self

Create a two-dimensional vector all with equal components.

source

fn norm(&self) -> S

Norm of this vector.

source

fn normalize(&self) -> Self

Divide by the norm to obain a normalized vector.

Implementors§