diagrams-core-0.6: Core libraries for diagrams EDSL

Maintainer diagrams-discuss@googlegroups.com None

Diagrams.Core.HasOrigin

Description

Types which have an intrinsic notion of a "local origin", i.e. things which are not invariant under translation.

Synopsis

# Documentation

class VectorSpace (V t) => HasOrigin t whereSource

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.

Methods

moveOriginTo :: Point (V t) -> t -> tSource

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.

Instances

 (VectorSpace (V [a]), HasOrigin a) => HasOrigin [a] (VectorSpace (V (Set a)), HasOrigin a, Ord a) => HasOrigin (Set a) (VectorSpace (V (Point v)), VectorSpace v) => HasOrigin (Point v) (VectorSpace (V (TransInv t)), VectorSpace (V t)) => HasOrigin (TransInv t) (VectorSpace (V (Transformation v)), HasLinearMap v) => HasOrigin (Transformation v) (VectorSpace (V (Trace v)), VectorSpace v) => HasOrigin (Trace v) (VectorSpace (V (Envelope v)), 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 (a, b)), HasOrigin a, HasOrigin b, ~ * (V a) (V b)) => HasOrigin (a, b) (VectorSpace (V (Map k a)), HasOrigin a) => HasOrigin (Map k a) (VectorSpace (V (Query v m)), VectorSpace v) => HasOrigin (Query v m) (VectorSpace (V (SubMap b v m)), OrderedField (Scalar v), InnerSpace v, HasLinearMap v) => HasOrigin (SubMap b v m) (VectorSpace (V (Subdiagram b v m)), HasLinearMap v, InnerSpace v, OrderedField (Scalar v)) => HasOrigin (Subdiagram b v m) (VectorSpace (V (QDiagram b 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.

moveOriginBy :: HasOrigin t => V t -> t -> tSource

Move the local origin by a relative vector.

moveTo :: HasOrigin t => Point (V t) -> t -> tSource

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) -> tSource

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.