From 48f321a80970ebeb8374072b1d2e0a4d297aa348 Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Sun, 20 Dec 2020 03:58:46 +0100 Subject: Add dimensional indicator with scaling --- src/math/vec2.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/math/vec2.rs') 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 { @@ -45,6 +46,18 @@ impl Vec2 { } } +impl Into> for Vec2 { + fn into(self) -> Point2 { + Point2::new(self.x, self.y) + } +} + +impl From> for Vec2 { + fn from(v: Point2) -> Self { + Self::new(v.x, v.y) + } +} + // This is sad, but also sadly necessary :/ impl From for Vec2 where -- cgit v1.2.3-70-g09d2