Add an `abs` method to `Vector2F`

This commit is contained in:
Patrick Walton 2020-05-15 19:11:16 -07:00
parent 3433545a76
commit 440510a126
1 changed files with 6 additions and 0 deletions

View File

@ -131,6 +131,12 @@ impl Vector2F {
Vector2F(self.0.yx()) Vector2F(self.0.yx())
} }
/// Returns the vector (|x|, |y|).
#[inline]
pub fn abs(self) -> Vector2F {
Vector2F(self.0.abs())
}
/// Returns the coefficient when the given vector `a` is projected onto this one. /// Returns the coefficient when the given vector `a` is projected onto this one.
/// ///
/// That is, if this vector is `v` and this function returns `c`, then `proj_v a = cv`. In /// That is, if this vector is `v` and this function returns `c`, then `proj_v a = cv`. In