Trait cgmath::EuclideanVector
source · pub trait EuclideanVector: Vector + Sizedwhere
<Self as Vector>::Scalar: BaseFloat,
Self: ApproxEq<Epsilon = <Self as Vector>::Scalar>,{
// Required method
fn angle(self, other: Self) -> Rad<Self::Scalar>;
// Provided methods
fn is_perpendicular(self, other: Self) -> bool { ... }
fn length2(self) -> Self::Scalar { ... }
fn length(self) -> Self::Scalar { ... }
fn normalize(self) -> Self { ... }
fn normalize_to(self, length: Self::Scalar) -> Self { ... }
fn lerp(self, other: Self, amount: Self::Scalar) -> Self { ... }
fn normalize_self(&mut self) { ... }
fn normalize_self_to(&mut self, length: Self::Scalar) { ... }
fn lerp_self(&mut self, other: Self, amount: Self::Scalar) { ... }
}
Expand description
Specifies geometric operations for vectors. This is only implemented for 2-dimensional and 3-dimensional vectors.
Required Methods§
Provided Methods§
sourcefn is_perpendicular(self, other: Self) -> bool
fn is_perpendicular(self, other: Self) -> bool
Returns true
if the vector is perpendicular (at right angles) to the
other vector.
sourcefn length2(self) -> Self::Scalar
fn length2(self) -> Self::Scalar
Returns the squared length of the vector. This does not perform an
expensive square root operation like in the length
method and can
therefore be more efficient for comparing the lengths of two vectors.
sourcefn normalize(self) -> Self
fn normalize(self) -> Self
Returns a vector with the same direction, but with a length
(or
norm
) of 1
.
sourcefn normalize_to(self, length: Self::Scalar) -> Self
fn normalize_to(self, length: Self::Scalar) -> Self
Returns a vector with the same direction and a given length
.
sourcefn lerp(self, other: Self, amount: Self::Scalar) -> Self
fn lerp(self, other: Self, amount: Self::Scalar) -> Self
Returns the result of linarly interpolating the length of the vector
towards the length of other
by the specified amount.
sourcefn normalize_self(&mut self)
fn normalize_self(&mut self)
Normalises the vector to a length of 1
.
sourcefn normalize_self_to(&mut self, length: Self::Scalar)
fn normalize_self_to(&mut self, length: Self::Scalar)
Normalizes the vector to length
.