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

Copyright | (c) 2013 diagrams-lib team (see LICENSE)
License | BSD-style (see LICENSE)
Maintainer | diagrams-discuss@googlegroups.com
Safe Haskell | None
Language | Haskell2010

Diagrams.ThreeD.Transform

Contents

- Rotation
- Scaling
- Translation
- Reflection

Description

Transformations specific to three dimensions, with a few generic transformations (uniform scaling, translation) also re-exported for convenience.

Synopsis

- type T3 = Transformation V3
- aboutX :: Floating n => Angle n -> Transformation V3 n
- aboutY :: Floating n => Angle n -> Transformation V3 n
- aboutZ :: Floating n => Angle n -> Transformation V3 n
- rotationAbout :: Floating n => Point V3 n -> Direction V3 n -> Angle n -> Transformation V3 n
- rotateAbout :: (InSpace V3 n t, Floating n, Transformable t) => Point V3 n -> Direction V3 n -> Angle n -> t -> t
- pointAt :: (Floating n, Ord n) => Direction V3 n -> Direction V3 n -> Direction V3 n -> Transformation V3 n
- pointAt' :: (Floating n, Ord n) => V3 n -> V3 n -> V3 n -> Transformation V3 n
- scalingX :: forall (v :: Type -> Type) n. (Additive v, R1 v, Fractional n) => n -> Transformation v n
- scalingY :: forall (v :: Type -> Type) n. (Additive v, R2 v, Fractional n) => n -> Transformation v n
- scalingZ :: forall (v :: Type -> Type) n. (Additive v, R3 v, Fractional n) => n -> Transformation v n
- scaleX :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Fractional n, Transformable t) => n -> t -> t
- scaleY :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Fractional n, Transformable t) => n -> t -> t
- scaleZ :: forall (v :: Type -> Type) n t. (InSpace v n t, R3 v, Fractional n, Transformable t) => n -> t -> t
- scaling :: forall (v :: Type -> Type) n. (Additive v, Fractional n) => n -> Transformation v n
- scale :: forall (v :: Type -> Type) n a. (InSpace v n a, Eq n, Fractional n, Transformable a) => n -> a -> a
- translationX :: forall (v :: Type -> Type) n. (Additive v, R1 v, Num n) => n -> Transformation v n
- translateX :: forall (v :: Type -> Type) n t. (InSpace v n t, R1 v, Transformable t) => n -> t -> t
- translationY :: forall (v :: Type -> Type) n. (Additive v, R2 v, Num n) => n -> Transformation v n
- translateY :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Transformable t) => n -> t -> t
- translationZ :: forall (v :: Type -> Type) n. (Additive v, R3 v, Num n) => n -> Transformation v n
- translateZ :: forall (v :: Type -> Type) n t. (InSpace v n t, R3 v, Transformable t) => n -> t -> t
- translation :: v n -> Transformation v n
- translate :: Transformable t => Vn t -> t -> t
- reflectionX :: forall (v :: Type -> Type) n. (Additive v, R1 v, Num n) => Transformation v n
- reflectX :: forall (v :: Type -> Type) n t. (InSpace v n t, R1 v, Transformable t) => t -> t
- reflectionY :: forall (v :: Type -> Type) n. (Additive v, R2 v, Num n) => Transformation v n
- reflectY :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Transformable t) => t -> t
- reflectionZ :: forall (v :: Type -> Type) n. (Additive v, R3 v, Num n) => Transformation v n
- reflectZ :: forall (v :: Type -> Type) n t. (InSpace v n t, R3 v, Transformable t) => t -> t
- reflectionAcross :: (Metric v, Fractional n) => Point v n -> v n -> Transformation v n
- reflectAcross :: (InSpace v n t, Metric v, Fractional n, Transformable t) => Point v n -> v n -> t -> t

# Documentation

type T3 = Transformation V3 Source #

# Rotation

aboutX :: Floating n => Angle n -> Transformation V3 n Source #

Like `aboutZ`, but rotates about the X axis, bringing positive y-values towards the positive z-axis.

aboutY :: Floating n => Angle n -> Transformation V3 n Source #

Like `aboutZ`, but rotates about the Y axis, bringing postive x-values towards the negative z-axis.

aboutZ :: Floating n => Angle n -> Transformation V3 n Source #

Create a transformation which rotates by the given angle about a line parallel the Z axis passing through the local origin. A positive angle brings positive x-values towards the positive-y axis.

The angle can be expressed using any type which is an instance of `Angle`. For example, `aboutZ (1/4 @@ `turn`)`, `aboutZ (tau/4 @@ `rad`)`, and `aboutZ (90 @@ `deg`)` all represent the same transformation, namely, a counterclockwise rotation by a right angle. For more general rotations, see `rotationAbout`.

Note that writing `aboutZ (1/4)`, with no type annotation, will yield an error since GHC cannot figure out which sort of angle you want to use.

rotationAbout Source #

Arguments

:: Floating n |
=> Point V3 n | origin of rotation
-> Direction V3 n | direction of rotation axis
-> Angle n | angle of rotation
-> Transformation V3 n |

`rotationAbout p d a` is a rotation about a line parallel to `d` passing through `p`.

rotateAbout Source #

Arguments

:: (InSpace V3 n t, Floating n, Transformable t) |
=> Point V3 n | origin of rotation
-> Direction V3 n | direction of rotation axis
-> Angle n | angle of rotation
-> t |
-> t |

`rotationAbout p d a` is a rotation about a line parallel to `d` passing through `p`.

pointAt :: (Floating n, Ord n) => Direction V3 n -> Direction V3 n -> Direction V3 n -> Transformation V3 n Source #

`pointAt about initial final` produces a rotation which brings the direction `initial` to point in the direction `final` by first panning around `about`, then tilting about the axis perpendicular to `about` and `final`. In particular, if this can be accomplished without tilting, it will be, otherwise if only tilting is necessary, no panning will occur. The tilt will always be between ± 1/4 turn.

pointAt' :: (Floating n, Ord n) => V3 n -> V3 n -> V3 n -> Transformation V3 n Source #

pointAt' has the same behavior as `pointAt`, but takes vectors instead of directions.

# Scaling

scalingX :: forall (v :: Type -> Type) n. (Additive v, R1 v, Fractional n) => n -> Transformation v n Source #

Construct a transformation which scales by the given factor in the x (horizontal) direction.

scalingY :: forall (v :: Type -> Type) n. (Additive v, R2 v, Fractional n) => n -> Transformation v n Source #

Construct a transformation which scales by the given factor in the y (vertical) direction.

scalingZ :: forall (v :: Type -> Type) n. (Additive v, R3 v, Fractional n) => n -> Transformation v n Source #

Construct a transformation which scales by the given factor in the z direction.

scaleX :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Fractional n, Transformable t) => n -> t -> t Source #

Scale a diagram by the given factor in the x (horizontal) direction. To scale uniformly, use `scale`.

scaleY :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Fractional n, Transformable t) => n -> t -> t Source #

Scale a diagram by the given factor in the y (vertical) direction. To scale uniformly, use `scale`.

scaleZ :: forall (v :: Type -> Type) n t. (InSpace v n t, R3 v, Fractional n, Transformable t) => n -> t -> t Source #

Scale a diagram by the given factor in the z direction. To scale uniformly, use `scale`.

scaling :: forall (v :: Type -> Type) n. (Additive v, Fractional n) => n -> Transformation v n Source #

Create a uniform scaling transformation.

scale :: forall (v :: Type -> Type) n a. (InSpace v n a, Eq n, Fractional n, Transformable a) => n -> a -> a Source #

Scale uniformly in every dimension by the given scalar.

# Translation

translationX :: forall (v :: Type -> Type) n. (Additive v, R1 v, Num n) => n -> Transformation v n Source #

Construct a transformation which translates by the given distance in the x (horizontal) direction.

translateX :: forall (v :: Type -> Type) n t. (InSpace v n t, R1 v, Transformable t) => n -> t -> t Source #

Translate a diagram by the given distance in the x (horizontal) direction.

translationY :: forall (v :: Type -> Type) n. (Additive v, R2 v, Num n) => n -> Transformation v n Source #

Construct a transformation which translates by the given distance in the y (vertical) direction.

translateY :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Transformable t) => n -> t -> t Source #

Translate a diagram by the given distance in the y (vertical) direction.

translationZ :: forall (v :: Type -> Type) n. (Additive v, R3 v, Num n) => n -> Transformation v n Source #

Construct a transformation which translates by the given distance in the z direction.

translateZ :: forall (v :: Type -> Type) n t. (InSpace v n t, R3 v, Transformable t) => n -> t -> t Source #

Translate a diagram by the given distance in the y direction.

translation :: v n -> Transformation v n Source #

Create a translation.

translate :: Transformable t => Vn t -> t -> t Source #

Translate by a vector.

# Reflection

reflectionX :: forall (v :: Type -> Type) n. (Additive v, R1 v, Num n) => Transformation v n Source #

Construct a transformation which flips a diagram from left to right, i.e. sends the point (x,y) to (-x,y).

reflectX :: forall (v :: Type -> Type) n t. (InSpace v n t, R1 v, Transformable t) => t -> t Source #

Flip a diagram from left to right, i.e. send the point (x,y) to (-x,y).

reflectionY :: forall (v :: Type -> Type) n. (Additive v, R2 v, Num n) => Transformation v n Source #

Construct a transformation which flips a diagram from top to bottom, i.e. sends the point (x,y) to (x,-y).

reflectY :: forall (v :: Type -> Type) n t. (InSpace v n t, R2 v, Transformable t) => t -> t Source #

Flip a diagram from top to bottom, i.e. send the point (x,y) to (x,-y).

reflectionZ :: forall (v :: Type -> Type) n. (Additive v, R3 v, Num n) => Transformation v n Source #

Construct a transformation which flips a diagram across z=0, i.e. sends the point (x,y,z) to (x,y,-z).

reflectZ :: forall (v :: Type -> Type) n t. (InSpace v n t, R3 v, Transformable t) => t -> t Source #

Flip a diagram across z=0, i.e. send the point (x,y,z) to (x,y,-z).

reflectionAcross :: (Metric v, Fractional n) => Point v n -> v n -> Transformation v n Source #

`reflectionAcross p v` is a reflection across the plane through the point `p` and normal to vector `v`. This also works as a 2D transform where `v` is the normal to the line passing through point `p`.

reflectAcross :: (InSpace v n t, Metric v, Fractional n, Transformable t) => Point v n -> v n -> t -> t Source #

`reflectAcross p v` reflects a diagram across the plane though the point `p` and the vector `v`. This also works as a 2D transform where `v` is the normal to the line passing through point `p`.