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§
Sourcefn as_mut_array(&mut self) -> &mut [S; 2]
fn as_mut_array(&mut self) -> &mut [S; 2]
Convert to a mutable array.
Can also use the indexing operator[]
.
Sourcefn add_componentwise(&self, rhs: Self) -> Self
fn add_componentwise(&self, rhs: Self) -> Self
Add component by component.
Can also use the +
operator.
Sourcefn sub_componentwise(&self, rhs: Self) -> Self
fn sub_componentwise(&self, rhs: Self) -> Self
Subtract component by component.
Can also use the -
operator.
Sourcefn mul_componentwise(&self, rhs: Self) -> Self
fn mul_componentwise(&self, rhs: Self) -> Self
Multiply component by component.
Can also use the *
operator.
Sourcefn div_componentwise(&self, rhs: Self) -> Self
fn div_componentwise(&self, rhs: Self) -> Self
Divide component by component.
Can also use the /
operator.
Sourcefn min_componentwise(&self, rhs: Self) -> Self
fn min_componentwise(&self, rhs: Self) -> Self
For each lane, select the smallest component of the two.
Sourcefn max_componentwise(&self, rhs: Self) -> Self
fn max_componentwise(&self, rhs: Self) -> Self
For each lane, select the largest component of the two.
Sourcefn min_reduce(&self) -> S
fn min_reduce(&self) -> S
Smallest of the four components.
Sourcefn max_reduce(&self) -> S
fn max_reduce(&self) -> S
Largest of the four components.
Provided Methods§
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.