From 0862712595cef8455783f0aba8396d652e138f27 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 25 Apr 2022 11:26:54 +0200 Subject: [PATCH] Add Vec2::dot --- emath/src/vec2.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/emath/src/vec2.rs b/emath/src/vec2.rs index df7265f3..d2f08b05 100644 --- a/emath/src/vec2.rs +++ b/emath/src/vec2.rs @@ -253,6 +253,12 @@ impl Vec2 { vec2(self.x.max(other.x), self.y.max(other.y)) } + /// The dot-product of two vectors. + #[inline] + pub fn dot(self, other: Self) -> f32 { + self.x * other.x + self.y * other.y + } + /// Returns the minimum of `self.x` and `self.y`. #[must_use] #[inline(always)]