1 -- | The Face module just contains the definition of the 'Face' data
2 -- type and its two typeclass instances.
7 import ThreeDimensional
9 data Face = Face { v0 :: Point,
15 instance Show Face where
17 " v0: " ++ (show (v0 f)) ++ "\n" ++
18 " v1: " ++ (show (v1 f)) ++ "\n" ++
19 " v2: " ++ (show (v2 f)) ++ "\n" ++
20 " v3: " ++ (show (v3 f)) ++ "\n"
22 -- | The 'Face' type is an instance of 'ThreeDimensional' so that we
23 -- can call the 'center' function on it. This is useful because the
24 -- center of a face is always a vertex of a tetrahedron.
25 instance ThreeDimensional Face where
26 -- | Since a face is square, we can just average the four vertices
27 -- to find the center.
28 center f = ((v0 f) + (v1 f) + (v2 f) + (v3 f)) `scale` (1/4)
30 -- | It's possible to implement this, but it hasn't been done
31 -- yet. A face will contain a point if the point lies in the same
32 -- plane as the vertices of the face, and if it falls on the
33 -- correct side of the four sides of the face.
34 contains_point _ _ = False