Long lines
This commit is contained in:
parent
645981efbf
commit
e939b5eb95
3 changed files with 44 additions and 18 deletions
|
@ -70,7 +70,8 @@ pub impl<T:Copy Float> Mat2<T> {
|
|||
* ~~~
|
||||
*/
|
||||
#[inline(always)]
|
||||
static pure fn from_cols(c0: Vec2<T>, c1: Vec2<T>) -> Mat2<T> {
|
||||
static pure fn from_cols(c0: Vec2<T>,
|
||||
c1: Vec2<T>) -> Mat2<T> {
|
||||
Mat2 { x: move c0,
|
||||
y: move c1 }
|
||||
}
|
||||
|
|
24
src/mat3.rs
24
src/mat3.rs
|
@ -70,16 +70,18 @@ pub impl<T:Copy Float> Mat3<T> {
|
|||
* ~~~
|
||||
* 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<T>, c1: Vec3<T>, c2: Vec3<T>) -> Mat3<T> {
|
||||
static pure fn from_cols(c0: Vec3<T>,
|
||||
c1: Vec3<T>,
|
||||
c2: Vec3<T>) -> Mat3<T> {
|
||||
Mat3 { x: move c0,
|
||||
y: move c1,
|
||||
z: move c2 }
|
||||
|
@ -307,9 +309,17 @@ pub impl<T:Copy Float> Mat3<T>: Matrix<T, Vec3<T>> {
|
|||
|
||||
#[inline(always)]
|
||||
pure fn mul_m(&self, other: &Mat3<T>) -> Mat3<T> {
|
||||
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>) -> T {
|
||||
|
|
35
src/mat4.rs
35
src/mat4.rs
|
@ -86,7 +86,10 @@ pub impl<T:Copy Float> Mat4<T> {
|
|||
* ~~~
|
||||
*/
|
||||
#[inline(always)]
|
||||
static pure fn from_cols(c0: Vec4<T>, c1: Vec4<T>, c2: Vec4<T>, c3: Vec4<T>) -> Mat4<T> {
|
||||
static pure fn from_cols(c0: Vec4<T>,
|
||||
c1: Vec4<T>,
|
||||
c2: Vec4<T>,
|
||||
c3: Vec4<T>) -> Mat4<T> {
|
||||
Mat4 { x: move c0,
|
||||
y: move c1,
|
||||
z: move c2,
|
||||
|
@ -239,13 +242,26 @@ pub impl<T:Copy Float Sign> Mat4<T>: Matrix<T, Vec4<T>> {
|
|||
|
||||
#[inline(always)]
|
||||
pure fn mul_m(&self, other: &Mat4<T>) -> Mat4<T> {
|
||||
// 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>) -> T {
|
||||
|
@ -485,8 +501,7 @@ pub impl<T:Copy Float Sign> Mat4<T>: MutableMatrix<T, Vec4<T>> {
|
|||
}
|
||||
}
|
||||
|
||||
pub impl<T> Mat4<T>: Matrix4<T, Vec4<T>> {
|
||||
}
|
||||
pub impl<T> Mat4<T>: Matrix4<T, Vec4<T>> {}
|
||||
|
||||
pub impl<T:Copy Float> Mat4<T>: Neg<Mat4<T>> {
|
||||
#[inline(always)]
|
||||
|
|
Loading…
Reference in a new issue