Add Vec2::to_pos2
This commit is contained in:
parent
a9c004d16b
commit
12334addda
1 changed files with 7 additions and 0 deletions
|
@ -133,6 +133,13 @@ impl Vec2 {
|
||||||
Self { x: v, y: v }
|
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.
|
/// Safe normalize: returns zero if input is zero.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
|
Loading…
Reference in a new issue