HORIZON HASKELLDocslts/ghc-10.0.xfc4e5982026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

Modulevector-space-0.19Haskell2010

Data.AffineSpace

Affine spaces.

  • 1 class
  • 5 values
  • Packagevector-space-0.19
  • Exports6
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceAffineSpace.hs
classclass AdditiveGroup (Diff p) => AffineSpace p where
#

Associated types

  • type family Diff p

    Associated vector space

Methods

  • (.-.) :: p -> p -> Diff pinfix 6

    Subtract points

  • (.+^) :: p -> Diff p -> pinfixl 6

    Point plus vector

Instances20AffineSpace, …
valueaffineCombo
  1. :: (AffineSpace p, v ~ Diff p, VectorSpace v)
  2. => p
  3. -> [(p, Scalar v)]
  4. -> 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).