Copyright  (c) 201113 diagramslib team (see LICENSE) 

License  BSDstyle (see LICENSE) 
Maintainer  diagramsdiscuss@googlegroups.com 
Safe Haskell  None 
Language  Haskell2010 
Affine transformations, parameterized by any vector space. For transformations on particular vector spaces, see e.g. Diagrams.TwoD.Transform.
 data Transformation v :: * > *
 inv :: HasLinearMap v => Transformation v > Transformation v
 transl :: Transformation v > v
 apply :: HasLinearMap v => Transformation v > v > v
 papply :: HasLinearMap v => Transformation v > Point v > Point v
 class HasLinearMap (V t) => Transformable t where
 transform :: Transformation (V t) > t > t
 translation :: HasLinearMap v => v > Transformation v
 translate :: (Transformable t, HasLinearMap (V t)) => V t > t > t
 moveTo :: HasOrigin t => Point (V t) > t > t
 place :: HasOrigin t => t > Point (V t) > t
 scaling :: (HasLinearMap v, Fractional (Scalar v)) => Scalar v > Transformation v
 scale :: (Transformable t, Fractional (Scalar (V t)), Eq (Scalar (V t))) => Scalar (V t) > t > t
 conjugate :: HasLinearMap v => Transformation v > Transformation v > Transformation v
 under :: Transformable a => (a > a) > Transformation (V a) > a > a
 class VectorSpace (V t) => HasOrigin t where
 moveOriginTo :: Point (V t) > t > t
 moveOriginBy :: HasOrigin t => V t > t > t
Transformations
data Transformation v :: * > *
General (affine) transformations, represented by an invertible linear map, its transpose, and a vector representing a translation component.
By the transpose of a linear map we mean simply the linear map corresponding to the transpose of the map's matrix representation. For example, any scale is its own transpose, since scales are represented by matrices with zeros everywhere except the diagonal. The transpose of a rotation is the same as its inverse.
The reason we need to keep track of transposes is because it turns out that when transforming a shape according to some linear map L, the shape's normal vectors transform according to L's inverse transpose. This is exactly what we need when transforming bounding functions, which are defined in terms of perpendicular (i.e. normal) hyperplanes.
For more general, noninvertable transformations, see
Diagrams.Deform
(in diagramslib
).
HasLinearMap v => Semigroup (Transformation v)  Transformations are closed under composition; 
HasLinearMap v => Monoid (Transformation v)  
HasLinearMap v => Transformable (Transformation v)  
HasLinearMap v => HasOrigin (Transformation v)  
(HasLinearMap v, (~) * v (V a), Transformable a) => Action (Transformation v) a  Transformations can act on transformable things. 
type V (Transformation v) = v 
inv :: HasLinearMap v => Transformation v > Transformation v
Invert a transformation.
transl :: Transformation v > v
Get the translational component of a transformation.
apply :: HasLinearMap v => Transformation v > v > v
Apply a transformation to a vector. Note that any translational component of the transformation will not affect the vector, since vectors are invariant under translation.
papply :: HasLinearMap v => Transformation v > Point v > Point v
Apply a transformation to a point.
The Transformable class
class HasLinearMap (V t) => Transformable t where
Type class for things t
which can be transformed.
transform :: Transformation (V t) > t > t
Apply a transformation to an object.
Some specific transformations
translation :: HasLinearMap v => v > Transformation v
Create a translation.
translate :: (Transformable t, HasLinearMap (V t)) => V t > t > t
Translate by a vector.
moveTo :: HasOrigin t => Point (V t) > t > t
Translate the object by the translation that sends the origin to
the given point. Note that this is dual to moveOriginTo
, i.e. we
should have
moveTo (origin .^+ v) === moveOriginTo (origin .^ v)
For types which are also Transformable
, this is essentially the
same as translate
, i.e.
moveTo (origin .^+ v) === translate v
place :: HasOrigin t => t > Point (V t) > t
A flipped variant of moveTo
, provided for convenience. Useful
when writing a function which takes a point as an argument, such
as when using withName
and friends.
scaling :: (HasLinearMap v, Fractional (Scalar v)) => Scalar v > Transformation v
Create a uniform scaling transformation.
scale :: (Transformable t, Fractional (Scalar (V t)), Eq (Scalar (V t))) => Scalar (V t) > t > t
Scale uniformly in every dimension by the given scalar.
Miscellaneous transformationrelated utilities
conjugate :: HasLinearMap v => Transformation v > Transformation v > Transformation v Source
Conjugate one transformation by another. conjugate t1 t2
is the
transformation which performs first t1
, then t2
, then the
inverse of t1
.
under :: Transformable a => (a > a) > Transformation (V a) > a > a Source
Carry out some transformation "under" another one: f ``under``
t
first applies t
, then f
, then the inverse of t
. For
example,
is the transformation which scales by a factor of 2 along the
diagonal line y = x.scaleX
2 ``under`` rotation
(1/8 @@ Turn)
Note that
(transform t2) under
t1 == transform (conjugate t1 t2)
for all transformations t1
and t2
.
The HasOrigin class
class VectorSpace (V t) => HasOrigin t where
Class of types which have an intrinsic notion of a "local origin", i.e. things which are not invariant under translation, and which allow the origin to be moved.
One might wonder why not just use Transformable
instead of
having a separate class for HasOrigin
; indeed, for types which
are instances of both we should have the identity
moveOriginTo (origin .^+ v) === translate (negateV v)
The reason is that some things (e.g. vectors, Trail
s) are
transformable but are translationally invariant, i.e. have no
origin.
moveOriginTo :: Point (V t) > t > t
Move the local origin to another point.
Note that this function is in some sense dual to translate
(for types which are also Transformable
); moving the origin
itself while leaving the object "fixed" is dual to fixing the
origin and translating the diagram.
HasOrigin Image  
HasOrigin Text  
HasOrigin a => HasOrigin [a]  
HasOrigin a => HasOrigin (Active a)  
(HasOrigin a, Ord a) => HasOrigin (Set a)  
(InnerSpace v, Fractional (Scalar v)) => HasOrigin (Envelope v)  The local origin of an envelope is the point with respect to which bounding queries are made, i.e. the point from which the input vectors are taken to originate. 
VectorSpace v => HasOrigin (Trace v)  
HasLinearMap v => HasOrigin (Transformation v)  
VectorSpace (V t) => HasOrigin (TransInv t)  
VectorSpace v => HasOrigin (Point v)  
(VectorSpace v, HasBasis v, Ord (Basis v), AdditiveGroup (Scalar v), Ord (Scalar v)) => HasOrigin (BoundingBox v)  
((~) * (V t) R2, HasOrigin t) => HasOrigin (ScaleInv t)  
VectorSpace (V a) => HasOrigin (Located a) 

VectorSpace v => HasOrigin (FixedSegment v)  
VectorSpace v => HasOrigin (Path v)  
(HasOrigin a, HasOrigin b, (~) * (V a) (V b)) => HasOrigin (a, b)  
HasOrigin a => HasOrigin (Map k a)  
VectorSpace v => HasOrigin (Query v m)  
(HasLinearMap v, InnerSpace v, OrderedField (Scalar v), Semigroup m) => HasOrigin (QDiagram b v m)  Every diagram has an intrinsic "local origin" which is the basis for all combining operations. 
(HasLinearMap v, InnerSpace v, OrderedField (Scalar v)) => HasOrigin (Subdiagram b v m)  
(OrderedField (Scalar v), InnerSpace v, HasLinearMap v) => HasOrigin (SubMap b v m) 
moveOriginBy :: HasOrigin t => V t > t > t
Move the local origin by a relative vector.