Creating Repeating Patterns on Polyhedra Ankur Nepalia August 2008 Department of Computer Science University of Minnesota Duluth 320, Heller Hall 1114, Kirby Drive Duluth, MN 55812 Phone: (218) 726 – 7607 Email: [email protected] Web: www.d.umn.edu/cs Creating Repeating Patterns on Polyhedra A Thesis Submitted to the faculty of The Graduate School of University of Minnesota by Ankur Nepalia In partial fulfillment of the requirements for The degree of Master of Computer Science August 2008 University of Minnesota This is to certify that I have examined this copy of a master’s thesis by Ankur Nepalia and have found that it is complete and satisfactory in all respects, And that any and all revisions required by the final examining committee have been made. Dr. Douglas Dunham ---------------------------------------Name of Faculty Advisor ---------------------------------------Signature of Faculty Advisor --------------------------------------Date GRADUATE SCHOOL Creating Repeating Patterns on Polyhedra A THESIS SUBMITTED TO THE FACULTY OF THE GRADUATE SCHOOL OF UNIVERSITY OF MINNESOTA By Ankur Nepalia IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE DEGREE OF MASTER OF SCIENCE August 2008 © Ankur Nepalia 2008 Acknowledgements I would like to take this opportunity to thank Dr. Douglas Dunham, my thesis advisor, for the invaluable help and support he has provided me throughout this thesis period. He is the one who was always there to help me through challenging situations. I am grateful for his invaluable guidance. I would also like to thank my committee members, Dr. Gary Shute and Dr. John Greene, for their time and suggestions. Thanks to the staff and faculty of Computer Science Department at UMD for their invaluable support. i Abstract Polyhedra can be considered to be three dimensional shapes bounded by a finite number of polygons called “faces.” A “net” of a polyhedron is a two dimensional figure consisting of a set of connected polygons, which when folded and joined properly along edges forms the three dimensional polyhedron. A “subnet” is a connected subset of the net. For any arbitrary polyhedron, a single connected net may not exist, but there will always be a collection of subnets that can be used to form the original polyhedron. Dr. Dunham’s research deals with creating repetitive patterns on surfaces of the polyhedra. A program to generate subnets of a polyhedron has already been implemented and Dr. Dunham has created a pattern on subnets of one specific polyhedron. The goal of this research has been to generalize the pattern creation algorithm to create repetitive patterns on subnets of any arbitrary polyhedron. We describe the algorithm developed and show some results. The current algorithm handles polyhedra with arbitrary polygon faces, thus improving on the previous pattern generation which only did triangular patterns. Thus the current collection of modules of subnet generation, centroid generation and pattern generation generalizes the pattern generation process. ii Table of Contents Acknowledgements ........................................................................................................ i Abstract............................................................................................................................. ii Table of Contents .......................................................................................................... iii List of Figures ................................................................................................................ iv Introduction ......................................................................................................... 1 Motivation ............................................................................................................ 2 Basic Terminology.............................................................................................. 4 Polygon ...................................................................................................... 4 Polyhedron ................................................................................................. 4 Polyhedron Net .......................................................................................... 5 Polyhedron Subnet .................................................................................... 6 Overview .............................................................................................................. 8 Subnet Generator ...................................................................................... 8 Centroid Generator .................................................................................... 8 Pattern Generator ...................................................................................... 9 Algorithms ......................................................................................................... 10 Centroid Generator Algorithm .................................................................. 10 Pattern Generator Algorithm .................................................................... 11 Symmetric Patterns .................................................................................. 11 Description ............................................................................................... 11 Pattern Generation Sequence.................................................................. 12 Implementation Details............................................................................. 14 Data Structures ........................................................................................ 14 Clipping Generator ................................................................................... 15 Clipping Generator Algorithm ................................................................... 16 Results and Conclusion ................................................................................... 17 Future Work....................................................................................................... 20 References ........................................................................................................ 21 iii List of Figures Figure 1: Net of a Pyramid ................................................................................. 5 Figure 2: Net of a Tetrahedron........................................................................... 5 Figure 3: Eleven Nets of a Cube ........................................................................ 5 Figure 4: Example of an Ambiguous Net .......................................................... 6 Figure 5: Subnets of a Cube .............................................................................. 6 Figure 6: Subnets of a Pyramid ......................................................................... 6 Figure 7: Branko Grünbaum’s star-shaped ‘no net’ polyhedron ........................... 7 Figure 8: Patterned Octahedron Subnet ......................................................... 17 Figure 9: Patterned Pyramid Net ..................................................................... 18 Figure 10: Patterned Icosahedron Subnet ...................................................... 19 iv Introduction The goal of this research is to automatically map a single pattern onto each of the possibly different polygons of a net that can be used to construct a patterned polyhedron. A polyhedron (Poly = many) is a three dimensional figure, bounded by a finite number of polygons. The ‘net’ of a polyhedron is an arrangement of edge-joined polygons in the plane which can be folded (along edges) to become the faces of the polyhedron. Polyhedron nets are a useful aid in the study of polyhedra and solid geometry in general. A ‘subnet’ of a polyhedron is a subset of a net, containing some but not all of the faces of the polyhedron. Dr. Dunham has been doing research on generating repeating patterns on surfaces of polyhedra. This research is aimed at generalizing the pattern generation to work on polyhedral figures of any shape. The research also covers the issue of clipping polygons after the symmetrical patterns have been generated on the polyhedron figures. The following section explains the motivation behind the project. It is followed by definitions of some key terms used in this report. Next there will be an overview of the project which will be followed by the four main programs, the Subnet Generator, Centroid Generator, Pattern Generator and Clipping Generator. This will be followed by a description of and an implementation of the algorithms. Finally we will discuss the results and conclusions, followed by possible future work. 1 Motivation Polyhedra have been recognized and used by man since antiquity. According to Cromwell [7], they have been used in architecture, art, ornamental designs, etc. Some of the most basic examples in architecture are the Egyptian pyramids. Also, people have been using the concept of a net of a polyhedron as an easy way to construct three dimensional figures for a long time. Children often cut and fold paper to create three-dimensional figures. Nets are also used to study properties of a given polyhedron. Dr. Dunham’s research has been based on polyhedral nets. He has been working on generating repeating patterns on nets of polyhedra and visualizing them in three dimensions. As is explained later, it may be difficult to find a connected net for a polyhedron. However finding subnets (pieces of nets) is relatively easier. Although there have been programs to generate subnets of a polyhedron, they have been designed to produce only a fixed number of widely used polyhedra. Some examples of such programs are: Stella [9], Hypergami, Hedron and POLYDRON [10]. Kailash Aurangabadkar’s research work concentrated on removing these limitations on the choice of the polyhedron. He devised an algorithm [2] for generating subnets of any arbitrary polyhedron. The algorithm works by starting with a seed face (which can be arbitrary) and then adding as many surrounding faces as possible to this subnet. Then a new seed face is selected and the process is repeated until all the faces have been accounted for. The original polyhedron can be formed by joining all the subnets. My research work is focused on further aiding Dr. Dunham’s research by developing an algorithm to generate repeating patterns on these subnets, irrespective of the shape of the subnet and its constituent polygons. The current version of the algorithm works for pattern generation on any arbitrary polygon. 2 This was the limitation in Sameer Atar’s pattern generation algorithm [3], which only worked for triangular faces, that is to be taken care of in the current pattern generation algorithms. There is an intermediate Centroid Generator module added which takes care of the arbitrary shapes of polygons in the subnets. Given that the polyhedron has arbitrary polygon faces, the algorithm works on subnets of any polyhedron, irrespective of the shape of its constituent polygons. 3 Basic Terminology Polygon: In geometry a polygon is traditionally a plane figure that is bounded by a closed path or circuit, composed of a finite sequence of straight line segments. These segments are called its edges or sides, and the points where two edges meet are the polygon’s vertices or corners. A simple polygon (polygon whose edges do not cross) can be convex or concave. It is convex if any two points inside the polygon can be connected by a line segment that does not intersect any side of the polygon. A polygon is concave if at least one of its internal angles is greater than 180 degrees. Examples of polygons include triangles, rectangles, hexagons, pentagons etc. An example of concave polygon is a chevron. For our purpose we also require that a polygon be star-shaped with respect to the centroid of its vertices. That is, a line segment from the centroid to any interior point lies entirely within the polygon. Polyhedron: In geometry, a polyhedron is simply a three-dimensional (3D) solid which consists of a collection of polygons, usually joined at their edges. The plural of polyhedron is “polyhedra” or “polyhedrons”. Like a simple polygon, a simple polyhedron (faces do not intersect) can be convex or non-convex. If the line segment joining any two points of the polyhedron lies completely inside the polyhedron or on its surface, it is said to be a convex polyhedron, otherwise it is a non-convex polyhedron. Examples of polyhedrons include the cube, the tetrahedron, the octahedron etc. 4 Polyhedron Net: A net of a polyhedron is a two dimensional group of connected (edgejoined) polygons which can be folded up to form the original three dimensional polyhedron. The polygons are the faces of the polyhedron. Figure 1: Net of a Pyramid Figure 2: Net of a Tetrahedron Nets are not unique to a polyhedron. For example, there are a total of 11 distinct nets for the cube, the tetrahedron has 2 nets, the octahedron has 11 nets, while the dodecahedron and icosahedron each have 43380 possible nets. Figure 3: Eleven Nets of a Cube Further, it is possible to get different polyhedron shapes from the single net by folding it in different ways. It is important for a net to show which edges are to be joined or glued as one net can be folded up into different polyhedron possibilities. Figure 4 shows an ambiguous net, in which either edge ‘a’ or edge ‘b’ could be matched with edge ‘c’. 5 c a b Figure 4: Example of an Ambiguous Net Polyhedron Subnet: A subnet is a connected subset of a net or in other words a net is a subnet that includes all the polyhedron’s faces. A single (proper) subnet cannot form the complete polyhedron, whereas a group of subnets can be joined together to produce the original polyhedron. Such a group is called a ‘complete set of subnets’ if they contain no overlapping polygons. Figure 6: Subnets of a Pyramid Figure 5: Subnets of a Cube For any arbitrary convex polyhedron it is still uncertain if its net exists or not. Shephard conjectures that there exists a net for every convex polyhedron [6], but this is still unsettled as many examples of convex polyhedra with no known net can be found in [4] and [5]. 6 Figure 7 is a no-net polyhedron. Intuitively, the polyhedron cannot have a net because it has too many vertices with angle sums greater than 360 degrees. Figure 7: Branko Grünbaum’s star-shaped ‘no net’ polyhedron However every polyhedron does have a “complete set” of subnets. A complete set can be comprised of different subnets. A subnet can be either individual faces of the polyhedron or a group of faces. It is always desirable to create a “complete set” with as few subnets as possible because then the number of edges to be considered is fewer. 7 Overview The task of generating repeating patterns on faces of a polyhedron is accomplished by using three programs in succession. The first program is called the “Subnet Generator”. This is a modified version of Kailash’s program, which now outputs generated subnets to a file in a format that can be understood by the second program. The second program is called the “Centroid Generator” which is responsible for reading the output file generated by Subnet Generator and generating centroid points for each of the polygon faces of the subnets. The output file generated from the Centroid Generator is then passed to the “Pattern Generator” which is responsible for creating the repeating patterns on the subnets. Subnet Generator: The Subnet Generator accepts a file containing the description of the three dimensional polyhedron as input and generates output to a file containing a description of the generated subnets in a particular format. The details of the algorithm for subnet generation can be found in Kailash’s thesis paper [2]. The formats of the input and output files are described in the implementation section. This program displays the subnets on screen and creates a PostScript file. The program has been implemented in C and makes use of the ‘SPHIGS’ library to show the polyhedron in 3D. Centroid Generator: The Centroid Generator accepts the output file generated by the Subnet Generator, which contains the face count of the polyhedron and the coordinates of polygon faces of all the subnets. It then generates the centroid point for each polygon face and divides the polygon into triangular faces by connecting each polygon edge to the centroid point. Thus the generated output file contains all the polygon faces of the subnets divided into triangular faces with respect to the 8 centroid point of the respective polygons. The program has been implemented in C. Pattern Generator: The Pattern Generator accepts the subnet file generated by Subnet Generator as input and shows subnets with repeating patterns on them on the screen as output. It also creates a PostScript file of the “patterned subnet.” This program is basically a generalized version of the program written by Dr. Dunham for his research paper [1]. It is implemented in C and uses the X windows subsystem for graphical output. The PostScript file is created using a set of helper routines developed by Dr. Dunham and Dr. Shute. 9 Algorithms Centroid Generator Algorithm: 1. Open the Subnet Generator output file. 2. Read the first line from the file and store the face count of the polyhedron. 3. Do till the end of file is reached a. Read and store the x and the y co-ordinates of all the vertices of the current polygon face. b. Compute the polygon area using the formula Where: A = Area, N = Number of current polygon vertices. Xi and Yi are polygon coordinates. c. Now using the polygon area, compute the Centroid coordinates for the current polygon, using the formulas: d. Each of the polygon edges along with the centroid point form a triangle. The coordinates of each of these triangles are then stored in an output file in the same format as the output file of Subnet Generator file. 10 Pattern Generator Algorithm: Symmetric Patterns The pattern to be “drawn” on each face of the polyhedron is itself a polygonal pattern. In other words, the pattern is made up of a series of polygons drawn inside the boundaries of an equilateral triangle. Although the pattern can be of any arbitrary design, we generally choose symmetric patterns. By symmetry we mean that if two such patterned equilateral triangles are placed adjacent to each other, irrespective of which sides are adjacent, the patterns will appear to be “continuous” across the joining boundary. Putting it differently, if the common edge was made invisible, you would see a continuous pattern. By definition, the face of the polyhedron can be a polygon of any arbitrary shape. The current Pattern Generator algorithm works for any arbitrary shaped polygon. This is an extension to Sameer’s pattern generation algorithm which worked only for triangular shaped polygons. Description: The Pattern Generator algorithm is based on the use of geometrical transformations such as translation, rotation, scaling and shearing. The goal is to convert each of the given subnets into corresponding “patterned subnets”. Each subnet is a group of connected polygons which are further subdivided into a group of triangles about the centroid point. The subdivided triangles can be of any arbitrary shape. So if we take each individual triangle and draw our pattern on it, since the patterns are symmetric as mentioned above, we will get the desired “patterned subnet.” Now the pattern to be drawn is itself made up of polygons confined within boundaries of an equilateral triangle. However the triangle on which we want to ‘fit’ this pattern can be of any shape. Hence the original equilateral shaped 11 pattern has to be “stretched” correctly and applied to the given triangle. This stretching is performed by applying a series of geometrical transformations on the polygonal pattern. These transformations include translation, rotation, scaling and shearing. The main task of the algorithm then, is to find the sequence in which these transformations are to be applied and the values for each of these transformation matrices. Pattern Generation Sequence: 1. Consider a subnet of a polyhedron located at some place in 2D space. 2. For each triangle of the subnet of polygons which is located at some place in 2D space, a. Translate the triangle so that one of its vertices lies on the origin. b. Now rotate the triangle about the origin so that one of its sides, lies on the Positive X-axis and the third vertex lies above the X-axis. c. Now scale the triangle so that its width and height match those of an equilateral triangle. In other words, the width should become 1 and the height should become sqrt (3)/2. d. Now shear the triangle in the positive or negative X-direction so that its top vertex lies at midpoint of the base, but at height of sqrt (3)/2. Note: The current triangle has now been reduced to an equilateral triangle. Hence applying the inverse transformations in reverse order to our patterned equilateral triangle will yield the patterned given triangle. Pattern Generator Algorithm: 1. Read the set of subnets from the given input file. 2. For each subnet a. For each polygon (triangle) of the subnet 12 i. Let v1, v2, v3 be the vertices of the triangle. ii. Translate the triangle to the origin using its first vertex v1 as the vertex for translation. Now the triangle is pivoted at vertex v1. Let T_mat be the associated translation matrix. iii. Find the angle theta by which the triangle should be rotated so that its one side lies on the positive X-axis and the third vertex lies above the X-axis, in the following way 1. Take the cross product of side (v1, v2) with side (v1, v3). 2. If cross product is positive, (v1, v2) is the side which should lie on X-axis, otherwise (v1, v3) is the required side. 3. Find the angle theta made by chosen side with respect to Xaxis by using tan-1(y/x), where x and y are coordinates of the non-origin vertex of the chosen side. iv. Rotate the triangle by angle theta. Let R_mat be the associated rotation matrix. v. Now find the X and Y scale factors Sx and Sy by which the triangle needs to be scaled to bring it to the width and height of an equilateral triangle (i.e. width of 1 and height of √3/2) as follows – 1. Suppose (v1, v2) is the side resting on the X-axis. 2. Then Sx = 1/v1.x, Sy = (1 x 0.866667)/v1.y vi. Scale triangle by Sx and Sy. Let S_mat be the associated scaling matrix. vii. Find the shear factor ShX by which the triangle needs to be sheared in X direction to make it an equilateral triangle. ShY will always be 0. ShX is calculated as follows – 1. Suppose (v1, v2) is the side resting on the X-axis. 2. Then, x_top (x coordinate of vertex not on X-axis) = v3.x 3. x_mid (x coordinate of midpoint of (v1,v2)) = v2.x/2; 4. ShX = (x_top – x_mid)/ 0.866667. (Note: x should grow from 0 to (x_top – x_mid), when height y is 0.866667 and not when y is 1 (which is the usual case), hence division by 0.866667). viii. Shear the triangle by ShX. Let SH_mat be the associated shear transformation. 13 Note: We now have converted the given arbitrary shaped triangle into an equilateral triangle with one vertex at origin and one side on positive X-axis with third vertex in first quadrant. Our equilateral triangle with the pattern inside it now coincides with the given triangle. ix. Apply the inverses of all the transformations, in reverse order to this patterned equilateral. In other words, patterned ▲=T_mat-1(R_mat-1(S_mat-1(SH_mat-1(patterned equilateral ▲)))) Note: We now have the given triangle with the appropriately transformed pattern inside it. Implementation Details: The Pattern Generator program has been implemented in C on the Solaris platform. It accepts two files as input - the pattern file and the subnet file. The pattern file contains the pattern to be drawn. The subnet file is generated by the Subnet Generator which is further modified by the Centroid Generator to generalize the pattern generation on any arbitrary polygon face. The final output file contains the information and the coordinates of the generated subnets. The pattern is appropriately stretched and applied to each individual triangle of the subnet and the resulting “patterned subnet” is displayed on the screen. It is also written to a PostScript file. The PostScript files have a .ps extension and can be viewed using Adobe Acrobat or Ghost View software. Data Structures: “triad” This data structure represents a triangle and simply contains an array of three points. The point data structure is defined in the SPHIGS library. It contains the x,y,z coordinates of a point. 14 “arrTriads” This data structure is used to store all the triangles of a subnet. It is a 2dimensional array of six columns to store x, y coordinates of three vertices of a triangle in each row. The triangles of the subnet are read from the input subnet file and stored in this array. Later each triangle is packed into a triad object and is passed on for getting a pattern to be drawn onto it. “Transformation” This data structure represents the geometrical transformation to be applied to a given triangle. It contains a substructure called a matrix which holds the actual transformation matrix. It is a 4 x 4 array with the first row and column not being used (For compatibility with previous programs). Clipping Generator: The currently available pattern motifs all overlap the triangular region used to construct the repeating pattern, so the motif need to be clipped to that triangle. The Clipping Generator takes as input a data file which contains the description of the “motif” (= basic sub-pattern). The current algorithm uses an isosceles triangle as the clipping polygon. Each edge of the polygon is tested against each edge of the clip triangle. New edges are added and existing edges are discarded, retained or divided. The current method uses divide and conquer strategy which solves series of simple and identical problems which when combined solves the overall problem. 15 Clipping Generator Algorithm: 1. Read the input file name which contains the information about the polyhedron vertices and the motif. Note: The algorithm accepts a series of polygon vertices from V1, V2 …., Vn. In 2D, the vertices define polygon edges from Vi to Vi+1 and from Vn to V1 . 2. For each polygon edge, the algorithm clips against a single, infinite clip edge and outputs another series of vertices defining the clipped polygon. • Three cases are examined i. When the polygon edge is completely inside the clip boundary. One vertex is added to the output list of vertices that now define the clipped polygon. ii. Edge intersects the boundary. Depending on the type of intersection either one or two vertices are added to the output list of vertices that now define the clipped polygon. iii. Both vertices are outside the boundary. No output vertex is added. 3. Then the clipping polygon is rotated -60 degrees, repeat step 2. 4. Then the clipping polygon is again rotated to 120 degrees, repeat step 2. 5. All the final coordinates of the polygon are printed to an output file which describes the clipped pattern. 16 Results and Conclusions Figure 8: Patterned Octahedron Subnet Figure 7 shows one subnet of an octahedron. The triangular faces of the octahedron are further divided into smaller triangles with respect to the centroid of the triangles. Each triangle is then fed to the Pattern Generator which results in a patterned polyhedron subnet. 17 Figure 9: Patterned Pyramid Net Each polygon face of the pyramid is converted to adjacent triangles with respect to the centroid point of that face. Then the Pattern Generator applies the butterfly triangular pattern to each of the input triangles of the polyhedron. 18 Figure 10: Patterned Icosahedron Subnet Figure 9 shows one subnet of an icosahedron. Two such subnets form the whole icosahedron. The algorithm has been successfully implemented and works as expected on various polyhedra as shown above. So given a polyhedron, the Centroid and Pattern Generator are able to apply repeating pattern to its subnets effectively. 19 Future Work Dr. Dunham would like to be able to visualize the patterned polyhedron in three dimensions. The Current implementation is limited to displaying patterns on two dimensional subnets. The SPHIGS library could be used to display the ‘patterned’ polyhedron in three dimensions. Another major feature that can be implemented is coloring the patterns as symmetrically is possible. By this we mean that, when a part of the pattern extends onto the adjoining polygon, we would like the color on both halves of the pattern to be the same. This is more difficult than it appears. First of all, such coloring may not always be possible. Secondly, the coloring should work for any pattern. Hence the coloring algorithm would need the pattern and information about how a single pattern is to be colored. It would then need to detect incomplete polygons around the edges of the bounding polygon and then decide how the adjoining polygon should be colored. 20 References [1] Douglas Dunham, “168 Butterflies on a Polyhedron of Genus 3”, Bridges 2002 Conference Proceedings, July 2002, Baltimore, Maryland, pp. 197-204. ISBN 0-9665201-4-9 [2] Aurangabadkar, K., “Generating subnets for polyhedra,” Computer Science Thesis, University of Minnesota, Duluth 2004 [3] Sameer Atar, “Generating repeating patterns on subnets of a polyhedron” Computer Science Thesis, University of Minnesota, Duluth 2006 [4] Grünbaum, B. “No-Net Polyhedra”, Geombinatorics 11, 43-48, 2001 http://www.math.washington.edu/~grunbaum/Nonetpolyhedra.pdf [5] Bern, M.; Demaine, E. D.; Eppstein, D.; and Kuo, E. "Ununfoldable Polyhedra," Proc. 11th Canadian Conference on Computational Geometry, 1316, 1999. http://arxiv.org/abs/cs.CG/9908003/ [6] Shephard, G. C. "Convex Polytopes with Convex Nets," Math. Proc. Camb. Phil. Soc. 78, 389-403, 1975. [7] Cromwell, P., Polyhedra, 1-4, Cambridge, 1997. [8] Computer Graphics: Principles and Practice in C, 2/E. ISBN-10: 0201848406 Publisher: Addison-Wesley Professional. Basic Raster Graphics Algorithms for Drawing 2D Primitives. [9] Webb, R. “Stella: Polyhedron Navigator”, preprint, to appear in journal “Symmetry: Culture and Science”. http://home.connexus.net.au/~robandfi/PolyNav/PolyNavigator.html 21 [10] Eisenberg, M., Nishioka, A. “Creating Polyhedral Models by Computer.” Journal of Computers of Mathematics and Science Teaching, 1997. Websites: http://mathworld.wolfram.com http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/ 22
© Copyright 2026 Paperzz