Trait cgmath::EuclideanVector [] [src]

pub trait EuclideanVector<S: BaseFloat>: Vector<S> + ApproxEq<S> + Sized {
    fn angle(&self, other: &Self) -> Rad<S>;

    fn is_perpendicular(&self, other: &Self) -> bool { ... }
    fn length2(&self) -> S { ... }
    fn length(&self) -> S { ... }
    fn normalize(&self) -> Self { ... }
    fn normalize_to(&self, length: S) -> Self { ... }
    fn lerp(&self, other: &Self, amount: S) -> Self { ... }
    fn normalize_self(&mut self) { ... }
    fn normalize_self_to(&mut self, length: S) { ... }
    fn lerp_self(&mut self, other: &Self, amount: S) { ... }
}

Specifies geometric operations for vectors. This is only implemented for 2-dimensional and 3-dimensional vectors.

Required Methods

fn angle(&self, other: &Self) -> Rad<S>

The angle between the vector and other, in radians.

Provided Methods

fn is_perpendicular(&self, other: &Self) -> bool

Returns true if the vector is perpendicular (at right angles) to the other vector.

fn length2(&self) -> S

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.

fn length(&self) -> S

The norm of the vector.

fn normalize(&self) -> Self

Returns a vector with the same direction, but with a length (or norm) of 1.

fn normalize_to(&self, length: S) -> Self

Returns a vector with the same direction and a given length.

fn lerp(&self, other: &Self, amount: S) -> Self

Returns the result of linarly interpolating the length of the vector towards the length of other by the specified amount.

fn normalize_self(&mut self)

Normalises the vector to a length of 1.

fn normalize_self_to(&mut self, length: S)

Normalizes the vector to length.

fn lerp_self(&mut self, other: &Self, amount: S)

Linearly interpolates the length of the vector towards the length of other by the specified amount.

Implementors