Skip to content

Commit b071c05

Browse files
committed
matrix multiplication and transforms
1 parent 695c301 commit b071c05

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

graphene/src/matrix.rs

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::fmt;
44

55
use glib::translate::*;
66

7-
use crate::{ffi, Matrix, Point3D, Vec3, Vec4};
7+
use crate::{ffi, Matrix, Point, Point3D, Vec3, Vec4};
88

99
impl Matrix {
1010
#[doc(alias = "graphene_matrix_init_from_2d")]
@@ -236,3 +236,45 @@ mod tests {
236236
);
237237
}
238238
}
239+
240+
impl std::ops::Mul<Matrix> for Matrix {
241+
type Output = Matrix;
242+
243+
fn mul(self, rhs: Matrix) -> Self::Output {
244+
(&self).multiply(&rhs)
245+
}
246+
}
247+
248+
impl std::ops::Mul<Vec4> for Matrix {
249+
type Output = Vec4;
250+
251+
fn mul(self, rhs: Vec4) -> Self::Output {
252+
(&self).transform_vec4(&rhs)
253+
}
254+
}
255+
256+
impl std::ops::Mul<Vec3> for Matrix {
257+
type Output = Vec3;
258+
259+
fn mul(self, rhs: Vec3) -> Self::Output {
260+
(&self).transform_vec3(&rhs)
261+
}
262+
}
263+
264+
impl std::ops::Mul<Point> for Matrix {
265+
type Output = Point;
266+
267+
fn mul(self, rhs: Point) -> Self::Output {
268+
(&self).transform_point(&rhs)
269+
}
270+
}
271+
272+
273+
impl std::ops::Mul<Point3D> for Matrix {
274+
type Output = Point3D;
275+
276+
fn mul(self, rhs: Point3D) -> Self::Output {
277+
(&self).transform_point3d(&rhs)
278+
}
279+
}
280+

0 commit comments

Comments
 (0)