diagrams-lib-1.4.2.2: 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.TwoD.Vector

Contents

Description

Two-dimensional vectors.

Synopsis

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 #

Signed angle between two vectors. Currently defined as

signedAngleBetween u v = (u ^. _theta) ^-^ (v ^. _theta)

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

Same as signedAngleBetween but for Directionss.

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.