module Diagrams.ThreeD.Types
(
R3, r3, unr3
, P3, p3, unp3
, T3
) where
import Diagrams.Coordinates
import Diagrams.TwoD.Types
import Diagrams.Core
import Control.Newtype
import Data.Basis
import Data.VectorSpace
newtype R3 = R3 { unR3 :: (Double, Double, Double) }
deriving (AdditiveGroup, Eq, Ord, Show, Read)
instance Newtype R3 (Double, Double, Double) where
pack = R3
unpack = unR3
r3 :: (Double, Double, Double) -> R3
r3 = pack
unr3 :: R3 -> (Double, Double, Double)
unr3 = unpack
type instance V R3 = R3
instance VectorSpace R3 where
type Scalar R3 = Double
(*^) = over R3 . (*^)
instance HasBasis R3 where
type Basis R3 = Either () (Either () ())
basisValue = R3 . basisValue
decompose = decompose . unR3
decompose' = decompose' . unR3
instance InnerSpace R3 where
(unR3 -> vec1) <.> (unR3 -> vec2) = vec1 <.> vec2
instance Coordinates R3 where
type FinalCoord R3 = Double
type PrevDim R3 = R2
type Decomposition R3 = Double :& Double :& Double
(coords -> x :& y) & z = r3 (x,y,z)
coords (unR3 -> (x,y,z)) = x :& y :& z
type P3 = Point R3
p3 :: (Double, Double, Double) -> P3
p3 = pack . pack
unp3 :: P3 -> (Double, Double, Double)
unp3 = unpack . unpack
type T3 = Transformation R3
instance Transformable R3 where
transform = apply