]> gitweb.michael.orlitzky.com - spline3.git/blobdiff - src/Tetrahedron.hs
Fix the tetrahedron collision detection.
[spline3.git] / src / Tetrahedron.hs
index 73ed58863595cab2da3bd8a4a0e98cd2f5f69ad4..6c13f4bbb429f2a185cdd1eaae3a541f1b147cb8 100644 (file)
@@ -6,6 +6,7 @@ import Prelude hiding (LT)
 import Test.QuickCheck (Arbitrary(..), Gen)
 
 import Cardinal
+import Comparisons (nearly_ge)
 import FunctionValues
 import Misc (factorial)
 import Point
@@ -42,7 +43,10 @@ instance Show Tetrahedron where
 instance ThreeDimensional Tetrahedron where
     center t = ((v0 t) + (v1 t) + (v2 t) + (v3 t)) `scale` (1/4)
     contains_point t p =
-        (b0 t p) >= 0 && (b1 t p) >= 0 && (b2 t p) >= 0 && (b3 t p) >= 0
+      (b0 t p) `nearly_ge` 0 &&
+      (b1 t p) `nearly_ge` 0 &&
+      (b2 t p) `nearly_ge` 0 &&
+      (b3 t p) `nearly_ge` 0
 
 
 polynomial :: Tetrahedron -> (RealFunction Point)