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

Copyright(c) 2011 diagrams-lib team (see LICENSE)
LicenseBSD-style (see LICENSE)
Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone
LanguageHaskell2010

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) -> R3 Source

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 -> R3 Source

Curried version of r3.

type P3 = Point R3 Source

Points in R^3.

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

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 -> P3 Source

Curried version of r3.

type T3 = Transformation R3 Source

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 Double Source

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 Double Source

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 Double Source

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 -> a infixl 5 Source

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 :: Angle Source

An angle representing one full turn.

angleRatio :: Angle -> Angle -> Double Source

Calculate ratio between two angles.

Directions in 3D

class Direction d where Source

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

Methods

toSpherical :: d -> Spherical Source

Convert to spherical coördinates

fromSpherical :: Spherical -> d Source

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 -> Spherical Source

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.