aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Sunet <jeannekamikaze@gmail.com>2012-09-01 18:18:19 +0200
committerMarc Sunet <jeannekamikaze@gmail.com>2012-09-01 18:18:19 +0200
commit74f1b41d45994eadb90b0f227b3a5682f43cb8c8 (patch)
treeb72f41e6300bdec25b07f4898122be09c21e568f
parent894ada84c5bec9181026817be25eb383b352924f (diff)
Added mulp and muld to Matrix3
-rw-r--r--Spear.lkshw2
-rw-r--r--Spear/Math/Matrix3.hs21
-rw-r--r--Spear/Scene/Loader.hs2
3 files changed, 23 insertions, 2 deletions
diff --git a/Spear.lkshw b/Spear.lkshw
index 91f4459..ec17604 100644
--- a/Spear.lkshw
+++ b/Spear.lkshw
@@ -1,7 +1,7 @@
1Version of workspace file format: 1Version of workspace file format:
2 1 2 1
3Time of storage: 3Time of storage:
4 "Sat Sep 1 16:50:37 CEST 2012" 4 "Sat Sep 1 18:14:28 CEST 2012"
5Name of the workspace: 5Name of the workspace:
6 "Spear" 6 "Spear"
7File paths of contained packages: 7File paths of contained packages:
diff --git a/Spear/Math/Matrix3.hs b/Spear/Math/Matrix3.hs
index b295cbd..adc4449 100644
--- a/Spear/Math/Matrix3.hs
+++ b/Spear/Math/Matrix3.hs
@@ -30,6 +30,8 @@ module Spear.Math.Matrix3
30, reflectZ 30, reflectZ
31 -- * Operations 31 -- * Operations
32, transpose 32, transpose
33, mulp
34, muld
33, mul 35, mul
34, inverseTransform 36, inverseTransform
35, Spear.Math.Matrix3.zipWith 37, Spear.Math.Matrix3.zipWith
@@ -271,6 +273,25 @@ transpose m = mat3
271 (m00 m) (m01 m) (m02 m) 273 (m00 m) (m01 m) (m02 m)
272 (m10 m) (m11 m) (m12 m) 274 (m10 m) (m11 m) (m12 m)
273 (m20 m) (m21 m) (m22 m) 275 (m20 m) (m21 m) (m22 m)
276
277
278-- | Transform the given point vector in 2D space with the given matrix.
279mulp :: Matrix3 -> Vector2 -> Vector2
280mulp m v = vec2 x' y'
281 where
282 v' = vec3 (V2.x v) (V2.y v) 1
283 x' = row0 m `V3.dot` v'
284 y' = row1 m `V3.dot` v'
285
286
287
288-- | Transform the given directional vector in 2D space with the given matrix.
289muld :: Matrix3 -> Vector2 -> Vector2
290muld m v = vec2 x' y'
291 where
292 v' = vec3 (V2.x v) (V2.y v) 0
293 x' = row0 m `V3.dot` v'
294 y' = row1 m `V3.dot` v'
274 295
275 296
276-- | Transform the given vector in 3D space with the given matrix. 297-- | Transform the given vector in 3D space with the given matrix.
diff --git a/Spear/Scene/Loader.hs b/Spear/Scene/Loader.hs
index f5d06a6..3bc29fa 100644
--- a/Spear/Scene/Loader.hs
+++ b/Spear/Scene/Loader.hs
@@ -221,7 +221,7 @@ rotateModel (Rotation x y z order) model =
221 normalMat = fastNormalMatrix mat 221 normalMat = fastNormalMatrix mat
222 222
223 vTransform (Vec3 x' y' z') = 223 vTransform (Vec3 x' y' z') =
224 let v = mat `mulp` (vec3 x' y' z') in Vec3 (V3.x v) (V3.y v) (V3.z v) 224 let v = mat `M4.mulp` (vec3 x' y' z') in Vec3 (V3.x v) (V3.y v) (V3.z v)
225 225
226 nTransform (Vec3 x' y' z') = 226 nTransform (Vec3 x' y' z') =
227 let v = normalMat `M3.mul` (vec3 x' y' z') in Vec3 (V3.x v) (V3.y v) (V3.z v) 227 let v = normalMat `M3.mul` (vec3 x' y' z') in Vec3 (V3.x v) (V3.y v) (V3.z v)