Trait cgmath::InnerSpace
source · pub trait InnerSpace: VectorSpacewhere
Self: MetricSpace<Metric = <Self as VectorSpace>::Scalar>,{
// Required method
fn dot(self, other: Self) -> Self::Scalar;
// Provided methods
fn is_perpendicular(self, other: Self) -> bool
where Self::Scalar: UlpsEq { ... }
fn magnitude2(self) -> Self::Scalar { ... }
fn angle(self, other: Self) -> Rad<Self::Scalar>
where Self::Scalar: BaseFloat { ... }
fn project_on(self, other: Self) -> Self { ... }
fn magnitude(self) -> Self::Scalar
where Self::Scalar: Float { ... }
fn normalize(self) -> Self
where Self::Scalar: Float { ... }
fn normalize_to(self, magnitude: Self::Scalar) -> Self
where Self::Scalar: Float { ... }
}
Expand description
Required Methods§
Provided Methods§
sourcefn is_perpendicular(self, other: Self) -> boolwhere
Self::Scalar: UlpsEq,
fn is_perpendicular(self, other: Self) -> boolwhere Self::Scalar: UlpsEq,
Returns true
if the vector is perpendicular (at right angles) to the
other vector.
sourcefn magnitude2(self) -> Self::Scalar
fn magnitude2(self) -> Self::Scalar
Returns the squared magnitude.
This does not perform an expensive square root operation like in
InnerSpace::magnitude
method, and so can be used to compare magnitudes
more efficiently.
sourcefn angle(self, other: Self) -> Rad<Self::Scalar>where
Self::Scalar: BaseFloat,
fn angle(self, other: Self) -> Rad<Self::Scalar>where Self::Scalar: BaseFloat,
Returns the angle between two vectors in radians.
sourcefn project_on(self, other: Self) -> Self
fn project_on(self, other: Self) -> Self
Returns the vector projection of the current inner space projected onto the supplied argument.
sourcefn magnitude(self) -> Self::Scalarwhere
Self::Scalar: Float,
fn magnitude(self) -> Self::Scalarwhere Self::Scalar: Float,
The distance from the tail to the tip of the vector.
sourcefn normalize(self) -> Selfwhere
Self::Scalar: Float,
fn normalize(self) -> Selfwhere Self::Scalar: Float,
Returns a vector with the same direction, but with a magnitude of 1
.
sourcefn normalize_to(self, magnitude: Self::Scalar) -> Selfwhere
Self::Scalar: Float,
fn normalize_to(self, magnitude: Self::Scalar) -> Selfwhere Self::Scalar: Float,
Returns a vector with the same direction and a given magnitude.