linear-1.20.3: Linear Algebra

Copyright | (C) 2012-2015 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | experimental
Portability | non-portable
Safe Haskell | Trustworthy
Language | Haskell98

Linear.V2

Description

2-D Vectors

Synopsis

- data V2 a = V2 !a !a
- class R1 t where
  - _x :: Lens' (t a) a
- class R1 t => R2 t where
  - _y :: Lens' (t a) a
  - _xy :: Lens' (t a) (V2 a)
- _yx :: R2 t => Lens' (t a) (V2 a)
- ex :: R1 t => E t
- ey :: R2 t => E t
- perp :: Num a => V2 a -> V2 a
- angle :: Floating a => a -> V2 a

# 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 |

Instances

Monad V2 Source |
Functor V2 Source |
MonadFix V2 Source |
Applicative V2 Source |
Foldable V2 Source |
Traversable V2 Source |
Generic1 V2 Source |
Distributive V2 Source |
Representable V2 Source |
MonadZip V2 Source |
Serial1 V2 Source |
Traversable1 V2 Source |
Apply V2 Source |
Bind V2 Source |
Foldable1 V2 Source |
Eq1 V2 Source |
Ord1 V2 Source |
Read1 V2 Source |
Show1 V2 Source |
Additive V2 Source |
Metric V2 Source |
R1 V2 Source |
R2 V2 Source |
Trace V2 Source |
Affine V2 Source |
Unbox a => Vector Vector (V2 a) Source |
Unbox a => MVector MVector (V2 a) Source |
Num r => Coalgebra r (E V2) Source |
Bounded a => Bounded (V2 a) Source |
Eq a => Eq (V2 a) Source |
Floating a => Floating (V2 a) Source |
Fractional a => Fractional (V2 a) Source |
Data a => Data (V2 a) Source |
Num a => Num (V2 a) Source |
Ord a => Ord (V2 a) Source |
Read a => Read (V2 a) Source |
Show a => Show (V2 a) Source |
Ix a => Ix (V2 a) Source |
Generic (V2 a) Source |
Storable a => Storable (V2 a) Source |
Binary a => Binary (V2 a) Source |
Serial a => Serial (V2 a) Source |
Serialize a => Serialize (V2 a) Source |
NFData a => NFData (V2 a) Source |
Hashable a => Hashable (V2 a) Source |
Unbox a => Unbox (V2 a) Source |
Ixed (V2 a) Source |
Epsilon a => Epsilon (V2 a) Source |
FunctorWithIndex (E V2) V2 Source |
FoldableWithIndex (E V2) V2 Source |
TraversableWithIndex (E V2) V2 Source |
Each (V2 a) (V2 b) a b Source |
type Rep1 V2 Source |
type Rep V2 = E V2 Source |
type Diff V2 = V2 Source |
data MVector s (V2 a) = MV_V2 !Int !(MVector s a) Source |
type Rep (V2 a) Source |
data Vector (V2 a) = V_V2 !Int !(Vector a) Source |
type Index (V2 a) = E V2 Source |
type IxValue (V2 a) = a Source |

class R1 t where Source

A space that has at least 1 basis vector `_x`.

Minimal complete definition

Nothing

Methods

_x :: Lens' (t a) a Source

    >>> V1 2 ^._x
    2

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

Instances

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

class R1 t => R2 t where Source

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

Minimal complete definition

Nothing

Methods

_y :: Lens' (t a) a Source

    >>> V2 1 2 ^._y
    2

    >>> V2 1 2 & _y .~ 3
    V2 1 3

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

Instances

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

_yx :: R2 t => Lens' (t a) (V2 a) Source

    >>> V2 1 2 ^. _yx
    V2 2 1

ex :: R1 t => E t Source

ey :: R2 t => E t Source

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

the counter-clockwise perpendicular vector

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

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