diff options
Diffstat (limited to 'Spear/Math/MatrixUtils.hs')
| -rw-r--r-- | Spear/Math/MatrixUtils.hs | 18 |
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 @@ | |||
| 1 | module Spear.Math.MatrixUtils | ||
| 2 | ( | ||
| 3 | fastNormalMatrix | ||
| 4 | ) | ||
| 5 | where | ||
| 6 | |||
| 7 | |||
| 8 | import Spear.Math.Matrix3 as M3 | ||
| 9 | import Spear.Math.Matrix4 as M4 | ||
| 10 | |||
| 11 | |||
| 12 | fastNormalMatrix :: Matrix4 -> Matrix3 | ||
| 13 | fastNormalMatrix 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') | ||
