From: Michael Orlitzky Date: Wed, 24 Aug 2011 16:40:43 +0000 (-0400) Subject: Remove the x_coord, y_coord, and z_coord functions from Point. X-Git-Tag: 0.0.1~222 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=603d9155a29bfbc353b42a6c880edce224626a16;p=spline3.git Remove the x_coord, y_coord, and z_coord functions from Point. --- diff --git a/src/Cube.hs b/src/Cube.hs index 2878eb0..6263d2e 100644 --- a/src/Cube.hs +++ b/src/Cube.hs @@ -116,13 +116,13 @@ instance ThreeDimensional Cube where -- | It's easy to tell if a point is within a cube; just make sure -- that it falls on the proper side of each of the cube's faces. - contains_point c p - | (x_coord p) < (xmin c) = False - | (x_coord p) > (xmax c) = False - | (y_coord p) < (ymin c) = False - | (y_coord p) > (ymax c) = False - | (z_coord p) < (zmin c) = False - | (z_coord p) > (zmax c) = False + contains_point c (x, y, z) + | x < (xmin c) = False + | x > (xmax c) = False + | y < (ymin c) = False + | y > (ymax c) = False + | z < (zmin c) = False + | z > (zmax c) = False | otherwise = True diff --git a/src/Point.hs b/src/Point.hs index a92041e..2b8d597 100644 --- a/src/Point.hs +++ b/src/Point.hs @@ -8,15 +8,6 @@ import Comparisons type Point = (Double, Double, Double) -x_coord :: Point -> Double -x_coord (x, _, _) = x - -y_coord :: Point -> Double -y_coord (_, y, _) = y - -z_coord :: Point -> Double -z_coord (_, _, z) = z - instance Num Point where (x1,y1,z1) + (x2,y2,z2) = (x1+x2, y1+y2, z1+z2) (x1,y1,z1) - (x2,y2,z2) = (x1-x2, y1-y2, z1-z2) @@ -33,15 +24,8 @@ scale (x, y, z) d = (x*d, y*d, z*d) -- | Returns the distance between p1 and p2. distance :: Point -> Point -> Double -distance p1 p2 = +distance (x1, y1, z1) (x2, y2, z2) = sqrt $ (x2 - x1)^(2::Int) + (y2 - y1)^(2::Int) + (z2 - z1)^(2::Int) - where - x1 = x_coord p1 - x2 = x_coord p2 - y1 = y_coord p1 - y2 = y_coord p2 - z1 = z_coord p1 - z2 = z_coord p2 -- | Returns 'True' if p1 is close to (within 'epsilon' of) p2, diff --git a/src/Tetrahedron.hs b/src/Tetrahedron.hs index eefbe11..73ed588 100644 --- a/src/Tetrahedron.hs +++ b/src/Tetrahedron.hs @@ -223,18 +223,10 @@ vol_matrix t = (4><4) y1, y2, y3, y4, z1, z2, z3, z4 ] where - x1 = x_coord (v0 t) - x2 = x_coord (v1 t) - x3 = x_coord (v2 t) - x4 = x_coord (v3 t) - y1 = y_coord (v0 t) - y2 = y_coord (v1 t) - y3 = y_coord (v2 t) - y4 = y_coord (v3 t) - z1 = z_coord (v0 t) - z2 = z_coord (v1 t) - z3 = z_coord (v2 t) - z4 = z_coord (v3 t) + (x1, y1, z1) = v0 t + (x2, y2, z2) = v1 t + (x3, y3, z3) = v2 t + (x4, y4, z4) = v3 t -- | Computed using the formula from Lai & Schumaker, Definition 15.4, -- page 436.