aboutsummaryrefslogtreecommitdiff
path: root/Spear/Math/MatrixUtils.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Spear/Math/MatrixUtils.hs')
-rw-r--r--Spear/Math/MatrixUtils.hs9
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)
12where 12where
13 13
14
15import Spear.Math.Camera as Cam 14import Spear.Math.Camera as Cam
16import Spear.Math.Matrix3 as M3 15import Spear.Math.Matrix3 as M3
17import Spear.Math.Matrix4 as M4 16import Spear.Math.Matrix4 as M4
18import Spear.Math.Spatial3 as S 17import Spear.Math.Spatial3 as S
19import Spear.Math.Vector as V 18import 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.
23fastNormalMatrix :: Matrix4 -> Matrix3 21fastNormalMatrix :: Matrix4 -> Matrix3
24fastNormalMatrix m = 22fastNormalMatrix 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.
33unproject :: Matrix4 -- ^ Inverse projection matrix 30unproject :: 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.
77rpgTransform 72rpgTransform
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.
102pltTransform :: Matrix3 -> Matrix4 96pltTransform :: Matrix3 -> Matrix4
103pltTransform mat = 97pltTransform 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
127rpgInverse h a axis pos viewI = 120rpgInverse 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 =
138pltInverse :: Matrix3 -> Matrix4 130pltInverse :: Matrix3 -> Matrix4
139pltInverse = M4.inverseTransform . pltTransform 131pltInverse = 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.
143objToClip :: Camera -> Matrix4 -> Vector3 -> Vector2 134objToClip :: Camera -> Matrix4 -> Vector3 -> Vector2
144objToClip cam model p = 135objToClip cam model p =