X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FFace.hs;h=bc316a72cee9ae4eb815424b2ccbfe8705316911;hb=6985f184b560c21139209e5cc9fd0eaf4a51715c;hp=3f1c223e10b3d28516c1c052fe4532f96633adf0;hpb=3cba7ca0c0b39cfd132a3b6ee255c377041cefb5;p=spline3.git diff --git a/src/Face.hs b/src/Face.hs index 3f1c223..bc316a7 100644 --- a/src/Face.hs +++ b/src/Face.hs @@ -1,13 +1,16 @@ +-- | The Face module just contains the definition of the 'Face' data +-- type and its two typeclass instances. module Face + ( Face(..) ) where import Point import ThreeDimensional -data Face = Face { v0 :: Point, - v1 :: Point, - v2 :: Point, - v3 :: Point } +data Face = Face { v0 :: !Point, + v1 :: !Point, + v2 :: !Point, + v3 :: !Point } deriving (Eq) instance Show Face where @@ -17,7 +20,16 @@ instance Show Face where " v2: " ++ (show (v2 f)) ++ "\n" ++ " v3: " ++ (show (v3 f)) ++ "\n" +-- | The 'Face' type is an instance of 'ThreeDimensional' so that we +-- can call the 'center' function on it. This is useful because the +-- center of a face is always a vertex of a tetrahedron. instance ThreeDimensional Face where + -- | Since a face is square, we can just average the four vertices + -- to find the center. center f = ((v0 f) + (v1 f) + (v2 f) + (v3 f)) `scale` (1/4) - -- Too lazy to implement this right now. + + -- | It's possible to implement this, but it hasn't been done + -- yet. A face will contain a point if the point lies in the same + -- plane as the vertices of the face, and if it falls on the + -- correct side of the four sides of the face. contains_point _ _ = False