X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FCardinal.hs;fp=src%2FCardinal.hs;h=c6f7e8f72a9bc112f81d052339971f4b027eaf01;hb=c88ec8e43960514d27a6368d864a68e07eb18e50;hp=f62896f9f3615bef495c99e045857c4748a491ac;hpb=33998c9e4eac925df771d224befc5c0974f877bf;p=spline3.git diff --git a/src/Cardinal.hs b/src/Cardinal.hs index f62896f..c6f7e8f 100644 --- a/src/Cardinal.hs +++ b/src/Cardinal.hs @@ -1,6 +1,8 @@ module Cardinal where +import Prelude hiding (LT) + data Cardinal = F | B | L @@ -48,3 +50,42 @@ instance Fractional Cardinal where 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