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.hs18
1 files changed, 18 insertions, 0 deletions
diff --git a/Spear/Math/MatrixUtils.hs b/Spear/Math/MatrixUtils.hs
new file mode 100644
index 0000000..88ad3b1
--- /dev/null
+++ b/Spear/Math/MatrixUtils.hs
@@ -0,0 +1,18 @@
1module Spear.Math.MatrixUtils
2(
3 fastNormalMatrix
4)
5where
6
7
8import Spear.Math.Matrix3 as M3
9import Spear.Math.Matrix4 as M4
10
11
12fastNormalMatrix :: Matrix4 -> Matrix3
13fastNormalMatrix m =
14 let m' = M4.transpose . M4.inverseTransform $ m
15 in M3.mat3
16 (M4.m00 m') (M4.m10 m') (M4.m20 m')
17 (M4.m01 m') (M4.m11 m') (M4.m21 m')
18 (M4.m02 m') (M4.m12 m') (M4.m22 m')