pub trait Vec2Ext {
// Required methods
fn distance_to(self, other: Vec2) -> f32;
fn distance_squared_to(self, other: Vec2) -> f32;
fn angle_to(self, other: Vec2) -> f32;
fn rotated(self, angle: f32) -> Vec2;
fn move_toward(self, target: Vec2, max_delta: f32) -> Vec2;
fn reflect(self, normal: Vec2) -> Vec2;
fn projected_onto(self, onto: Vec2) -> Vec2;
fn perp(self) -> Vec2;
fn to_ivec(self) -> IVec2;
}Expand description
Extension trait for Vec2 with game-oriented helpers.
Required Methods§
Sourcefn distance_to(self, other: Vec2) -> f32
fn distance_to(self, other: Vec2) -> f32
Euclidean distance to another point.
Sourcefn distance_squared_to(self, other: Vec2) -> f32
fn distance_squared_to(self, other: Vec2) -> f32
Squared Euclidean distance (avoids sqrt).
Sourcefn move_toward(self, target: Vec2, max_delta: f32) -> Vec2
fn move_toward(self, target: Vec2, max_delta: f32) -> Vec2
Move toward target by at most max_delta.
Sourcefn reflect(self, normal: Vec2) -> Vec2
fn reflect(self, normal: Vec2) -> Vec2
Reflect this vector off a surface with the given normal.
Sourcefn projected_onto(self, onto: Vec2) -> Vec2
fn projected_onto(self, onto: Vec2) -> Vec2
Project self onto onto.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".