diff --git a/src/mat2.rs b/src/mat2.rs index 8d210ac..c91bc5f 100644 --- a/src/mat2.rs +++ b/src/mat2.rs @@ -70,7 +70,8 @@ pub impl Mat2 { * ~~~ */ #[inline(always)] - static pure fn from_cols(c0: Vec2, c1: Vec2) -> Mat2 { + static pure fn from_cols(c0: Vec2, + c1: Vec2) -> Mat2 { Mat2 { x: move c0, y: move c1 } } diff --git a/src/mat3.rs b/src/mat3.rs index 6501962..dd9ebd7 100644 --- a/src/mat3.rs +++ b/src/mat3.rs @@ -70,16 +70,18 @@ pub impl Mat3 { * ~~~ * c0 c1 c2 * +------+------+------+ - * r0 | c0.x | c1.y | c2.z | + * r0 | c0.x | c1.x | c2.x | * +------+------+------+ - * r1 | c0.x | c1.y | c2.z | + * r1 | c0.y | c1.y | c2.y | * +------+------+------+ - * r2 | c0.x | c1.y | c2.z | + * r2 | c0.z | c1.z | c2.z | * +------+------+------+ * ~~~ */ #[inline(always)] - static pure fn from_cols(c0: Vec3, c1: Vec3, c2: Vec3) -> Mat3 { + static pure fn from_cols(c0: Vec3, + c1: Vec3, + c2: Vec3) -> Mat3 { Mat3 { x: move c0, y: move c1, z: move c2 } @@ -307,9 +309,17 @@ pub impl Mat3: Matrix> { #[inline(always)] pure fn mul_m(&self, other: &Mat3) -> Mat3 { - Mat3::new(self.row(0).dot(&other.col(0)), self.row(1).dot(&other.col(0)), self.row(2).dot(&other.col(0)), - self.row(0).dot(&other.col(1)), self.row(1).dot(&other.col(1)), self.row(2).dot(&other.col(1)), - self.row(0).dot(&other.col(2)), self.row(1).dot(&other.col(2)), self.row(2).dot(&other.col(2))) + Mat3::new(self.row(0).dot(&other.col(0)), + self.row(1).dot(&other.col(0)), + self.row(2).dot(&other.col(0)), + + self.row(0).dot(&other.col(1)), + self.row(1).dot(&other.col(1)), + self.row(2).dot(&other.col(1)), + + self.row(0).dot(&other.col(2)), + self.row(1).dot(&other.col(2)), + self.row(2).dot(&other.col(2))) } pure fn dot(&self, other: &Mat3) -> T { diff --git a/src/mat4.rs b/src/mat4.rs index 59dc689..6833671 100644 --- a/src/mat4.rs +++ b/src/mat4.rs @@ -86,7 +86,10 @@ pub impl Mat4 { * ~~~ */ #[inline(always)] - static pure fn from_cols(c0: Vec4, c1: Vec4, c2: Vec4, c3: Vec4) -> Mat4 { + static pure fn from_cols(c0: Vec4, + c1: Vec4, + c2: Vec4, + c3: Vec4) -> Mat4 { Mat4 { x: move c0, y: move c1, z: move c2, @@ -239,13 +242,26 @@ pub impl Mat4: Matrix> { #[inline(always)] pure fn mul_m(&self, other: &Mat4) -> Mat4 { - // Surprisingly when building with optimisation turned on this is actually - // faster than writing out the matrix multiplication in expanded form. - // If you don't believe me, see ./test/performance/matrix_mul.rs - Mat4::new(self.row(0).dot(&other.col(0)), self.row(1).dot(&other.col(0)), self.row(2).dot(&other.col(0)), self.row(3).dot(&other.col(0)), - self.row(0).dot(&other.col(1)), self.row(1).dot(&other.col(1)), self.row(2).dot(&other.col(1)), self.row(3).dot(&other.col(1)), - self.row(0).dot(&other.col(2)), self.row(1).dot(&other.col(2)), self.row(2).dot(&other.col(2)), self.row(3).dot(&other.col(2)), - self.row(0).dot(&other.col(3)), self.row(1).dot(&other.col(3)), self.row(2).dot(&other.col(3)), self.row(3).dot(&other.col(3))) + Mat4::new(self.row(0).dot(&other.col(0)), + self.row(1).dot(&other.col(0)), + self.row(2).dot(&other.col(0)), + self.row(3).dot(&other.col(0)), + + self.row(0).dot(&other.col(1)), + self.row(1).dot(&other.col(1)), + self.row(2).dot(&other.col(1)), + self.row(3).dot(&other.col(1)), + + self.row(0).dot(&other.col(2)), + self.row(1).dot(&other.col(2)), + self.row(2).dot(&other.col(2)), + self.row(3).dot(&other.col(2)), + + self.row(0).dot(&other.col(3)), + self.row(1).dot(&other.col(3)), + self.row(2).dot(&other.col(3)), + self.row(3).dot(&other.col(3))) + } pure fn dot(&self, other: &Mat4) -> T { @@ -485,8 +501,7 @@ pub impl Mat4: MutableMatrix> { } } -pub impl Mat4: Matrix4> { -} +pub impl Mat4: Matrix4> {} pub impl Mat4: Neg> { #[inline(always)]