vector-space-0.16: 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-Inferred
LanguageHaskell98

Data.AffineSpace

Description

Affine spaces.

Synopsis

Documentation

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

Minimal complete definition

Nothing

Associated Types

type Diff p Source #

Associated vector space

type Diff p = GenericDiff p

Methods

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

Subtract points

default (.-.) :: (Generic p, Diff p ~ GenericDiff p, AffineSpace (VRep p)) => p -> p -> Diff p Source #

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

Point plus vector

default (.+^) :: (Generic p, Diff p ~ GenericDiff p, AffineSpace (VRep p)) => p -> Diff p -> p Source #

Instances

Instances details
AffineSpace CDouble Source # 
Instance details

Defined in Data.AffineSpace

Associated Types

type Diff CDouble 
Instance details

Defined in Data.AffineSpace

type Diff CDouble = CDouble

Methods

(.-.) :: CDouble -> CDouble -> Diff CDouble Source #

(.+^) :: CDouble -> Diff CDouble -> CDouble Source #

AffineSpace CFloat Source # 
Instance details

Defined in Data.AffineSpace

Associated Types

type Diff CFloat 
Instance details

Defined in Data.AffineSpace

type Diff CFloat = CFloat

Methods

(.-.) :: CFloat -> CFloat -> Diff CFloat Source #

(.+^) :: CFloat -> Diff CFloat -> CFloat Source #

AffineSpace CInt Source # 
Instance details

Defined in Data.AffineSpace

Associated Types

type Diff CInt 
Instance details

Defined in Data.AffineSpace

type Diff CInt = CInt

Methods

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

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

AffineSpace CIntMax Source # 
Instance details

Defined in Data.AffineSpace

Associated Types

type Diff CIntMax 
Instance details

Defined in Data.AffineSpace

type Diff CIntMax = CIntMax

Methods

(.-.) :: CIntMax -> CIntMax -> Diff CIntMax Source #

(.+^) :: CIntMax -> Diff CIntMax -> CIntMax Source #

AffineSpace CLLong Source # 
Instance details

Defined in Data.AffineSpace

Associated Types

type Diff CLLong 
Instance details

Defined in Data.AffineSpace

type Diff CLLong = CLLong

Methods

(.-.) :: CLLong -> CLLong -> Diff CLLong Source #

(.+^) :: CLLong -> Diff CLLong -> CLLong Source #

AffineSpace CLong Source # 
Instance details

Defined in Data.AffineSpace

Associated Types

type Diff CLong 
Instance details

Defined in Data.AffineSpace

type Diff CLong = CLong

Methods

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

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

AffineSpace CSChar Source # 
Instance details

Defined in Data.AffineSpace

Associated Types

type Diff CSChar 
Instance details

Defined in Data.AffineSpace

type Diff CSChar = CSChar

Methods

(.-.) :: CSChar -> CSChar -> Diff CSChar Source #

(.+^) :: CSChar -> Diff CSChar -> CSChar Source #

AffineSpace CShort Source # 
Instance details

Defined in Data.AffineSpace

Associated Types

type Diff CShort 
Instance details

Defined in Data.AffineSpace

type Diff CShort = CShort

Methods

(.-.) :: CShort -> CShort -> Diff CShort Source #

(.+^) :: CShort -> Diff CShort -> CShort Source #

AffineSpace Integer Source # 
Instance details

Defined in Data.AffineSpace

Associated Types

type Diff Integer 
Instance details

Defined in Data.AffineSpace

type Diff Integer = Integer

Methods

(.-.) :: Integer -> Integer -> Diff Integer Source #

(.+^) :: Integer -> Diff Integer -> Integer Source #

AffineSpace Double Source # 
Instance details

Defined in Data.AffineSpace

Associated Types

type Diff Double 
Instance details

Defined in Data.AffineSpace

type Diff Double = Double

Methods

(.-.) :: Double -> Double -> Diff Double Source #

(.+^) :: Double -> Diff Double -> Double Source #

AffineSpace Float Source # 
Instance details

Defined in Data.AffineSpace

Associated Types

type Diff Float 
Instance details

Defined in Data.AffineSpace

type Diff Float = Float

Methods

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

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

AffineSpace Int Source # 
Instance details

Defined in Data.AffineSpace

Associated Types

type Diff Int 
Instance details

Defined in Data.AffineSpace

type Diff Int = Int

Methods

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

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

Integral a => AffineSpace (Ratio a) Source # 
Instance details

Defined in Data.AffineSpace

Associated Types

type Diff (Ratio a) 
Instance details

Defined in Data.AffineSpace

type Diff (Ratio a) = Ratio a

Methods

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

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

(AffineSpace p, AffineSpace q) => AffineSpace (p, q) Source # 
Instance details

Defined in Data.AffineSpace

Associated Types

type Diff (p, q) 
Instance details

Defined in Data.AffineSpace

type Diff (p, q) = (Diff p, Diff q)

Methods

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

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

AffineSpace p => AffineSpace (a -> p) Source # 
Instance details

Defined in Data.AffineSpace

Associated Types

type Diff (a -> p) 
Instance details

Defined in Data.AffineSpace

type Diff (a -> p) = a -> Diff p

Methods

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

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

AffineSpace a => AffineSpace (Rec0 a s) Source # 
Instance details

Defined in Data.AffineSpace

Associated Types

type Diff (Rec0 a s) 
Instance details

Defined in Data.AffineSpace

type Diff (Rec0 a s) = Diff a

Methods

(.-.) :: Rec0 a s -> Rec0 a s -> Diff (Rec0 a s) Source #

(.+^) :: Rec0 a s -> Diff (Rec0 a s) -> Rec0 a s Source #

(AffineSpace p, AffineSpace q, AffineSpace r) => AffineSpace (p, q, r) Source # 
Instance details

Defined in Data.AffineSpace

Associated Types

type Diff (p, q, r) 
Instance details

Defined in Data.AffineSpace

type Diff (p, q, r) = (Diff p, Diff q, Diff r)

Methods

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

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

(AffineSpace (f p), AffineSpace (g p)) => AffineSpace ((f :*: g) p) Source # 
Instance details

Defined in Data.AffineSpace

Associated Types

type Diff ((f :*: g) p) 
Instance details

Defined in Data.AffineSpace

type Diff ((f :*: g) p)

Methods

(.-.) :: (f :*: g) p -> (f :*: g) p -> Diff ((f :*: g) p) Source #

(.+^) :: (f :*: g) p -> Diff ((f :*: g) p) -> (f :*: g) p Source #

AffineSpace (f p) => AffineSpace (M1 i c f p) Source # 
Instance details

Defined in Data.AffineSpace

Associated Types

type Diff (M1 i c f p) 
Instance details

Defined in Data.AffineSpace

type Diff (M1 i c f p) = Diff (f p)

Methods

(.-.) :: M1 i c f p -> M1 i c f p -> Diff (M1 i c f p) Source #

(.+^) :: M1 i c f p -> Diff (M1 i c f p) -> M1 i c f p Source #

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

Point minus vector

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

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

Distance between two points. See also distanceSq.

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

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

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).