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

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

Diagrams.Direction

Description

Type for representing directions, polymorphic in vector space

Synopsis

- data Direction (v :: Type -> Type) n
- _Dir :: forall v n p f. (Profunctor p, Functor f) => p (v n) (f (v n)) -> p (Direction v n) (f (Direction 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 :: forall (v :: Type -> Type) n. (Metric v, Floating n, Ord n) => Direction v n -> Direction v n -> Angle n
- dirBetween :: forall (v :: Type -> Type) n. (Additive v, Num n) => Point v n -> Point v n -> Direction v n

# Documentation

data Direction (v :: Type -> Type) n Source #

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

Instances details

HasPhi v => HasPhi (Direction v) Source # |
Instance details Defined in Diagrams.Direction Methods _phi :: RealFloat n => Lens' (Direction v n) (Angle n) Source #
HasTheta v => HasTheta (Direction v) Source # |
Instance details Defined in Diagrams.Direction Methods _theta :: RealFloat n => Lens' (Direction v n) (Angle n) Source #
Functor v => Functor (Direction v) Source # |
Instance details Defined in Diagrams.Direction Methods fmap :: (a -> b) -> Direction v a -> Direction v b Source # (<$) :: a -> Direction v b -> Direction v a Source #
(V (v n) ~ v, N (v n) ~ n, Transformable (v n)) => Transformable (Direction v n) Source # |
Instance details Defined in Diagrams.Direction Methods transform :: Transformation (V (Direction v n)) (N (Direction v n)) -> Direction v n -> Direction v n Source #
Read (v n) => Read (Direction v n) Source # |
Instance details Defined in Diagrams.Direction Methods readsPrec :: Int -> ReadS (Direction v n) Source # readList :: ReadS [Direction v n] Source # readPrec :: ReadPrec (Direction v n) Source # readListPrec :: ReadPrec [Direction v n] Source #
Show (v n) => Show (Direction v n) Source # |
Instance details Defined in Diagrams.Direction Methods showsPrec :: Int -> Direction v n -> ShowS Source # show :: Direction v n -> String Source # showList :: [Direction v n] -> ShowS Source #
Eq (v n) => Eq (Direction v n) Source # |
Instance details Defined in Diagrams.Direction Methods (==) :: Direction v n -> Direction v n -> Bool Source # (/=) :: Direction v n -> Direction v n -> Bool Source #
Ord (v n) => Ord (Direction v n) Source # |

Instance details

Defined in Diagrams.Direction

Methods

compare :: Direction v n -> Direction v n -> Ordering Source #

(<) :: Direction v n -> Direction v n -> Bool Source #

(<=) :: Direction v n -> Direction v n -> Bool Source #

(>) :: Direction v n -> Direction v n -> Bool Source #

(>=) :: Direction v n -> Direction v n -> Bool Source #

max :: Direction v n -> Direction v n -> Direction v n Source #

min :: Direction v n -> Direction v n -> Direction v n Source #

type N (Direction v n) Source # |
Instance details Defined in Diagrams.Direction type N (Direction v n) = n
type V (Direction v n) Source # |
Instance details Defined in Diagrams.Direction type V (Direction v n) = v

_Dir :: forall v n p f. (Profunctor p, Functor f) => p (v n) (f (v n)) -> p (Direction v n) (f (Direction v n)) Source #

_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 Source #

`direction v` is the direction in which `v` points. Returns an unspecified value when given the zero vector as input.

dir :: v n -> Direction v n Source #

Synonym for `direction`.

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

`fromDirection d` is the unit vector in the direction `d`.

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

Synonym for `fromDirection`.

angleBetweenDirs :: forall (v :: Type -> Type) n. (Metric v, Floating n, Ord n) => Direction v n -> Direction v n -> Angle n Source #

compute the positive angle between the two directions in their common plane

dirBetween :: forall (v :: Type -> Type) n. (Additive v, Num n) => Point v n -> Point v n -> Direction v n Source #

`dirBetween p q` returns the direction from `p` to `q`.