module Cardinal
where
+import Prelude hiding (LT)
+
data Cardinal = F
| B
| L
x / y = Quotient x y
recip x = Quotient (Scalar 1) x
fromRational x = Scalar (fromRational x)
+
+-- | Rotate a cardinal direction counter-clockwise about the x-axis.
+ccwx :: Cardinal -> Cardinal
+ccwx F = F
+ccwx B = B
+ccwx L = T
+ccwx R = D
+ccwx D = L
+ccwx T = R
+ccwx FL = FT
+ccwx FR = FD
+ccwx FD = FL
+ccwx FT = FR
+ccwx BL = BT
+ccwx BR = BD
+ccwx BD = BL
+ccwx BT = BR
+ccwx LD = LT
+ccwx LT = RT
+ccwx RD = LD
+ccwx RT = RD
+ccwx FLD = FLT
+ccwx FLT = FRT
+ccwx FRD = FLD
+ccwx FRT = FRD
+ccwx BLD = BLT
+ccwx BLT = BRT
+ccwx BRD = BLD
+ccwx BRT = BRD
+ccwx I = I
+ccwx (Scalar s) = (Scalar s)
+ccwx (Sum c0 c1) = Sum (ccwx c0) (ccwx c1)
+ccwx (Difference c0 c1) = Difference (ccwx c0) (ccwx c1)
+ccwx (Product c0 c1) = Product (ccwx c0) (ccwx c1)
+ccwx (Quotient c0 c1) = Quotient (ccwx c0) (ccwx c1)
+
+-- | Rotate a cardinal direction clockwise about the x-axis.
+cwx :: Cardinal -> Cardinal
+cwx = ccwx . ccwx . ccwx