|Copyright||(c) 2011-13 diagrams-lib team (see LICENSE)|
|License||BSD-style (see LICENSE)|
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
- 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, Transformable b, V a ~ V b) => (a -> b) -> Transformation (V a) -> a -> b
- class VectorSpace (V t) => HasOrigin t where
- moveOriginBy :: HasOrigin t => V t -> t -> t
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, non-invertable transformations, see
|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|
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.
Apply a transformation to a point.
The Transformable class
Type class for things
t which can be transformed.
Some specific transformations
Translate the object by the translation that sends the origin to
the given point. Note that this is dual to
moveOriginTo, i.e. we
moveTo (origin .^+ v) === moveOriginTo (origin .^- v)
For types which are also
Transformable, this is essentially the
moveTo (origin .^+ v) === translate v
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.
Create a uniform scaling transformation.
Scale uniformly in every dimension by the given scalar.
Miscellaneous transformation-related utilities
Conjugate one transformation by another.
conjugate t1 t2 is the
transformation which performs first
t2, then the
Carry out some transformation "under" another one:
t first applies
f, then the inverse of
is the transformation which scales by a factor of 2 along the
diagonal line y = x.
scaleX 2 ``under``
rotation (-1/8 @@ Turn)
undert1 == transform (conjugate t1 t2)
for all transformations
The HasOrigin class
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,
transformable but are translationally invariant, i.e. have no
Move the local origin to another point.
Note that this function is in some sense dual to
(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 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 (DImage a)|
|(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)|