{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wall -fno-warn-orphans #-}
{-# LANGUAGE Safe #-}
module Physics.Learn.CarrotVec
( Vec
, R
, xComp
, yComp
, zComp
, vec
, (^+^)
, (^-^)
, (*^)
, (^*)
, (^/)
, (<.>)
, (><)
, magnitude
, zeroV
, negateV
, sumV
, iHat
, jHat
, kHat
)
where
import Data.VectorSpace
( VectorSpace(..)
, InnerSpace(..)
, AdditiveGroup(..)
, Scalar
, (^+^)
, (^-^)
, (*^)
, (^*)
, (^/)
, (<.>)
, magnitude
, zeroV
, negateV
, sumV
)
import Physics.Learn.CommonVec
( Vec(..)
, R
, xComp
, yComp
, zComp
, vec
, (><)
, iHat
, jHat
, kHat
)
instance AdditiveGroup Vec where
zeroV = vec 0 0 0
negateV (Vec ax ay az) = Vec (-ax) (-ay) (-az)
Vec ax ay az ^+^ Vec bx by bz = Vec (ax+bx) (ay+by) (az+bz)
instance VectorSpace Vec where
type Scalar Vec = R
c *^ Vec ax ay az = Vec (c*ax) (c*ay) (c*az)
instance InnerSpace Vec where
Vec ax ay az <.> Vec bx by bz = ax*bx + ay*by + az*bz