diff options
Diffstat (limited to 'Spear/Math/MatrixUtils.hs')
-rw-r--r-- | Spear/Math/MatrixUtils.hs | 9 |
1 files changed, 0 insertions, 9 deletions
diff --git a/Spear/Math/MatrixUtils.hs b/Spear/Math/MatrixUtils.hs index 24d9778..567bee1 100644 --- a/Spear/Math/MatrixUtils.hs +++ b/Spear/Math/MatrixUtils.hs | |||
@@ -11,14 +11,12 @@ module Spear.Math.MatrixUtils | |||
11 | ) | 11 | ) |
12 | where | 12 | where |
13 | 13 | ||
14 | |||
15 | import Spear.Math.Camera as Cam | 14 | import Spear.Math.Camera as Cam |
16 | import Spear.Math.Matrix3 as M3 | 15 | import Spear.Math.Matrix3 as M3 |
17 | import Spear.Math.Matrix4 as M4 | 16 | import Spear.Math.Matrix4 as M4 |
18 | import Spear.Math.Spatial3 as S | 17 | import Spear.Math.Spatial3 as S |
19 | import Spear.Math.Vector as V | 18 | import Spear.Math.Vector as V |
20 | 19 | ||
21 | |||
22 | -- | Compute the normal matrix of the given matrix. | 20 | -- | Compute the normal matrix of the given matrix. |
23 | fastNormalMatrix :: Matrix4 -> Matrix3 | 21 | fastNormalMatrix :: Matrix4 -> Matrix3 |
24 | fastNormalMatrix m = | 22 | fastNormalMatrix m = |
@@ -28,7 +26,6 @@ fastNormalMatrix m = | |||
28 | (M4.m01 m') (M4.m11 m') (M4.m21 m') | 26 | (M4.m01 m') (M4.m11 m') (M4.m21 m') |
29 | (M4.m02 m') (M4.m12 m') (M4.m22 m') | 27 | (M4.m02 m') (M4.m12 m') (M4.m22 m') |
30 | 28 | ||
31 | |||
32 | -- | Transform the given point in window coordinates to object coordinates. | 29 | -- | Transform the given point in window coordinates to object coordinates. |
33 | unproject :: Matrix4 -- ^ Inverse projection matrix | 30 | unproject :: Matrix4 -- ^ Inverse projection matrix |
34 | -> Matrix4 -- ^ Inverse modelview matrix. | 31 | -> Matrix4 -- ^ Inverse modelview matrix. |
@@ -48,7 +45,6 @@ unproject projI modelviewI vpx vpy w h x y z = | |||
48 | in | 45 | in |
49 | (modelviewI * projI) `M4.mulp` vec3 xmouse ymouse zmouse | 46 | (modelviewI * projI) `M4.mulp` vec3 xmouse ymouse zmouse |
50 | 47 | ||
51 | |||
52 | -- | Transform the given point in window coordinates to 2d coordinates. | 48 | -- | Transform the given point in window coordinates to 2d coordinates. |
53 | -- | 49 | -- |
54 | -- The line defined by the given point in window space is intersected with | 50 | -- The line defined by the given point in window space is intersected with |
@@ -72,7 +68,6 @@ rpgUnproject projI viewI vpx vpy w h wx wy = | |||
72 | in | 68 | in |
73 | vec2 (x p') (-(z p')) | 69 | vec2 (x p') (-(z p')) |
74 | 70 | ||
75 | |||
76 | -- | Map an object's transform in view space to world space. | 71 | -- | Map an object's transform in view space to world space. |
77 | rpgTransform | 72 | rpgTransform |
78 | :: Float -- ^ The height above the ground | 73 | :: Float -- ^ The height above the ground |
@@ -97,7 +92,6 @@ rpgTransform h a axis pos viewI = | |||
97 | (z r) (z u) (z f) (z t) | 92 | (z r) (z u) (z f) (z t) |
98 | 0 0 0 1 | 93 | 0 0 0 1 |
99 | 94 | ||
100 | |||
101 | -- | Map an object's transform in view space to world space. | 95 | -- | Map an object's transform in view space to world space. |
102 | pltTransform :: Matrix3 -> Matrix4 | 96 | pltTransform :: Matrix3 -> Matrix4 |
103 | pltTransform mat = | 97 | pltTransform mat = |
@@ -111,7 +105,6 @@ pltTransform mat = | |||
111 | (z r) (z u) (z f) (z t) | 105 | (z r) (z u) (z f) (z t) |
112 | 0 0 0 1 | 106 | 0 0 0 1 |
113 | 107 | ||
114 | |||
115 | -- | Map an object's transform in world space to view space. | 108 | -- | Map an object's transform in world space to view space. |
116 | -- | 109 | -- |
117 | -- The XY plane in 2D translates to the X(-Z) plane in 3D. | 110 | -- The XY plane in 2D translates to the X(-Z) plane in 3D. |
@@ -127,7 +120,6 @@ rpgInverse | |||
127 | rpgInverse h a axis pos viewI = | 120 | rpgInverse h a axis pos viewI = |
128 | M4.inverseTransform $ rpgTransform h a axis pos viewI | 121 | M4.inverseTransform $ rpgTransform h a axis pos viewI |
129 | 122 | ||
130 | |||
131 | -- | Map an object's transform in world space to view space. | 123 | -- | Map an object's transform in world space to view space. |
132 | -- | 124 | -- |
133 | -- This function maps an object's transform in 2D to the object's inverse in 3D. | 125 | -- This function maps an object's transform in 2D to the object's inverse in 3D. |
@@ -138,7 +130,6 @@ rpgInverse h a axis pos viewI = | |||
138 | pltInverse :: Matrix3 -> Matrix4 | 130 | pltInverse :: Matrix3 -> Matrix4 |
139 | pltInverse = M4.inverseTransform . pltTransform | 131 | pltInverse = M4.inverseTransform . pltTransform |
140 | 132 | ||
141 | |||
142 | -- | Transform an object from object to clip space coordinates. | 133 | -- | Transform an object from object to clip space coordinates. |
143 | objToClip :: Camera -> Matrix4 -> Vector3 -> Vector2 | 134 | objToClip :: Camera -> Matrix4 -> Vector3 -> Vector2 |
144 | objToClip cam model p = | 135 | objToClip cam model p = |