diff options
-rw-r--r-- | Spear.lkshw | 2 | ||||
-rw-r--r-- | Spear/Math/Matrix3.hs | 21 | ||||
-rw-r--r-- | Spear/Scene/Loader.hs | 2 |
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 @@ | |||
1 | Version of workspace file format: | 1 | Version of workspace file format: |
2 | 1 | 2 | 1 |
3 | Time of storage: | 3 | Time of storage: |
4 | "Sat Sep 1 16:50:37 CEST 2012" | 4 | "Sat Sep 1 18:14:28 CEST 2012" |
5 | Name of the workspace: | 5 | Name of the workspace: |
6 | "Spear" | 6 | "Spear" |
7 | File paths of contained packages: | 7 | File 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. | ||
279 | mulp :: Matrix3 -> Vector2 -> Vector2 | ||
280 | mulp 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. | ||
289 | muld :: Matrix3 -> Vector2 -> Vector2 | ||
290 | muld 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) |