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

Maintainer | diagrams-discuss@googlegroups.com
Safe Haskell | None

Diagrams.TwoD.Vector

Contents

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

Description

Two-dimensional vectors.

Synopsis

- unitX :: R2
- unitY :: R2
- unit_X :: R2
- unit_Y :: R2
- direction :: Angle a => R2 -> a
- fromDirection :: Angle a => a -> R2
- e :: Angle a => a -> R2
- perp :: R2 -> R2
- leftTurn :: R2 -> R2 -> Bool

# Special 2D vectors

unitX :: R2 Source

The unit vector in the positive X direction.

unitY :: R2 Source

The unit vector in the positive Y direction.

unit_X :: R2 Source

The unit vector in the negative X direction.

unit_Y :: R2 Source

The unit vector in the negative Y direction.

# Converting between vectors and angles

direction :: Angle a => R2 -> aSource

Compute the direction of a vector, measured counterclockwise from the positive x-axis as a fraction of a full turn. The zero vector is arbitrarily assigned the direction 0.

fromDirection :: Angle a => a -> R2 Source

Convert an angle into a unit vector pointing in that direction.

e :: Angle a => a -> R2 Source

A convenient synonym for `fromDirection`.

# 2D vector utilities

perp :: R2 -> R2 Source

`perp v` is perpendicular to and has the same magnitude as `v`. In particular `perp v == rotateBy (1/4) v`.

leftTurn :: R2 -> R2 -> 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).