linear-1.10.1.1: Linear Algebra

Portabilitynon-portable
Stabilityexperimental
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellTrustworthy

Linear.V2

Description

2-D Vectors

Synopsis

Documentation

data V2 a Source

A 2-dimensional vector

>>> pure 1 :: V2 Int
V2 1 1
>>> V2 1 2 + V2 3 4
V2 4 6
>>> V2 1 2 * V2 3 4
V2 3 8
>>> sum (V2 1 2)
3

Constructors

V2 !a !a 

class R1 t whereSource

A space that has at least 1 basis vector _x.

Methods

_x :: Lens' (t a) aSource

>>> V1 2 ^._x
2
>>> V1 2 & _x .~ 3
V1 3

Instances

R1 Identity 
R1 V1 
R1 V2 
R1 V3 
R1 V4 
R1 f => R1 (Point f) 

class R1 t => R2 t whereSource

A space that distinguishes 2 orthogonal basis vectors _x and _y, but may have more.

Methods

_y :: Functor f => (a -> f a) -> t a -> f (t a)Source

>>> V2 1 2 ^._y
2
>>> V2 1 2 & _y .~ 3
V2 1 3
 _y :: Lens' (t a) a

_xy :: Functor f => (V2 a -> f (V2 a)) -> t a -> f (t a)Source

 _xy :: Lens' (t a) (V2 a)

Instances

R2 V2 
R2 V3 
R2 V4 
R2 f => R2 (Point f) 

ex :: R1 t => E tSource

ey :: R2 t => E tSource

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

the counter-clockwise perpendicular vector

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

angle :: Floating a => a -> V2 aSource