{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE Safe #-}
module Physics.Learn.CoordinateSystem
( CoordinateSystem(..)
, standardCartesian
, standardCylindrical
, standardSpherical
, newCoordinateSystem
)
where
import Physics.Learn.Position
( Position
, cartesian
, cartesianCoordinates
, cylindrical
, cylindricalCoordinates
, spherical
, sphericalCoordinates
)
data CoordinateSystem
= CoordinateSystem { toPosition :: (Double,Double,Double) -> Position
, fromPosition :: Position -> (Double,Double,Double)
}
standardCartesian :: CoordinateSystem
standardCartesian = CoordinateSystem cartesian cartesianCoordinates
standardCylindrical :: CoordinateSystem
standardCylindrical = CoordinateSystem cylindrical cylindricalCoordinates
standardSpherical :: CoordinateSystem
standardSpherical = CoordinateSystem spherical sphericalCoordinates
newCoordinateSystem :: ((Double,Double,Double) -> (Double,Double,Double))
-> ((Double,Double,Double) -> (Double,Double,Double))
-> CoordinateSystem
-> CoordinateSystem
newCoordinateSystem f g (CoordinateSystem tp fp)
= CoordinateSystem (tp . g) (f . fp)