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

Diagrams.TwoD.Vector

Description

Two-dimensional vectors.

Synopsis

# Special 2D vectors

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

The unit vector in the positive X direction.

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

The unit vector in the positive Y direction.

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

The unit vector in the negative X direction.

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

The unit vector in the negative Y direction.

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

A Direction pointing in the X direction.

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

A Direction pointing in the Y direction.

# Converting between vectors and angles

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

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

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

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

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

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

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

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 #

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 #

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 #

Cross product on vectors in R2.