From: Michael Orlitzky Date: Mon, 5 Sep 2011 21:19:26 +0000 (-0400) Subject: Use pattern matching in the 'center' function. Might speed things up? X-Git-Tag: 0.0.1~158 X-Git-Url: http://gitweb.michael.orlitzky.com/?p=spline3.git;a=commitdiff_plain;h=899320830ae421d98fd9cdc09468409350cd3715 Use pattern matching in the 'center' function. Might speed things up? Add the Tetrahedron number to its show output. --- 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 &&