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

Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone

Diagrams.ThreeD.Types

Contents

Description

Basic types for three-dimensional Euclidean space.

Synopsis

3D Euclidean space

data R3 Source

The three-dimensional Euclidean vector space R^3.

r3 :: (Double, Double, Double) -> R3Source

Construct a 3D vector from a triple of components.

unr3 :: R3 -> (Double, Double, Double)Source

Convert a 3D vector back into a triple of components.

mkR3 :: Double -> Double -> Double -> R3Source

Curried version of r3.

type P3 = Point R3Source

Points in R^3.

p3 :: (Double, Double, Double) -> P3Source

Construct a 3D point from a triple of coordinates.

unp3 :: P3 -> (Double, Double, Double)Source

Convert a 3D point back into a triple of coordinates.

mkP3 :: Double -> Double -> Double -> P3Source

Curried version of r3.

type T3 = Transformation R3Source

Transformations in R^3.

Two-dimensional angles

These are defined in Diagrams.TwoD.Types but reëxported here for convenience.

data Angle Source

Angles can be expressed in a variety of units. Internally, they are represented in radians.

rad :: Iso' Angle DoubleSource

The radian measure of an Angle a can be accessed as a ^. rad. A new Angle can be defined in radians as pi @@ rad.

turn :: Iso' Angle DoubleSource

The measure of an Angle a in full circles can be accessed as a ^. turn. A new Angle of one-half circle can be defined in as 1/2 @@ turn.

deg :: Iso' Angle DoubleSource

The degree measure of an Angle a can be accessed as a ^. deg. A new Angle can be defined in degrees as 180 @@ deg.

(@@) :: b -> Iso' a b -> aSource

30 @@ deg is an Angle of the given measure and units.

More generally, @@ reverses the Iso' on its right, and applies the Iso' to the value on the left. Angles are the motivating example where this order improves readability.

fullTurn :: AngleSource

An angle representing one full turn.

angleRatio :: Angle -> Angle -> DoubleSource

Calculate ratio between two angles.

Directions in 3D

class Direction d whereSource

Direction is a type class representing directions in R3. The interface is based on that of the Angle class in 2D.

Methods

toSpherical :: d -> SphericalSource

Convert to spherical coördinates

fromSpherical :: Spherical -> dSource

Convert from spherical coördinates

Instances

data Spherical Source

A direction expressed as a pair of spherical coordinates. `Spherical 0 0` is the direction of unitX. The first coordinate represents rotation about the Z axis, the second rotation towards the Z axis.

Constructors

Spherical Angle Angle 

asSpherical :: Spherical -> SphericalSource

The identity function with a restricted type, for conveniently restricting unwanted polymorphism. For example, fromDirection . asSpherical . camForward gives a unit vector pointing in the direction of the camera view. Without asSpherical, the intermediate type would be ambiguous.