From: Michael Orlitzky Date: Tue, 25 Oct 2011 20:21:17 +0000 (-0400) Subject: Add comments to the effect that some functions are only used in tests. X-Git-Tag: 0.0.1~83 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=35bc3798d28ed65ab970cf158082bf8d68e2c480;p=spline3.git Add comments to the effect that some functions are only used in tests. Minor whitespace changes. --- diff --git a/src/Comparisons.hs b/src/Comparisons.hs index 3bf4e24..58a5747 100644 --- a/src/Comparisons.hs +++ b/src/Comparisons.hs @@ -21,17 +21,32 @@ epsilon = 0.0001 theta :: Double theta = 0.0000000000001 + -- | x almost equals y if x is within 'theta' of y. +-- +-- Only used in tests. +-- nearly_equals :: Double -> Double -> Bool -nearly_equals x y = (abs (x - y)) < theta +nearly_equals x y = + (abs (x - y)) < theta + -- | Nearly greater-than or equal-to. +-- +-- Only used in tests. +-- nearly_ge :: Double -> Double -> Bool -x `nearly_ge` y = (x > y) || (x `nearly_equals` y) +x `nearly_ge` y = + (x > y) || (x `nearly_equals` y) + -- | x almost equals y if x is within 'epsilon' of y. +-- +-- Only used in tests. +-- almost_equals :: Double -> Double -> Bool -almost_equals x y = (abs (x - y)) < epsilon +almost_equals x y = + (abs (x - y)) < epsilon infix 4 ~= (~=) :: Double -> Double -> Bool @@ -41,11 +56,14 @@ infix 4 ~= -- | Like 'almost_equals', except much more tolerant. The difference -- between the two arguments must be less than one percent of the sum -- of their magnitudes. +-- +-- Only used in tests. +-- kinda_equals :: Double -> Double -> Bool kinda_equals x y = - (abs (x - y)) < threshold - where - threshold = ((abs x) + (abs y)) / 100.0 + (abs (x - y)) < threshold + where + threshold = ((abs x) + (abs y)) / 100.0 infix 4 ~~= (~~=) :: Double -> Double -> Bool @@ -53,8 +71,12 @@ infix 4 ~~= -- | x is very positive if it is 'epsilon' greater than zero. +-- +-- Only used in tests. +-- very_positive :: Double -> Bool -very_positive x = x - epsilon > 0 +very_positive x = + x - epsilon > 0 -- | Takes a list of 'Double' and returns the ones which are not very diff --git a/src/Tetrahedron.hs b/src/Tetrahedron.hs index 670a6e0..4c7abed 100644 --- a/src/Tetrahedron.hs +++ b/src/Tetrahedron.hs @@ -71,6 +71,7 @@ instance ThreeDimensional Tetrahedron where center (Tetrahedron _ v0' v1' v2' v3' _) = (v0' + v1' + v2' + v3') `scale` (1/4) + -- contains_point is only used in tests. contains_point t p0 = b0_unscaled `nearly_ge` 0 && b1_unscaled `nearly_ge` 0 &&