vector-space-0.10.4: Vector & affine spaces, linear maps, and derivatives

Copyright(c) Conal Elliott and Andy J Gill 2008
LicenseBSD3
Maintainerconal@conal.net, andygill@ku.edu
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell98

Data.AffineSpace

Description

Affine spaces.

Synopsis

Documentation

class AdditiveGroup (Diff p) => AffineSpace p where #

Minimal complete definition

(.-.), (.+^)

Associated Types

type Diff p #

Associated vector space

Methods

(.-.) :: p -> p -> Diff p infix 6 #

Subtract points

(.+^) :: p -> Diff p -> p infixl 6 #

Point plus vector

Instances

AffineSpace Double # 

Associated Types

type Diff Double :: * #

AffineSpace Float # 

Associated Types

type Diff Float :: * #

Methods

(.-.) :: Float -> Float -> Diff Float #

(.+^) :: Float -> Diff Float -> Float #

AffineSpace Int # 

Associated Types

type Diff Int :: * #

Methods

(.-.) :: Int -> Int -> Diff Int #

(.+^) :: Int -> Diff Int -> Int #

AffineSpace Integer # 

Associated Types

type Diff Integer :: * #

AffineSpace CSChar # 

Associated Types

type Diff CSChar :: * #

AffineSpace CShort # 

Associated Types

type Diff CShort :: * #

AffineSpace CInt # 

Associated Types

type Diff CInt :: * #

Methods

(.-.) :: CInt -> CInt -> Diff CInt #

(.+^) :: CInt -> Diff CInt -> CInt #

AffineSpace CLong # 

Associated Types

type Diff CLong :: * #

Methods

(.-.) :: CLong -> CLong -> Diff CLong #

(.+^) :: CLong -> Diff CLong -> CLong #

AffineSpace CLLong # 

Associated Types

type Diff CLLong :: * #

AffineSpace CFloat # 

Associated Types

type Diff CFloat :: * #

AffineSpace CDouble # 

Associated Types

type Diff CDouble :: * #

AffineSpace CIntMax # 

Associated Types

type Diff CIntMax :: * #

Integral a => AffineSpace (Ratio a) # 

Associated Types

type Diff (Ratio a) :: * #

Methods

(.-.) :: Ratio a -> Ratio a -> Diff (Ratio a) #

(.+^) :: Ratio a -> Diff (Ratio a) -> Ratio a #

AffineSpace p => AffineSpace (a -> p) # 

Associated Types

type Diff (a -> p) :: * #

Methods

(.-.) :: (a -> p) -> (a -> p) -> Diff (a -> p) #

(.+^) :: (a -> p) -> Diff (a -> p) -> a -> p #

(AffineSpace p, AffineSpace q) => AffineSpace (p, q) # 

Associated Types

type Diff (p, q) :: * #

Methods

(.-.) :: (p, q) -> (p, q) -> Diff (p, q) #

(.+^) :: (p, q) -> Diff (p, q) -> (p, q) #

(AffineSpace p, AffineSpace q, AffineSpace r) => AffineSpace (p, q, r) # 

Associated Types

type Diff (p, q, r) :: * #

Methods

(.-.) :: (p, q, r) -> (p, q, r) -> Diff (p, q, r) #

(.+^) :: (p, q, r) -> Diff (p, q, r) -> (p, q, r) #

(.-^) :: AffineSpace p => p -> Diff p -> p infixl 6 #

Point minus vector

distanceSq :: (AffineSpace p, v ~ Diff p, InnerSpace v) => p -> p -> Scalar v #

Square of the distance between two points. Sometimes useful for efficiency. See also distance.

distance :: (AffineSpace p, v ~ Diff p, InnerSpace v, s ~ Scalar v, Floating (Scalar v)) => p -> p -> s #

Distance between two points. See also distanceSq.

alerp :: (AffineSpace p, VectorSpace (Diff p)) => p -> p -> Scalar (Diff p) -> p #

Affine linear interpolation. Varies from p to p' as s varies from 0 to 1. See also lerp (on vector spaces).

affineCombo :: (AffineSpace p, v ~ Diff p, VectorSpace v) => p -> [(p, Scalar v)] -> p #

Compute an affine combination (weighted average) of points. The first element is used as origin and is weighted such that all coefficients sum to 1. For example,

affineCombo a [(0.3,b), (0.2,c)]

is equal to

a .+^ (0.3 *^ (b .-. a) ^+^ 0.2 *^ (c .-. a))

and if a, b, and c were in a vector space would also be equal to

0.5 *^ a ^+^ 0.3 *^ b ^+^ 0.2 *^ c

See also linearCombo (on vector spaces).