diff --git a/emath/src/vec2.rs b/emath/src/vec2.rs index cf926d64..55dd008f 100644 --- a/emath/src/vec2.rs +++ b/emath/src/vec2.rs @@ -133,6 +133,13 @@ impl Vec2 { Self { x: v, y: v } } + /// Treat this vector as a position. + /// `v.to_pos2()` is equivalent to `Pos2::default() + v`. + #[inline(always)] + pub fn to_pos2(self) -> crate::Pos2 { + crate::Pos2::new(self.x, self.y) + } + /// Safe normalize: returns zero if input is zero. #[must_use] #[inline(always)]