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

Copyright (c) Conal Elliott and Andy J Gill 2008 BSD3 conal@conal.net, andygill@ku.edu experimental Safe Haskell98

Data.AffineSpace

Description

Affine spaces.

Synopsis

# Documentation

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

Minimal complete definition

Associated Types

type Diff p Source #

Associated vector space

Methods

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

Subtract points

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

Point plus vector

Instances

 Source # Associated Typestype Diff Double :: * Source # Methods Source # Associated Typestype Diff Float :: * Source # Methods Source # Associated Typestype Diff Int :: * Source # Methods Source # Associated Typestype Diff Integer :: * Source # Methods Source # Associated Typestype Diff CSChar :: * Source # Methods Source # Associated Typestype Diff CShort :: * Source # Methods Source # Associated Typestype Diff CInt :: * Source # Methods Source # Associated Typestype Diff CLong :: * Source # Methods Source # Associated Typestype Diff CLLong :: * Source # Methods Source # Associated Typestype Diff CFloat :: * Source # Methods Source # Associated Typestype Diff CDouble :: * Source # Methods Source # Associated Typestype Diff CIntMax :: * Source # Methods Integral a => AffineSpace (Ratio a) Source # Associated Typestype Diff (Ratio a) :: * Source # Methods(.-.) :: Ratio a -> Ratio a -> Diff (Ratio a) Source #(.+^) :: Ratio a -> Diff (Ratio a) -> Ratio a Source # AffineSpace p => AffineSpace (a -> p) Source # Associated Typestype Diff (a -> p) :: * Source # Methods(.-.) :: (a -> p) -> (a -> p) -> Diff (a -> p) Source #(.+^) :: (a -> p) -> Diff (a -> p) -> a -> p Source # (AffineSpace p, AffineSpace q) => AffineSpace (p, q) Source # Associated Typestype Diff (p, q) :: * Source # Methods(.-.) :: (p, q) -> (p, q) -> Diff (p, q) Source #(.+^) :: (p, q) -> Diff (p, q) -> (p, q) Source # (AffineSpace p, AffineSpace q, AffineSpace r) => AffineSpace (p, q, r) Source # Associated Typestype Diff (p, q, r) :: * Source # Methods(.-.) :: (p, q, r) -> (p, q, r) -> Diff (p, q, r) Source #(.+^) :: (p, q, r) -> Diff (p, q, r) -> (p, q, r) 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).