Add Vec2::to_pos2

This commit is contained in:
Emil Ernerfeldt 2021-07-20 14:32:12 +02:00
parent a9c004d16b
commit 12334addda

View file

@ -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)]