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

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

Diagrams.TwoD.Vector

Contents

- Special 2D vectors
- Converting between vectors and angles
- 2D vector utilities

Description

Two-dimensional vectors.

Synopsis

- unitX :: (R1 v, Additive v, Num n) => v n
- unitY :: (R2 v, Additive v, Num n) => v n
- unit_X :: (R1 v, Additive v, Num n) => v n
- unit_Y :: (R2 v, Additive v, Num n) => v n
- xDir :: (R1 v, Additive v, Num n) => Direction v n
- yDir :: (R2 v, Additive v, Num n) => Direction v n
- angleV :: Floating n => Angle n -> V2 n
- angleDir :: Floating n => Angle n -> Direction V2 n
- e :: Floating n => Angle n -> V2 n
- signedAngleBetween :: RealFloat n => V2 n -> V2 n -> Angle n
- signedAngleBetweenDirs :: RealFloat n => Direction V2 n -> Direction V2 n -> Angle n
- perp :: Num a => V2 a -> V2 a
- leftTurn :: (Num n, Ord n) => V2 n -> V2 n -> Bool
- cross2 :: Num n => V2 n -> V2 n -> n

# Special 2D vectors

unitX :: (R1 v, Additive v, Num n) => v n Source

The unit vector in the positive X direction.

unitY :: (R2 v, Additive v, Num n) => v n Source

The unit vector in the positive Y direction.

unit_X :: (R1 v, Additive v, Num n) => v n Source

The unit vector in the negative X direction.

unit_Y :: (R2 v, Additive v, Num n) => v n Source

The unit vector in the negative Y direction.

xDir :: (R1 v, Additive v, Num n) => Direction v n Source

A `Direction` pointing in the X direction.

yDir :: (R2 v, Additive v, Num n) => Direction v n Source

A `Direction` pointing in the Y direction.

# Converting between vectors and angles

angleV :: Floating n => Angle n -> V2 n Source

A unit vector at a specified angle counter-clockwise from the positive x-axis

angleDir :: Floating n => Angle n -> Direction V2 n Source

A direction at a specified angle counter-clockwise from the `xDir`.

e :: Floating n => Angle n -> V2 n Source

A unit vector at a specified angle counter-clockwise from the positive X axis.

signedAngleBetween :: RealFloat n => V2 n -> V2 n -> Angle n Source

signedAngleBetweenDirs :: RealFloat n => Direction V2 n -> Direction V2 n -> Angle n Source

# 2D vector utilities

perp :: Num a => V2 a -> V2 a

the counter-clockwise perpendicular vector

    >>> perp $ V2 10 20
    V2 (-20) 10

leftTurn :: (Num n, Ord n) => V2 n -> V2 n -> Bool Source

`leftTurn v1 v2` tests whether the direction of `v2` is a left turn from `v1` (that is, if the direction of `v2` can be obtained from that of `v1` by adding an angle 0 <= theta <= tau/2).

cross2 :: Num n => V2 n -> V2 n -> n Source

Cross product on vectors in R2.