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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§