diff options
Diffstat (limited to 'evc/src/helpers')
-rw-r--r-- | evc/src/helpers/matrix.rs | 4 | ||||
-rw-r--r-- | evc/src/helpers/vector.rs | 10 |
2 files changed, 11 insertions, 3 deletions
diff --git a/evc/src/helpers/matrix.rs b/evc/src/helpers/matrix.rs index c3c120b..0007440 100644 --- a/evc/src/helpers/matrix.rs +++ b/evc/src/helpers/matrix.rs @@ -12,8 +12,8 @@ impl<T: std::ops::Mul<Output = T> + std::ops::Add<Output = T> + Copy> Mat2<T> { #[inline] pub fn transform(&self, v: Vec2<T>) -> Vec2<T> { Vec2 { - x: self.a * v.x + self.b * v.x, - y: self.c * v.y + self.d * v.y, + x: self.a * v.x + self.b * v.y, + y: self.c * v.x + self.d * v.y, } } } diff --git a/evc/src/helpers/vector.rs b/evc/src/helpers/vector.rs index 0209c58..a4766d1 100644 --- a/evc/src/helpers/vector.rs +++ b/evc/src/helpers/vector.rs @@ -20,6 +20,14 @@ impl From<Vec2<u16>> for Vec2<isize> { } } } +impl From<Vec2<f32>> for Vec2<isize> { + fn from(value: Vec2<f32>) -> Self { + Self { + x: value.x as isize, + y: value.y as isize, + } + } +} impl Vec2<isize> { pub const ZERO: Vec2<isize> = Vec2 { x: 0, y: 0 }; @@ -58,7 +66,7 @@ impl Vec2<isize> { Self { x: self.x, y: 0 } } pub fn y_only(&self) -> Self { - Self { x: self.x, y: 0 } + Self { x: 0, y: self.y } } } |