Copyright | (c) Conal Elliott and Andy J Gill 2008 |
---|---|
License | BSD3 |
Maintainer | conal@conal.net, andygill@ku.edu |
Stability | experimental |
Safe Haskell | Safe |
Language | Haskell98 |
Affine spaces.
Synopsis
- class AdditiveGroup (Diff p) => AffineSpace p where
- (.-^) :: AffineSpace p => p -> Diff p -> p
- distanceSq :: (AffineSpace p, v ~ Diff p, InnerSpace v) => p -> p -> Scalar v
- distance :: (AffineSpace p, v ~ Diff p, InnerSpace v, s ~ Scalar v, Floating (Scalar v)) => p -> p -> s
- alerp :: (AffineSpace p, VectorSpace (Diff p)) => p -> p -> Scalar (Diff p) -> p
- affineCombo :: (AffineSpace p, v ~ Diff p, VectorSpace v) => p -> [(p, Scalar v)] -> p
Documentation
class AdditiveGroup (Diff p) => AffineSpace p where Source #
Nothing
(.-.) :: p -> p -> Diff p infix 6 Source #
Subtract points
(.-.) :: (Generic p, Diff p ~ GenericDiff p, AffineSpace (VRep p)) => p -> p -> Diff p infix 6 Source #
Subtract points
(.+^) :: p -> Diff p -> p infixl 6 Source #
Point plus vector
(.+^) :: (Generic p, Diff p ~ GenericDiff p, AffineSpace (VRep p)) => p -> Diff p -> p infixl 6 Source #
Point plus vector
Instances
AffineSpace Double Source # | |
AffineSpace Float Source # | |
AffineSpace Int Source # | |
AffineSpace Integer Source # | |
AffineSpace CSChar Source # | |
AffineSpace CShort Source # | |
AffineSpace CInt Source # | |
AffineSpace CLong Source # | |
AffineSpace CLLong Source # | |
AffineSpace CFloat Source # | |
AffineSpace CDouble Source # | |
AffineSpace CIntMax Source # | |
Integral a => AffineSpace (Ratio a) Source # | |
AffineSpace p => AffineSpace (a -> p) Source # | |
(AffineSpace p, AffineSpace q) => AffineSpace (p, q) Source # | |
AffineSpace a => AffineSpace (Rec0 a s) Source # | |
(AffineSpace p, AffineSpace q, AffineSpace r) => AffineSpace (p, q, r) Source # | |
(AffineSpace (f p), AffineSpace (g p)) => AffineSpace ((f :*: g) p) Source # | |
AffineSpace (f p) => AffineSpace (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).