March 26, 2003 Geometric puzzles: The Snafooz puzzle which is a kind of a jigsaw puzzle without a picture. You are given six rectilinear cutouts from a 6x6 square; the goal is to interlock them so as to form a cube. Would like to write a program to solve the puzzle. What is a good representation? One can represent each piece as a polygon. A polygon is a closed figure in the plane with 3 or more sides. DETOUR Representing polygons. We can lay the polygon in the plane. Identify each vertex by a 2-D coordinate (x,y). Will the list of vertex coordinates identify the polygon? No, there are multiple ways to connect them. A clockwise (or counterclockwise) list of vertices identifies the polygon. Computational Geometry: Problems dealing with shapes, geometric objects, 2-D, 3-D, and even higher dimensions. Applications in computer graphics, robotics, VLSI design, computer vision, etc. Interesting questions: -- Do two line segments intersect? -- Is a given point inside a given polygon? -- What is the area of a figure in the plane? -- What is the volume of a 3-D object? -- Convex hull of a set of points? Answer to the second question: One simple way to find whether a point is in a given polygon is to walk along a ray in a particular direction. If the number of intersections with the polygon edges is even, then the point is outside; otherwise the point is inside. One needs to be careful about intersecting at a vertex or brushing an edge of the polygon. Polygons (in fact, any closed shape) can be divided as convex and non-convex polygons. In a convex polygon, the line joining any two points inside the polygon is completely contained in the polygon. END DETOUR A better representation for the Snafooz puzzle blocks is to store four lists, each list representing an edge. Each list, in turn, identifies which part of the edge is in the piece and which is not.