From 899320830ae421d98fd9cdc09468409350cd3715 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 5 Sep 2011 17:19:26 -0400 Subject: [PATCH] Use pattern matching in the 'center' function. Might speed things up? Add the Tetrahedron number to its show output. --- src/Tetrahedron.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Tetrahedron.hs b/src/Tetrahedron.hs index d468f0c..5b459fe 100644 --- a/src/Tetrahedron.hs +++ b/src/Tetrahedron.hs @@ -47,6 +47,7 @@ instance Arbitrary Tetrahedron where instance Show Tetrahedron where show t = "Tetrahedron:\n" ++ + " no: " ++ (show (number t)) ++ "\n" ++ " fv: " ++ (show (fv t)) ++ "\n" ++ " v0: " ++ (show (v0 t)) ++ "\n" ++ " v1: " ++ (show (v1 t)) ++ "\n" ++ @@ -55,7 +56,9 @@ instance Show Tetrahedron where instance ThreeDimensional Tetrahedron where - center t = ((v0 t) + (v1 t) + (v2 t) + (v3 t)) `scale` (1/4) + center (Tetrahedron _ v0' v1' v2' v3' _ _) = + (v0' + v1' + v2' + v3') `scale` (1/4) + contains_point t p = b0_unscaled `nearly_ge` 0 && b1_unscaled `nearly_ge` 0 && -- 2.43.2