module Data.Vector.Transform.T2 where
import Data.Monoid
import Data.Vector.Class
import Data.Vector.V2
data Transform2 =
Transform2
{
t2_XX, t2_YX, t2_1X,
t2_XY, t2_YY, t2_1Y :: !Scalar
}
deriving (Eq, Show)
instance Monoid Transform2 where
mempty = Transform2 1 0 0 0 1 0
mappend a b =
Transform2
{
t2_XX = t2_XX a * t2_XX b + t2_XY a * t2_YX b,
t2_YX = t2_YX a * t2_XX b + t2_YY a * t2_YX b,
t2_1X = t2_1X a * t2_XX b + t2_1Y a * t2_YX b + t2_1X b,
t2_XY = t2_XX a * t2_XY b + t2_XY a * t2_YY b,
t2_YY = t2_YX a * t2_XY b + t2_YY a * t2_YY b,
t2_1Y = t2_1X a * t2_XY b + t2_1Y a * t2_YY b + t2_1Y b
}
transformP2 :: Transform2 -> Vector2 -> Vector2
transformP2 a (Vector2 x y) =
Vector2
{
v2x = t2_XX a * x + t2_YX a * y + t2_1X a,
v2y = t2_XY a * x + t2_YY a * y + t2_1Y a
}