linear-1.20.3: Linear Algebra

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

Linear.Affine

Description

Operations on affine spaces.

Synopsis

- class Additive (Diff p) => Affine p where
  - type Diff p :: * -> *
  - (.-.) :: Num a => p a -> p a -> Diff p a
  - (.+^) :: Num a => p a -> Diff p a -> p a
  - (.-^) :: Num a => p a -> Diff p a -> p a
- qdA :: (Affine p, Foldable (Diff p), Num a) => p a -> p a -> a
- distanceA :: (Floating a, Foldable (Diff p), Affine p) => p a -> p a -> a
- newtype Point f a = P (f a)
- lensP :: Lens' (Point g a) (g a)
- _Point :: Iso' (Point f a) (f a)
- origin :: (Additive f, Num a) => Point f a
- relative :: (Additive f, Num a) => Point f a -> Iso' (Point f a) (f a)

# Documentation

class Additive (Diff p) => Affine p where Source

An affine space is roughly a vector space in which we have forgotten or at least pretend to have forgotten the origin.

    a .+^ (b .-. a)  =  b@
    (a .+^ u) .+^ v  =  a .+^ (u ^+^ v)@
    (a .-. b) ^+^ v  =  (a .+^ v) .-. q@

Minimal complete definition

(.-.), (.+^)

Associated Types

type Diff p :: * -> * Source

Methods

(.-.) :: Num a => p a -> p a -> Diff p a infixl 6 Source

Get the difference between two points as a vector offset.

(.+^) :: Num a => p a -> Diff p a -> p a infixl 6 Source

Add a vector offset to a point.

(.-^) :: Num a => p a -> Diff p a -> p a infixl 6 Source

Subtract a vector offset from a point.

Instances

Affine [] Source |
Affine Identity Source |
Affine Complex Source |
Affine ZipList Source |
Affine Maybe Source |
Affine IntMap Source |
Affine Vector Source |
Affine V0 Source |
Affine V1 Source |
Affine V2 Source |
Affine V3 Source |
Affine V4 Source |
Affine Plucker Source |
Affine Quaternion Source |
Affine ((->) b) Source |
Ord k => Affine (Map k) Source |
(Eq k, Hashable k) => Affine (HashMap k) Source |
Additive f => Affine (Point f) Source |
Dim * n => Affine (V * n) Source |

qdA :: (Affine p, Foldable (Diff p), Num a) => p a -> p a -> a Source

Compute the quadrance of the difference (the square of the distance)

distanceA :: (Floating a, Foldable (Diff p), Affine p) => p a -> p a -> a Source

Distance between two points in an affine space

newtype Point f a Source

A handy wrapper to help distinguish points from vectors at the type level

Constructors

P (f a) |

Instances

Unbox (f a) => Vector Vector (Point f a) Source |
Unbox (f a) => MVector MVector (Point f a) Source |
Monad f => Monad (Point f) Source |
Functor f => Functor (Point f) Source |
Applicative f => Applicative (Point f) Source |
Foldable f => Foldable (Point f) Source |
Traversable f => Traversable (Point f) Source |
Generic1 (Point f) Source |
Distributive f => Distributive (Point f) Source |
Representable f => Representable (Point f) Source |
Serial1 f => Serial1 (Point f) Source |
Apply f => Apply (Point f) Source |
Bind f => Bind (Point f) Source |
Eq1 f => Eq1 (Point f) Source |
Ord1 f => Ord1 (Point f) Source |
Read1 f => Read1 (Point f) Source |
Show1 f => Show1 (Point f) Source |
Additive f => Additive (Point f) Source |
Metric f => Metric (Point f) Source |
R1 f => R1 (Point f) Source |
R2 f => R2 (Point f) Source |
R3 f => R3 (Point f) Source |
R4 f => R4 (Point f) Source |
Additive f => Affine (Point f) Source |
Eq (f a) => Eq (Point f a) Source |
Fractional (f a) => Fractional (Point f a) Source |
(Data (f a), Typeable (* -> *) f, Typeable * a) => Data (Point f a) Source |
Num (f a) => Num (Point f a) Source |
Ord (f a) => Ord (Point f a) Source |
Read (f a) => Read (Point f a) Source |
Show (f a) => Show (Point f a) Source |
Ix (f a) => Ix (Point f a) Source |
Generic (Point f a) Source |
Storable (f a) => Storable (Point f a) Source |
Binary (f a) => Binary (Point f a) Source |
Serial (f a) => Serial (Point f a) Source |
Serialize (f a) => Serialize (Point f a) Source |
NFData (f a) => NFData (Point f a) Source |
Hashable (f a) => Hashable (Point f a) Source |
Unbox (f a) => Unbox (Point f a) Source |
Ixed (f a) => Ixed (Point f a) Source |
Wrapped (Point f a) Source |
Epsilon (f a) => Epsilon (Point f a) Source |
(~) * t (Point g b) => Rewrapped (Point f a) t Source |
Traversable f => Each (Point f a) (Point f b) a b Source |
data MVector s (Point f a) = MV_P !(MVector s (f a)) Source |
type Rep1 (Point f) Source |
type Rep (Point f) = Rep f Source |
type Diff (Point f) = f Source |
type Rep (Point f a) Source |
data Vector (Point f a) = V_P !(Vector (f a)) Source |
type Index (Point f a) = Index (f a) Source |
type IxValue (Point f a) = IxValue (f a) Source |
type Unwrapped (Point f a) = f a Source |

lensP :: Lens' (Point g a) (g a) Source

_Point :: Iso' (Point f a) (f a) Source

origin :: (Additive f, Num a) => Point f a Source

Vector spaces have origins.

relative :: (Additive f, Num a) => Point f a -> Iso' (Point f a) (f a) Source

An isomorphism between points and vectors, given a reference point.