diagrams-lib-1.2.0.8: Embedded domain-specific language for declarative graphics

Diagrams.TwoD.Types

Contents

Description

Basic types for two-dimensional Euclidean space.

Synopsis

# 2D Euclidean space

data R2 Source

The two-dimensional Euclidean vector space R^2. This type is intentionally abstract.

```r2 (3,4) :: R2
3 ^& 4    :: R2
```

Note that Diagrams.Coordinates is not re-exported by Diagrams.Prelude and must be explicitly imported.

• To construct the vector from the origin to a point `p`, use `p .-. origin`.
• To convert a vector `v` into the point obtained by following `v` from the origin, use `origin .+^ v`.
• To convert a vector back into a pair of components, use `unv2` or `coords` (from Diagrams.Coordinates). These are typically used in conjunction with the `ViewPatterns` extension:
```foo (unr2 -> (x,y)) = ...
foo (coords -> x :& y) = ...
```

Constructors

 R2 !Double !Double

Instances

 Eq R2 Fractional R2 Data R2 Num R2 Ord R2 Read R2 Show R2 Transformable R2 Wrapped R2 Lens wrapped isomorphisms for R2. HasBasis R2 VectorSpace R2 InnerSpace R2 AdditiveGroup R2 HasR P2 HasR R2 HasY P2 HasY R2 HasX P2 HasX R2 Coordinates R2 HasTheta P2 HasTheta R2 Typeable * R2 Rewrapped R2 R2 Traced (FixedSegment R2) Traced (Trail R2) Traced (Path R2) Traced (Segment Closed R2) Renderable (Path R2) b => TrailLike (QDiagram b R2 Any) type V R2 = R2 type Unwrapped R2 = (Double, Double) type Basis R2 type Scalar R2 = Double type FinalCoord R2 = Double type PrevDim R2 = Double type Decomposition R2 = (:&) Double Double

r2 :: (Double, Double) -> R2 Source

Construct a 2D vector from a pair of components. See also `&`.

unr2 :: R2 -> (Double, Double) Source

Convert a 2D vector back into a pair of components. See also `coords`.

mkR2 :: Double -> Double -> R2 Source

Curried form of `r2`.

type P2 = Point R2 Source

Points in R^2. This type is intentionally abstract.

```p2 (3,4)  :: P2
3 ^& 4    :: P2
```
• To construct a point from a vector `v`, use `origin .+^ v`.
• To convert a point `p` into the vector from the origin to `p`, use `p .-. origin`.
• To convert a point back into a pair of coordinates, use `unp2`, or `coords` (from Diagrams.Coordinates). It's common to use these in conjunction with the `ViewPatterns` extension:
```foo (unp2 -> (x,y)) = ...
foo (coords -> x :& y) = ...
```

p2 :: (Double, Double) -> P2 Source

Construct a 2D point from a pair of coordinates. See also `^&`.

mkP2 :: Double -> Double -> P2 Source

Curried form of `p2`.

unp2 :: P2 -> (Double, Double) Source

Convert a 2D point back into a pair of coordinates. See also `coords`.

Transformations in R^2.