Copyright | (c) 2014 diagrams-lib team (see LICENSE) |
---|---|

License | BSD-style (see LICENSE) |

Maintainer | diagrams-discuss@googlegroups.com |

Safe Haskell | None |

Language | Haskell2010 |

Type for representing directions, polymorphic in vector space

## Synopsis

- data Direction v n
- _Dir :: Iso' (Direction v n) (v n)
- direction :: v n -> Direction v n
- dir :: v n -> Direction v n
- fromDirection :: (Metric v, Floating n) => Direction v n -> v n
- fromDir :: (Metric v, Floating n) => Direction v n -> v n
- angleBetweenDirs :: (Metric v, Floating n, Ord n) => Direction v n -> Direction v n -> Angle n
- dirBetween :: (Additive v, Num n) => Point v n -> Point v n -> Direction v n

# Documentation

A vector is described by a `Direction`

and a magnitude. So we
can think of a `Direction`

as a vector that has forgotten its
magnitude. `Direction`

s can be used with `fromDirection`

and the
lenses provided by its instances.

## Instances

Functor v => Functor (Direction v) # | |

HasPhi v => HasPhi (Direction v) # | |

HasTheta v => HasTheta (Direction v) # | |

Eq (v n) => Eq (Direction v n) # | |

Ord (v n) => Ord (Direction v n) # | |

Defined in Diagrams.Direction compare :: Direction v n -> Direction v n -> Ordering # (<) :: Direction v n -> Direction v n -> Bool # (<=) :: Direction v n -> Direction v n -> Bool # (>) :: Direction v n -> Direction v n -> Bool # (>=) :: Direction v n -> Direction v n -> Bool # | |

Read (v n) => Read (Direction v n) # | |

Show (v n) => Show (Direction v n) # | |

(V (v n) ~ v, N (v n) ~ n, Transformable (v n)) => Transformable (Direction v n) # | |

Defined in Diagrams.Direction | |

type V (Direction v n) # | |

Defined in Diagrams.Direction | |

type N (Direction v n) # | |

Defined in Diagrams.Direction |

_Dir :: Iso' (Direction v n) (v n) #

_Dir is provided to allow efficient implementations of functions in particular vector-spaces, but should be used with care as it exposes too much information.

direction :: v n -> Direction v n #

`direction v`

is the direction in which `v`

points. Returns an
unspecified value when given the zero vector as input.

fromDirection :: (Metric v, Floating n) => Direction v n -> v n #

`fromDirection d`

is the unit vector in the direction `d`

.