Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
PhysicsVectors
Description
Documentation
class (Num a, Floating b, Eq b) => Vec a b | a -> b where Source #
The Vec class represents objects embedable within a normed vector space.
Implementing Vec requires a concept of a dot product and scalar multiplication with the restriction that the embedded vector space be over a ring with a multiplicative inverse.
More formally, instances should satisfy the three dot product rules, with the
fromScalar
requirement being an explicit representation of the implicit
scalar multiplication process through a hadamard product.
- \( x \cdot y = \overline{y \cdot x} \)
- \( ax \cdot y = a(x \cdot y)\) and \((x + y) \cdot z = x \cdot z + x \cdot y \)
- \( x \cdot x \geq 0 \)
Minimal complete definition
Methods
fromScalar :: b -> a Source #
fromScalar
s
returns a unit vector scaled by s
dot
v w
returns the dot product of v
and w
as defined by the
embedded vector space
scalarMult :: b -> a -> a Source #
Vec3
x y z
constructs a three dimensional cartesian vector with
coordinates as noted.
Instances
Eq a => Eq (Vec3 a) Source # | |
Floating a => Num (Vec3 a) Source # | |
Ord a => Ord (Vec3 a) Source # | |
Show a => Show (Vec3 a) Source # | |
Generic (Vec3 a) Source # | |
NFData a => NFData (Vec3 a) Source # | |
Defined in PhysicsVectors | |
(Eq a, Floating a) => Vec (Vec3 a) a Source # | |
type Rep (Vec3 a) Source # | |
Defined in PhysicsVectors type Rep (Vec3 a) = D1 (MetaData "Vec3" "PhysicsVectors" "nbody-0.1.0.0-5vnB4DCzNBqD29X1Eke4fT" False) (C1 (MetaCons "Vec3" PrefixI True) (S1 (MetaSel (Just "x") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a) :*: (S1 (MetaSel (Just "y") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a) :*: S1 (MetaSel (Just "z") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))) |
Instances
Eq a => Eq (Vec2 a) Source # | |
Floating a => Num (Vec2 a) Source # | |
Ord a => Ord (Vec2 a) Source # | |
Show a => Show (Vec2 a) Source # | |
Generic (Vec2 a) Source # | |
NFData a => NFData (Vec2 a) Source # | |
Defined in PhysicsVectors | |
(Eq a, Floating a) => Vec (Vec2 a) a Source # | |
type Rep (Vec2 a) Source # | |
Defined in PhysicsVectors type Rep (Vec2 a) = D1 (MetaData "Vec2" "PhysicsVectors" "nbody-0.1.0.0-5vnB4DCzNBqD29X1Eke4fT" False) (C1 (MetaCons "Vec2" PrefixI True) (S1 (MetaSel (Just "r") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Vec3 a)) :*: S1 (MetaSel (Just "v") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Vec3 a)))) |