#define Flt Double
#define VECT_Double
module Data.Vect.Flt.Util.Projective where
import Data.Vect.Flt.Base
import Data.Vect.Flt.Util.Dim3
import qualified Data.Vect.Flt.Util.Dim4 as Dim4
rotMatrixProj4' :: Flt -> Normal3 -> Proj4
rotMatrixProj4' angle axis = linear $ rotMatrix3' axis angle
rotMatrixProj4 :: Flt -> Vec3 -> Proj4
rotMatrixProj4 angle axis = linear $ rotMatrix3 axis angle
rotateProj4 :: Flt -> Normal3 -> Proj4 -> Proj4
rotateProj4 = rotateAfterProj4
rotateAfterProj4 :: Flt -> Normal3 -> Proj4 -> Proj4
rotateAfterProj4 angle axis m = m .*. (rotMatrixProj4' angle axis)
rotateBeforeProj4 :: Flt -> Normal3 -> Proj4 -> Proj4
rotateBeforeProj4 angle axis m = (rotMatrixProj4' angle axis) .*. m
scalingUniformProj4 :: Flt -> Proj4
scalingUniformProj4 x = scaling (Vec3 x x x)
scaleBeforeProj4 :: Vec3 -> Proj4 -> Proj4
scaleBeforeProj4 (Vec3 u v w) p4 =
toProjectiveUnsafe $
Mat4 (u*&a) (v*&b) (w*&c) t
where
Mat4 a b c t = fromProjective p4
scaleAfterProj4 :: Vec3 -> Proj4 -> Proj4
scaleAfterProj4 v p4 =
toProjectiveUnsafe $
Mat4 (a&!w) (b&!w) (c&!w) (t&!w)
where
w = extendWith 1 v
Mat4 a b c t = fromProjective p4
translate4 :: Vec3 -> Proj4 -> Proj4
translate4 = translateAfter4
translateAfter4 :: Vec3 -> Proj4 -> Proj4
translateAfter4 v p4 =
toProjectiveUnsafe $
Mat4 r1 r2 r3 (extendWith 0 v &+ r4)
where
Mat4 r1 r2 r3 r4 = fromProjective p4
translateBefore4 :: Vec3 -> Proj4 -> Proj4
translateBefore4 v p4 =
toProjectiveUnsafe $
Mat4 r1 r2 r3 (extendWith 0 u &+ r4)
where
u = v .* (trim mat :: Mat3)
mat@(Mat4 r1 r2 r3 r4) = fromProjective p4