From 440510a126ca832571d4fa328ce12169a7c53835 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 15 May 2020 19:11:16 -0700 Subject: [PATCH] Add an `abs` method to `Vector2F` --- geometry/src/vector.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/geometry/src/vector.rs b/geometry/src/vector.rs index cd2c28cf..711818cd 100644 --- a/geometry/src/vector.rs +++ b/geometry/src/vector.rs @@ -131,6 +131,12 @@ impl Vector2F { 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. /// /// That is, if this vector is `v` and this function returns `c`, then `proj_v a = cv`. In