Skip to main content

pax_runtime_api/
math.rs

1use std::ops::Mul;
2
3use kurbo::Affine;
4
5mod point;
6mod transform;
7mod vector;
8
9pub use point::Point2;
10pub use transform::Transform2;
11pub use transform::TransformParts;
12pub use vector::Vector2;
13
14/// Marker trait for phantom coordinate spaces.
15pub trait Space: 'static {}
16
17/// Generic, untyped coordinate space.
18pub struct Generic;
19
20impl Space for Generic {}
21
22impl<W: Space> Mul<Point2<W>> for Affine {
23    type Output = Point2<W>;
24
25    #[inline]
26    fn mul(self, other: Point2<W>) -> Point2<W> {
27        let coeffs = self.as_coeffs();
28        Self::Output::new(
29            coeffs[0] * other.x + coeffs[2] * other.y + coeffs[4],
30            coeffs[1] * other.x + coeffs[3] * other.y + coeffs[5],
31        )
32    }
33}