From: Michael Orlitzky Date: Fri, 6 May 2011 20:37:52 +0000 (-0400) Subject: Add the counter-clockwise rotations (with respect to the x-axis) to the Cardinal... X-Git-Tag: 0.0.1~341 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=c88ec8e43960514d27a6368d864a68e07eb18e50;p=spline3.git Add the counter-clockwise rotations (with respect to the x-axis) to the Cardinal module. --- 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