]> gitweb.michael.orlitzky.com - spline3.git/blobdiff - src/Cardinal.hs
Begin overhauling the program to handle other tetrahedra. Main is
[spline3.git] / src / Cardinal.hs
index e4e9464e1bddef6ef57fd306d6423c8a707660d5..f62896f9f3615bef495c99e045857c4748a491ac 100644 (file)
@@ -5,19 +5,46 @@ data Cardinal = F
               | B
               | L
               | R
-              | T
               | D
+              | T
+              | FL
+              | FR
+              | FD
+              | FT
+              | BL
+              | BR
+              | BD
+              | BT
+              | LD
+              | LT
+              | RD
+              | RT
+              | FLD
+              | FLT
+              | FRD
+              | FRT
+              | BLD
+              | BLT
+              | BRD
+              | BRT
+              | I
+              | Scalar Double
               | Sum Cardinal Cardinal
               | Difference Cardinal Cardinal
               | Product Cardinal Cardinal
-              | ScalarProduct Double Cardinal
+              | Quotient Cardinal Cardinal
                 deriving (Show, Eq)
 
 instance Num Cardinal where
     x + y = Sum x y
     x - y = Difference x y
-    x * y = Sum x y
-    negate x = ScalarProduct (-1) x
+    x * y = Product x y
+    negate x = Product (Scalar (-1)) x
     abs x = x
     signum x = x
-    fromInteger _ = F -- Whatever.
+    fromInteger x = Scalar (fromIntegral x)
+
+instance Fractional Cardinal where
+    x / y   = Quotient x y
+    recip x = Quotient (Scalar 1) x
+    fromRational x = Scalar (fromRational x)