aboutsummaryrefslogtreecommitdiff
path: root/src/math/vec2.rs
diff options
context:
space:
mode:
authorArne Dußin2020-12-20 03:58:46 +0100
committerArne Dußin2020-12-20 16:41:52 +0100
commit48f321a80970ebeb8374072b1d2e0a4d297aa348 (patch)
tree8f6dbffef7ed507ae118919917fd69a7a9528c39 /src/math/vec2.rs
parentc073618d9773216ab4a2dcd7944589f38b1df751 (diff)
downloadgraf_karto-48f321a80970ebeb8374072b1d2e0a4d297aa348.tar.gz
graf_karto-48f321a80970ebeb8374072b1d2e0a4d297aa348.zip
Add dimensional indicator with scaling
Diffstat (limited to 'src/math/vec2.rs')
-rw-r--r--src/math/vec2.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/math/vec2.rs b/src/math/vec2.rs
index d591f1d..b9e3215 100644
--- a/src/math/vec2.rs
+++ b/src/math/vec2.rs
@@ -7,6 +7,7 @@ use std::cmp::Ordering;
use std::convert::{From, Into};
use std::ops::{Add, AddAssign, Div, Mul, MulAssign, Neg, Sub, SubAssign};
use std::{fmt, mem};
+use nalgebra::Point2;
#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize, Eq, Hash)]
pub struct Vec2<T: Scalar + Copy> {
@@ -45,6 +46,18 @@ impl<T: Scalar + Copy> Vec2<T> {
}
}
+impl<T: Scalar + Copy> Into<Point2<T>> for Vec2<T> {
+ fn into(self) -> Point2<T> {
+ Point2::new(self.x, self.y)
+ }
+}
+
+impl<T: Scalar + Copy> From<Point2<T>> for Vec2<T> {
+ fn from(v: Point2<T>) -> Self {
+ Self::new(v.x, v.y)
+ }
+}
+
// This is sad, but also sadly necessary :/
impl<T> From<raylib::ffi::Vector2> for Vec2<T>
where