aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeanne-Kamikaze <jeannekamikaze@gmail.com>2013-03-12 20:03:36 +0100
committerJeanne-Kamikaze <jeannekamikaze@gmail.com>2013-03-12 20:03:36 +0100
commit4eba446239e17bab42ecf7c9d09844b563fc6417 (patch)
tree924118c9a24be4c85f42977a11a3a5725008b7ef
parent591e64b7d8c6e858a038a8bc37121dea00c6164e (diff)
Fixed whitespace
-rw-r--r--Spear/Math/Matrix4.hs56
1 files changed, 28 insertions, 28 deletions
diff --git a/Spear/Math/Matrix4.hs b/Spear/Math/Matrix4.hs
index 1424b28..e1b1d04 100644
--- a/Spear/Math/Matrix4.hs
+++ b/Spear/Math/Matrix4.hs
@@ -66,7 +66,7 @@ data Matrix4 = Matrix4
66 66
67 67
68instance Show Matrix4 where 68instance Show Matrix4 where
69 69
70 show (Matrix4 m00 m10 m20 m30 m01 m11 m21 m31 m02 m12 m22 m32 m03 m13 m23 m33) = 70 show (Matrix4 m00 m10 m20 m30 m01 m11 m21 m31 m02 m12 m22 m32 m03 m13 m23 m33) =
71 show' m00 ++ ", " ++ show' m10 ++ ", " ++ show' m20 ++ ", " ++ show' m30 ++ "\n" ++ 71 show' m00 ++ ", " ++ show' m10 ++ ", " ++ show' m20 ++ ", " ++ show' m30 ++ "\n" ++
72 show' m01 ++ ", " ++ show' m11 ++ ", " ++ show' m21 ++ ", " ++ show' m31 ++ "\n" ++ 72 show' m01 ++ ", " ++ show' m11 ++ ", " ++ show' m21 ++ ", " ++ show' m31 ++ "\n" ++
@@ -83,58 +83,58 @@ instance Num Matrix4 where
83 (a04 + b04) (a05 + b05) (a06 + b06) (a07 + b07) 83 (a04 + b04) (a05 + b05) (a06 + b06) (a07 + b07)
84 (a08 + b08) (a09 + b09) (a10 + b10) (a11 + b11) 84 (a08 + b08) (a09 + b09) (a10 + b10) (a11 + b11)
85 (a12 + b12) (a13 + b13) (a14 + b14) (a15 + b15) 85 (a12 + b12) (a13 + b13) (a14 + b14) (a15 + b15)
86 86
87 (Matrix4 a00 a01 a02 a03 a04 a05 a06 a07 a08 a09 a10 a11 a12 a13 a14 a15) 87 (Matrix4 a00 a01 a02 a03 a04 a05 a06 a07 a08 a09 a10 a11 a12 a13 a14 a15)
88 - (Matrix4 b00 b01 b02 b03 b04 b05 b06 b07 b08 b09 b10 b11 b12 b13 b14 b15) 88 - (Matrix4 b00 b01 b02 b03 b04 b05 b06 b07 b08 b09 b10 b11 b12 b13 b14 b15)
89 = Matrix4 (a00 - b00) (a01 - b01) (a02 - b02) (a03 - b03) 89 = Matrix4 (a00 - b00) (a01 - b01) (a02 - b02) (a03 - b03)
90 (a04 - b04) (a05 - b05) (a06 - b06) (a07 - b07) 90 (a04 - b04) (a05 - b05) (a06 - b06) (a07 - b07)
91 (a08 - b08) (a09 - b09) (a10 - b10) (a11 - b11) 91 (a08 - b08) (a09 - b09) (a10 - b10) (a11 - b11)
92 (a12 - b12) (a13 - b13) (a14 - b14) (a15 - b15) 92 (a12 - b12) (a13 - b13) (a14 - b14) (a15 - b15)
93 93
94 (Matrix4 a00 a10 a20 a30 a01 a11 a21 a31 a02 a12 a22 a32 a03 a13 a23 a33) 94 (Matrix4 a00 a10 a20 a30 a01 a11 a21 a31 a02 a12 a22 a32 a03 a13 a23 a33)
95 * (Matrix4 b00 b10 b20 b30 b01 b11 b21 b31 b02 b12 b22 b32 b03 b13 b23 b33) 95 * (Matrix4 b00 b10 b20 b30 b01 b11 b21 b31 b02 b12 b22 b32 b03 b13 b23 b33)
96 = Matrix4 (a00 * b00 + a10 * b01 + a20 * b02 + a30 * b03) 96 = Matrix4 (a00 * b00 + a10 * b01 + a20 * b02 + a30 * b03)
97 (a00 * b10 + a10 * b11 + a20 * b12 + a30 * b13) 97 (a00 * b10 + a10 * b11 + a20 * b12 + a30 * b13)
98 (a00 * b20 + a10 * b21 + a20 * b22 + a30 * b23) 98 (a00 * b20 + a10 * b21 + a20 * b22 + a30 * b23)
99 (a00 * b30 + a10 * b31 + a20 * b32 + a30 * b33) 99 (a00 * b30 + a10 * b31 + a20 * b32 + a30 * b33)
100 100
101 (a01 * b00 + a11 * b01 + a21 * b02 + a31 * b03) 101 (a01 * b00 + a11 * b01 + a21 * b02 + a31 * b03)
102 (a01 * b10 + a11 * b11 + a21 * b12 + a31 * b13) 102 (a01 * b10 + a11 * b11 + a21 * b12 + a31 * b13)
103 (a01 * b20 + a11 * b21 + a21 * b22 + a31 * b23) 103 (a01 * b20 + a11 * b21 + a21 * b22 + a31 * b23)
104 (a01 * b30 + a11 * b31 + a21 * b32 + a31 * b33) 104 (a01 * b30 + a11 * b31 + a21 * b32 + a31 * b33)
105 105
106 (a02 * b00 + a12 * b01 + a22 * b02 + a32 * b03) 106 (a02 * b00 + a12 * b01 + a22 * b02 + a32 * b03)
107 (a02 * b10 + a12 * b11 + a22 * b12 + a32 * b13) 107 (a02 * b10 + a12 * b11 + a22 * b12 + a32 * b13)
108 (a02 * b20 + a12 * b21 + a22 * b22 + a32 * b23) 108 (a02 * b20 + a12 * b21 + a22 * b22 + a32 * b23)
109 (a02 * b30 + a12 * b31 + a22 * b32 + a32 * b33) 109 (a02 * b30 + a12 * b31 + a22 * b32 + a32 * b33)
110 110
111 (a03 * b00 + a13 * b01 + a23 * b02 + a33 * b03) 111 (a03 * b00 + a13 * b01 + a23 * b02 + a33 * b03)
112 (a03 * b10 + a13 * b11 + a23 * b12 + a33 * b13) 112 (a03 * b10 + a13 * b11 + a23 * b12 + a33 * b13)
113 (a03 * b20 + a13 * b21 + a23 * b22 + a33 * b23) 113 (a03 * b20 + a13 * b21 + a23 * b22 + a33 * b23)
114 (a03 * b30 + a13 * b31 + a23 * b32 + a33 * b33) 114 (a03 * b30 + a13 * b31 + a23 * b32 + a33 * b33)
115 115
116 abs = Spear.Math.Matrix4.map abs 116 abs = Spear.Math.Matrix4.map abs
117 117
118 signum = Spear.Math.Matrix4.map signum 118 signum = Spear.Math.Matrix4.map signum
119 119
120 fromInteger i = mat4 i' i' i' i' i' i' i' i' i' i' i' i' i' i' i' i' where i' = fromInteger i 120 fromInteger i = mat4 i' i' i' i' i' i' i' i' i' i' i' i' i' i' i' i' where i' = fromInteger i
121 121
122 122
123instance Storable Matrix4 where 123instance Storable Matrix4 where
124 sizeOf _ = 64 124 sizeOf _ = 64
125 alignment _ = 4 125 alignment _ = 4
126 126
127 peek ptr = do 127 peek ptr = do
128 a00 <- peekByteOff ptr 0; a01 <- peekByteOff ptr 4; a02 <- peekByteOff ptr 8; a03 <- peekByteOff ptr 12; 128 a00 <- peekByteOff ptr 0; a01 <- peekByteOff ptr 4; a02 <- peekByteOff ptr 8; a03 <- peekByteOff ptr 12;
129 a10 <- peekByteOff ptr 16; a11 <- peekByteOff ptr 20; a12 <- peekByteOff ptr 24; a13 <- peekByteOff ptr 28; 129 a10 <- peekByteOff ptr 16; a11 <- peekByteOff ptr 20; a12 <- peekByteOff ptr 24; a13 <- peekByteOff ptr 28;
130 a20 <- peekByteOff ptr 32; a21 <- peekByteOff ptr 36; a22 <- peekByteOff ptr 40; a23 <- peekByteOff ptr 44; 130 a20 <- peekByteOff ptr 32; a21 <- peekByteOff ptr 36; a22 <- peekByteOff ptr 40; a23 <- peekByteOff ptr 44;
131 a30 <- peekByteOff ptr 48; a31 <- peekByteOff ptr 52; a32 <- peekByteOff ptr 56; a33 <- peekByteOff ptr 60; 131 a30 <- peekByteOff ptr 48; a31 <- peekByteOff ptr 52; a32 <- peekByteOff ptr 56; a33 <- peekByteOff ptr 60;
132 132
133 return $ Matrix4 a00 a10 a20 a30 133 return $ Matrix4 a00 a10 a20 a30
134 a01 a11 a21 a31 134 a01 a11 a21 a31
135 a02 a12 a22 a32 135 a02 a12 a22 a32
136 a03 a13 a23 a33 136 a03 a13 a23 a33
137 137
138 poke ptr (Matrix4 a00 a10 a20 a30 138 poke ptr (Matrix4 a00 a10 a20 a30
139 a01 a11 a21 a31 139 a01 a11 a21 a31
140 a02 a12 a22 a32 140 a02 a12 a22 a32
@@ -187,7 +187,7 @@ transform right up fwd pos = mat4
187 (x right) (x up) (x fwd) (x pos) 187 (x right) (x up) (x fwd) (x pos)
188 (y right) (y up) (y fwd) (y pos) 188 (y right) (y up) (y fwd) (y pos)
189 (z right) (z up) (z fwd) (z pos) 189 (z right) (z up) (z fwd) (z pos)
190 0 0 0 1 190 0 0 0 1
191 191
192 192
193-- | Get the translation part of the given transformation matrix. 193-- | Get the translation part of the given transformation matrix.
@@ -201,7 +201,7 @@ translation (Matrix4
201 1 0 0 a30 201 1 0 0 a30
202 0 1 0 a31 202 0 1 0 a31
203 0 0 1 a32 203 0 0 1 a32
204 0 0 0 a33 204 0 0 0 a33
205 205
206 206
207-- | Get the rotation part of the given transformation matrix. 207-- | Get the rotation part of the given transformation matrix.
@@ -215,7 +215,7 @@ rotation (Matrix4
215 a00 a10 a20 0 215 a00 a10 a20 0
216 a01 a11 a21 0 216 a01 a11 a21 0
217 a02 a12 a22 0 217 a02 a12 a22 0
218 a03 a13 a23 1 218 a03 a13 a23 1
219 219
220 220
221-- | Build a transformation 'Matrix4' defined by the given position and target. 221-- | Build a transformation 'Matrix4' defined by the given position and target.
@@ -345,8 +345,8 @@ scale sx sy sz = mat4
345 0 sy 0 0 345 0 sy 0 0
346 0 0 sz 0 346 0 0 sz 0
347 0 0 0 1 347 0 0 0 1
348 348
349 349
350-- | Create a scale matrix. 350-- | Create a scale matrix.
351scalev :: Vector3 -> Matrix4 351scalev :: Vector3 -> Matrix4
352scalev v = mat4 352scalev v = mat4
@@ -437,10 +437,10 @@ planeProj n d l =
437 ly = y l 437 ly = y l
438 lz = z l 438 lz = z l
439 in mat4 439 in mat4
440 (d + c - nx*lx) (-ny*lx) (-nz*lx) (-lx*d) 440 (d + c - nx*lx) (-ny*lx) (-nz*lx) (-lx*d)
441 (-nx*ly) (d + c - ny*ly) (-nz*ly) (-ly*d) 441 (-nx*ly) (d + c - ny*ly) (-nz*ly) (-ly*d)
442 (-nx*lz) (-ny*lz) (d + c - nz*lz) (-lz*d) 442 (-nx*lz) (-ny*lz) (d + c - nz*lz) (-lz*d)
443 (-nx) (-ny) (-nz) c 443 (-nx) (-ny) (-nz) c
444 444
445 445
446-- | Transpose the specified matrix. 446-- | Transpose the specified matrix.
@@ -470,7 +470,7 @@ inverseTransform mat =
470 470
471-- | Invert the given matrix. 471-- | Invert the given matrix.
472inverse :: Matrix4 -> Matrix4 472inverse :: Matrix4 -> Matrix4
473inverse mat = 473inverse mat =
474 let 474 let
475 a00 = m00 mat 475 a00 = m00 mat
476 a01 = m01 mat 476 a01 = m01 mat
@@ -488,14 +488,14 @@ inverse mat =
488 a13 = m31 mat 488 a13 = m31 mat
489 a14 = m32 mat 489 a14 = m32 mat
490 a15 = m33 mat 490 a15 = m33 mat
491 491
492 m00' = a05 * a10 * a15 492 m00' = a05 * a10 * a15
493 - a05 * a11 * a14 493 - a05 * a11 * a14
494 - a09 * a06 * a15 494 - a09 * a06 * a15
495 + a09 * a07 * a14 495 + a09 * a07 * a14
496 + a13 * a06 * a11 496 + a13 * a06 * a11
497 - a13 * a07 * a10 497 - a13 * a07 * a10
498 498
499 m04' = -a04 * a10 * a15 499 m04' = -a04 * a10 * a15
500 + a04 * a11 * a14 500 + a04 * a11 * a14
501 + a08 * a06 * a15 501 + a08 * a06 * a15
@@ -530,7 +530,7 @@ inverse mat =
530 + a08 * a03 * a14 530 + a08 * a03 * a14
531 + a12 * a02 * a11 531 + a12 * a02 * a11
532 - a12 * a03 * a10 532 - a12 * a03 * a10
533 533
534 m09' = -a00 * a09 * a15 534 m09' = -a00 * a09 * a15
535 + a00 * a11 * a13 535 + a00 * a11 * a13
536 + a08 * a01 * a15 536 + a08 * a01 * a15
@@ -600,7 +600,7 @@ inverse mat =
600 + a04 * a02 * a09 600 + a04 * a02 * a09
601 + a08 * a01 * a06 601 + a08 * a01 * a06
602 - a08 * a02 * a05 602 - a08 * a02 * a05
603 603
604 det' = a00 * m00' + a01 * m04' + a02 * m08' + a03 * m12' 604 det' = a00 * m00' + a01 * m04' + a02 * m08' + a03 * m12'
605 in 605 in
606 if det' == 0 then Spear.Math.Matrix4.id 606 if det' == 0 then Spear.Math.Matrix4.id