{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module Diagrams.Transform
(
Transformation, inv, transl, apply, papply
, Transformable(..)
, translation, translate, moveTo, place, scaling, scale
, conjugate, underT, transformed, translated, movedTo, movedFrom
, HasOrigin(..), moveOriginBy
) where
import Control.Lens hiding (transform)
import Data.Semigroup
import Diagrams.Core
import Linear.Vector
conjugate :: (Additive v, Num n)
=> Transformation v n -> Transformation v n -> Transformation v n
conjugate :: forall (v :: * -> *) n.
(Additive v, Num n) =>
Transformation v n -> Transformation v n -> Transformation v n
conjugate Transformation v n
t1 Transformation v n
t2 = forall (v :: * -> *) n.
(Functor v, Num n) =>
Transformation v n -> Transformation v n
inv Transformation v n
t1 forall a. Semigroup a => a -> a -> a
<> Transformation v n
t2 forall a. Semigroup a => a -> a -> a
<> Transformation v n
t1
underT :: (InSpace v n a, SameSpace a b, Transformable a, Transformable b)
=> (a -> b) -> Transformation v n -> a -> b
a -> b
f underT :: forall (v :: * -> *) n a b.
(InSpace v n a, SameSpace a b, Transformable a, Transformable b) =>
(a -> b) -> Transformation v n -> a -> b
`underT` Transformation v n
t = forall t. Transformable t => Transformation (V t) (N t) -> t -> t
transform (forall (v :: * -> *) n.
(Functor v, Num n) =>
Transformation v n -> Transformation v n
inv Transformation v n
t) forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> b
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall t. Transformable t => Transformation (V t) (N t) -> t -> t
transform Transformation v n
t
transformed :: (InSpace v n a, SameSpace a b, Transformable a, Transformable b)
=> Transformation v n -> Iso a b a b
transformed :: forall (v :: * -> *) n a b.
(InSpace v n a, SameSpace a b, Transformable a, Transformable b) =>
Transformation v n -> Iso a b a b
transformed Transformation v n
t = forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso (forall t. Transformable t => Transformation (V t) (N t) -> t -> t
transform forall a b. (a -> b) -> a -> b
$ forall (v :: * -> *) n.
(Functor v, Num n) =>
Transformation v n -> Transformation v n
inv Transformation v n
t) (forall t. Transformable t => Transformation (V t) (N t) -> t -> t
transform Transformation v n
t)
movedTo :: (InSpace v n a, SameSpace a b, HasOrigin a, HasOrigin b)
=> Point v n -> Iso a b a b
movedTo :: forall (v :: * -> *) n a b.
(InSpace v n a, SameSpace a b, HasOrigin a, HasOrigin b) =>
Point v n -> Iso a b a b
movedTo Point v n
p = forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso (forall (v :: * -> *) n t.
(InSpace v n t, HasOrigin t) =>
Point v n -> t -> t
moveTo (forall (f :: * -> *) a. (Functor f, Num a) => f a -> f a
negated Point v n
p)) (forall (v :: * -> *) n t.
(InSpace v n t, HasOrigin t) =>
Point v n -> t -> t
moveTo Point v n
p)
movedFrom :: (InSpace v n a, SameSpace a b, HasOrigin a, HasOrigin b)
=> Point v n -> Iso a b a b
movedFrom :: forall (v :: * -> *) n a b.
(InSpace v n a, SameSpace a b, HasOrigin a, HasOrigin b) =>
Point v n -> Iso a b a b
movedFrom Point v n
p = forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso (forall t. HasOrigin t => Point (V t) (N t) -> t -> t
moveOriginTo (forall (f :: * -> *) a. (Functor f, Num a) => f a -> f a
negated Point v n
p)) (forall t. HasOrigin t => Point (V t) (N t) -> t -> t
moveOriginTo Point v n
p)
translated :: (InSpace v n a, SameSpace a b, Transformable a, Transformable b)
=> v n -> Iso a b a b
translated :: forall (v :: * -> *) n a b.
(InSpace v n a, SameSpace a b, Transformable a, Transformable b) =>
v n -> Iso a b a b
translated v n
v = forall (v :: * -> *) n a b.
(InSpace v n a, SameSpace a b, Transformable a, Transformable b) =>
Transformation v n -> Iso a b a b
transformed forall a b. (a -> b) -> a -> b
$ forall (v :: * -> *) n. v n -> Transformation v n
translation v n
v