]> gitweb.michael.orlitzky.com - spline3.git/blob - src/Face.hs
src/Face.hs: don't import "Point" type members.
[spline3.git] / src / Face.hs
1 -- | The Face module just contains the definition of the 'Face' data
2 -- type and its two typeclass instances.
3 --
4 module Face (
5 Face(..),
6 center )
7 where
8
9 import Point ( Point, scale )
10
11 data Face = Face { v0 :: !Point,
12 v1 :: !Point,
13 v2 :: !Point,
14 v3 :: !Point }
15 deriving (Eq)
16
17 instance Show Face where
18 show (Face v0' v1' v2' v3') =
19 "Face:\n" ++
20 " v0: " ++ (show v0') ++ "\n" ++
21 " v1: " ++ (show v1') ++ "\n" ++
22 " v2: " ++ (show v2') ++ "\n" ++
23 " v3: " ++ (show v3') ++ "\n"
24
25 -- | Returns the center of the given face. Since a face is just
26 -- square, we can average the four vertices to find its center. This
27 -- is useful because the center of a face is always a vertex of a
28 -- tetrahedron.
29 center :: Face -> Point
30 center (Face v0' v1' v2' v3') =
31 (v0' + v1' + v2' + v3') `scale` (1/4)