Type Definition speedy2d::dimen::Vec2

source ·
pub type Vec2 = Vector2<f32>;
Expand description

A vector with two f32 values.

Implementations§

source§

impl Vec2

source

pub fn magnitude_squared(&self) -> f32

Returns the magnitude of the vector, squared.

source

pub fn magnitude(&self) -> f32

Returns the magnitude of the vector.

source

pub fn normalize(&self) -> Option<Vec2>

Normalizes the vector so that the magnitude is 1.0. If the current magnitude of the vector is 0.0, then None is returned to avoid a division by zero.