using boolean operations to simulate cnc-milling · pdf file4.9 notes and comments ... sta is...

80
Diplomarbeit Using Boolean Operations to Simulate CNC-Milling Thomas Sch¨ uppel Matrikel–Nr. 178175 Berlin, 2001-04-28 Prof. Dr. G. M. Ziegler Technische Universit¨ at Berlin CNC-Milling is the process of machining physical objects from 2-d or 3-d digital information given by an NC-program. The programs created for execution on NC-machines are often faulty and need further debugging. This paper presents an algorithm to simulate the process of milling material out of a work- piece. The workpiece is approximated by a polyhedron and stored inside a Convex Difference Aggregate [20]. The algorithm performs a boolean difference operation on the Convex Differ- ence Aggregate. Successive operations allow the simulation of even complex NC-programs. The algorithm is compared to other algorithms that solve the same problem. The algorithm presented is robust and is implemented and used inside the STA milling simulation [27].

Upload: vominh

Post on 16-Mar-2018

217 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

Diplomarbeit

Using Boolean Operations to Simulate

CNC-Milling

Thomas Schuppel

Matrikel–Nr. 178175

Berlin, 2001-04-28

Prof. Dr. G. M. ZieglerTechnische Universitat Berlin

CNC-Milling is the process of machining physical objects from 2-d or 3-d digital informationgiven by an NC-program. The programs created for execution on NC-machines are oftenfaulty and need further debugging.This paper presents an algorithm to simulate the process of milling material out of a work-piece. The workpiece is approximated by a polyhedron and stored inside a Convex DifferenceAggregate [20]. The algorithm performs a boolean difference operation on the Convex Differ-ence Aggregate. Successive operations allow the simulation of even complex NC-programs.The algorithm is compared to other algorithms that solve the same problem. The algorithmpresented is robust and is implemented and used inside the STA milling simulation [27].

Page 2: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

Acknowledgements

I would like to thank Prof. Gunter Ziegler for letting me work on this topic although I studycomputer science. I have to thank for his patience, support and many answers to my ques-tions.Thanks to the STA GmbH and especially Bernd Ramer for their assistance and help in real-izing the implementation.Im am also much obliged to Frank Gaebler and Axel Friedrich for sharing their ideas withme and helping me over the many decisions I had to make on the way.Last not least I wish to express my thanks to my proof readers Ilja Radusch, Frank Gaeblerand Axel Friedrich.

Page 3: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

Die selbststandige und eigenhandige Anfertigung versichere ich an Eides statt.

Berlin, den 30. April 2001

Thomas Schuppel

Page 4: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling
Page 5: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

Contents

1 Introduction 1

2 Previous Work 7

2.1 Complete Boundary Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.2 The Intersecting Ray Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2.3 Other Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

3 The Convex Difference Aggregate 15

3.1 Facet Bindings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

4 Intersection of Convex Polytopes 21

4.1 The Space Sweep Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

4.1.1 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

4.1.2 Notes and Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

4.2 Intersecting Halfspaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

4.3 Linear Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

4.4 The Quickhull Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

4.4.1 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

4.5 Computing the Facet Bindings . . . . . . . . . . . . . . . . . . . . . . . . . . 39

4.6 The Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

4.7 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

4.8 The Evils of Floating Point Numbers . . . . . . . . . . . . . . . . . . . . . . . 43

4.9 Notes and Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

5 Working on the CDA 45

Page 6: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

vi CONTENTS

5.1 Rendering the CDA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

5.1.1 The Stencil Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

5.1.2 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

5.2 Collision Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

6 The Implementation 49

6.1 Package Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

6.2 Static Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

6.3 Class Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

7 Analysis and Results 53

7.1 The Simple CNC Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

7.2 The Complex CNC Program . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

7.3 The Wave CNC Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

8 Future Work 61

8.1 Getting Rid of Zero Cells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

8.2 Exporting a Polyhedron . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

9 Conclusion 65

A Color Slides 67

B Deutsche Zusammenfassung 69

Page 7: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

Chapter 1

Introduction

Computer Numerically Controlled (CNC) milling is the process of machining physical objectsfrom 2-D or 3-D digital information. The objects to produce are usually generated by Com-puter Aided Design (CAD) software. The process of CNC milling is a two step procedure.The first step is called toolpathing. It is the process of translating the 3-d or 2-d computermodel, that is created by the CAD system, into a series of ’paths’ for the CNC mill-bit tofollow as it excavates the model from a block of raw material. This step is usually performedby a Computer Aided Manufacturing (CAM) software. The ’paths’ are given in form of anNC-program. An NC-program is a program that consists of small commands to the machine.These include linear- and circular movements, tool changes as well as changes in the rotationspeed of the tool.The second step of the procedure is the actual machining, which involves translating the toolpaths into elemental commands. According to these, the small ’stepper’ motors in the millingmachine move the head of mill incrementally in the X, Y and Z directions.We distinguish between three-axis milling and five-axis milling. As the name suggests, thesimpler three-axis milling machines, allow to move the milling tool in 3 axes. Therefore, it isonly able to work on the surface of the workpiece. In five-axis milling the tool can additionallybe rotated around two axes. Rotations around the third axis are obsolete as it is the one, thetool spins around anyway.

Time on CNC-machines and their tools is expensive. The NC-programs entered into a machineare often faulty and need further debugging and verification. Doing this on the actual machineis expensive and may even result in destruction of the tools used. Therefore a software thatsimulates the behavior of such a machine is highly appreciated.

We present an algorithm for simulating the operations a machine performs on a 3-d workpieceduring the execution of an NC program. The algorithm is capable of simulating the operationsof a 5 axis mill. It is part of the CNC simulation toolkit released by the STA GmbH [27].STA is a software company that specializes in creating simulations for CNC-machines. Its3D Milling Center simulates a mill. It enables designers to simulate their NC-programsbefore they get into production. A 3-d model of the machine is described in the proprietaryfile-format, which bases on the Virtual Reality Markup Language [28].

The scope of this paper is the simulation of the milling operations performed on the workpiece.

Page 8: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

2 CHAPTER 1. INTRODUCTION

z

y

xspinning direction

ba

Figure 1.1: A tool and the 5 milling axes it can move on. The x, y and z-axis are forthree-axis-milling. In five-axis-milling, they are extended by the rotational a and b-axis.

Thus, the structures introduced are designed to suffice the needs of cutting objects out ofthem. In computational geometry, finding the difference, intersection and union of a pointset is known as boolean operations. In the chapter called ”Previous Work”, we will discussmultiple techniques to solve the problem. Most of them, as well as the technique this paperis focussed on, owe their functionality to the special data structures they store the objects in.Therefore, the edge between algorithm and data structure will sometimes blur.

Figure 1.2: An example picture of a small CNC milling machine with 5 axes.

This paragraph discusses the type of data that are excavated from the workpiece. Like mostCAM applications, STA approximates all objects by three dimensional polyhedra. The algo-rithms to simulate the milling operations, assume the polyhedra to satisfy certain assumptions.Because the polyhedron is three dimensional, its faces are described by two dimensional poly-

Page 9: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

3

gons. A polyhedron must be finite. The polygonal faces of the polyhedron must be convexand planar. Their vertices are stored in a counterclockwise order. However, the polyhedronitself may be concave.Some algorithms require additional information that, for example, allow to find the adjacent

Figure 1.3: Examples of a tool traces. The original pictures are in [12].

faces of a face. However the interface between the algorithms discussed here and the appli-cation was designed to be lean. Thus it does not hold any of these information. Instead, thedifferent implementations have to create their own specific structures.We will now detail the core data structures for objects in space.

A polyhedron is given byarray of verticesarray of polygonsbounding box

A vertex is given byspatial location (x,y,z)

A polygon is given byarray of references to verticesplane equation (normal vector, distance)

The tools of a machine are approximated by a set of convex polyhedra, represented by theirvertices and faces. The tool path is a curve in three dimensional space. It is generated bythe framework. From the tool path, the tool trace is generated. The tool trace is a set ofpolyhedra that approximates the volume, that the tool sweeps over. Throughout this paper,we will assume the tool traces as being approximated by a set of convex polyhedra.We will now briefly discuss a way of generating these tool traces. From the tool path which isgenerated from the NC-program, we sample some positions of the tool in space. A part of thetool trace is generated by combining two subsequent samples by their convex hull. Thereforethe tool trace is assembled by convex polyhedra intersecting each other. Since we computethe convex hull, the tools must themselves be convex or at least be assembled from convexobjects.The trace generation as explained here is quite simple. It is the details that are most difficult:Finding good positions for the sampling. Since this is not the scope of this paper we justsketch their computation. We observe that even long linear movements are approximated

Page 10: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

4 CHAPTER 1. INTRODUCTION

Tool Trace

Scene Graph

Application

Rendering Layer

Work Piece Model

Figure 1.4: The layers inside the nc-milling simulation. Shaded areas are the parts discussedin this paper.

perfectly by the convex hull of their end points. In contrary even short movements thatrotate the tool produce a high divergence of the convex hull from the actual path. Thus, wecalculate the angle offset of two positions of the tool. If this offset exceeds a certain limit,we will pick a sample and compute the convex hull. Once we generated a tool trace, we willsubtract it from the workpiece.Since the simulation is aimed to perform in real time, it does use floating point numbers torepresent the coordinates of points. The use of floating point numbers has a wide influenceon the design of the algorithms because creating a stable implementation using floats iscomplicated.

The simulation of the cutting has two main purposes. One is to enable the user to get animpression on how the workpiece will look during and after the simulation. The other oneis to perform additional tasks with the workpiece. These tasks include collision tests withmoving parts of the machine. Additional tasks are also exporting a workpiece some CAD- orCAM-system. For the first purpose, an image-space-only approach is sufficient. The secondone needs a geometric description of the workpiece and requires geometric calculations.The algorithm we present is a mixture between pure image space representation and realprocessing. It computes some - but not all - of the geometric calculations in real time anduses some image-space methods to “fake” the complete result. However, with some additionalcomputation done, it is able to compute the resulting polyhedra.

We will now focus on how the algorithm and data structures discussed in this paper areembedded in the simulation by the STA GmbH. As to be seen in figure 1.4, the milling appli-cation has different layers. A line of the nc-program is combined with the tool geometry andconverted into tool traces. These tool traces are subtracted from the workpiece. The machineis rendered. According to its transformations inside the machine, the changed workpiece isalso rendered. Different approaches for the representation of workpieces and hence booleanoperations can be included in the application by the simple workpiece interface. To be used,an implementation overrides the abstract class CstaWpModel. This class follows the patternof a prototype described in [10]. A prototype specifies the kinds of objects to create using aprototypical instance. It then allows the creation of new objects by copying this prototype.

Page 11: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

5

This enables the application to copy and use a workpiece model without actually knowinganything about it.In the following paragraph, we describe the different operations of this class that have to beoverridden by a workpiece model.

create(polyhedron c). Creates a workpiece. The contour of the workpiece is given by c.This is used to create an initial instance of the workpiece. It can be considered a virtualconstructor that is overridden by the concrete workpiece representation.

subtract(polyhedron p). This operation gets a polyhedron p. This polyhedron is sub-tracted from the workpiece. Hence, after the operation is performed, the statement c∩ p ⊆ ∅applies.

render. Renders the workpiece. This routine is OpenGL specific. Before is is called, atransformation matrix is entered into the OpenGL machine. Therefore the rendering of theworkpiece operates in a separate coordinate system which has its origin on the bottom of theworkpiece.

clone. Returns a new instance of the workpiece. This instance is an exact copy of theworkpiece. This method is used like a virtual copy constructor.

Let’s summarize this chapter. The objects we are dealing with are tree dimensional polyhedragiven by convex polygons on their surface. The part of the simulation that is discussed in thispaper is initialized by a polyhedron which approximates the workpiece. During the simulation,polyhedra are subtracted from this initial one. The subtracted polyhedra are generated fromthe tool traces which themselves are generated from the NC-program and the tools geometry.

Page 12: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling
Page 13: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

Chapter 2

Previous Work

In this chapter we describe different approaches done to solve the problem described. Someof them are specifically designed to simulate the operations performed during CNC-milling,and some are not. While trying to give an overview, we also mention the current state andtry to point out advantages and disadvantages. As mentioned in the last chapter, we assumeall entities that are handled to be approximated by flat surfaced objects.

2.1 Complete Boundary Evaluation

Many algorithms approach the problem in a straitforward way. The polyhedra are givenby their boundary. Hence the polyhedron defined by the difference of two polyhedra canbe computed by performing boolean operations on their boundaries. Most of the algorithmssubtract a polyhedron from another, like this: They compute the contour of intersection. Thiscontour is composed of lines in the space. It divides the polyhedron into pieces that are partof the result and pieces that are not. The latter are dropped while the former are connectedtogether such that the resulting polyhedra evade. The problem with algorithms of this typeis, that they have problems whenever two faces touch but do not intersect. Unfortunately,detecting and handling these cases is not trivial, especially in an environment, with floatingpoint numbers. There are two general ways to handle them. The first one tries to adjust thesource polyhedra such that the degenerate cases do not occur at all. The second one tries toclassify them, and handle them separately. In the next paragraph, we will take a closer lookat one of the algorithms that do the latter.

We will now discuss the algorithm in [15] to compute the boundary of the resulting polyhedron.In short, the algorithm requires three steps: First subdivide all faces of both polyhedra, suchthat no face of P1 intersects any face of P2 and vice versa. Second, classify each face withrespect to the other polyhedron as INSIDE, OUTSIDE or BOUNDARY. Third, according tothe boolean operation performed, delete unnecessary faces from polyhedron P1 and P2 andmerge the remaining face sets to obtain the resulting polyhedron.

The algorithm assumes both incoming polyhedra P1 and P2 to be valid closed polyhedra withstrictly convex faces. In the following, we discuss the three steps in more detail:

Page 14: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

8 CHAPTER 2. PREVIOUS WORK

Subdivision. Given two faces A and B from P1 and P2 respectively we subdivide them suchthat no sub face intersects the other. This is the most time critical step of the algorithm.The intersecting of all face pairs performs in O(n2) worst case running time. However,we may greatly reduce this through hierarchical bounding box considerations.Two faces intersect, if a vertex of one lies in the interior of a face or edge of the other,or if an edge of one crosses an edge or face of the other. Due to the closeness of thepolyhedra, as the paper points out, faces that are coplanar do not intersect and canthus be ignored.If two non planar, convex faces intersect, they intersect in a connected straight linesegment. The algorithm explicitly distinguishes 17 cases of how two convex faces A andB may intersect and how A can be subdivided into smaller convex faces A1, ..., An, suchthat no face Ai intersects B.

vertexvertexvertex

vertexedgevertex

vertexfaceedge

vertexfacevertex

edgefacevertex

edgefaceedge

Figure 2.1: Examples for the 6 possible classes, how a line can intersect a convex polygon.

Classify. After subdivision, we classify each face uniquely as INSIDE, OUTSIDE or BOUND-ARY with respect to the other polyhedron. A face is classified INSIDE, if it has at leastone vertex which lies inside the other polyhedron. Similar, it is classified OUTSIDE, ifit has at least one vertex outside of the other polyhedron. All remaining faces lie strictlyon the boundary of the other polyhedron. We further classify these faces as SAME orOPPOSITE depending on the orientation of the face normal.To find out if a vertex is located inside or outside of a polyhedron, [15] uses a rayshooting algorithm. Through thoughtful flag-setting during the subdivision step andthe use of connectivity information for each polyhedron, we keep this time consumingcalculation to a minimum.

Merge. After we classified each face in the last step, constructing the resulting polyhedronfor a given boolean operation is simply a matter of selecting the right faces from bothpolyhedra. The tables 2.1 and 2.2 show, how this is done:

Unlike many similar algorithms, Laidlaw et. al. thoroughly classify and handle all non-generic cases which makes this algorithm relatively easy to implement. In combinationwith bounding box considerations, the performance is quite good even for complexcases. Nevertheless, in a floating point environment the subdivision and classificationsteps easily lead to numeric instabilities. A stable implementation is very difficult, ifnot impossible.

Page 15: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

2.2. THE INTERSECTING RAY MODEL 9

inside outside same oppositeP1 ∪ P2 no yes yes noP1 ∩ P2 yes no yes noP1 \ P2 no yes no yes

Table 2.1: Selecting P1s faces for output.

inside outside same oppositeP1 ∪ P2 no yes no noP1 ∩ P2 yes no no noP1 \ P2 yes no no no

Table 2.2: Selecting P2s faces for output.

2.2 The Intersecting Ray Model

Have you ever pressed your hand into a needle picture? It is a small squared boardwith holes in it. Each of the holes, bears a spike that can slide up and down init. When you press your hand into it, you get a 3-dimensional image of your handmodeled by the spikes. The data structure we encounter now is almost like one ofthese needle beds.

The intersecting ray model (IRM), described in [3] bases on a height grid that was usedfor very early simulations of milling and also for displaying landscapes. A height gridsolely consists of a grid of voxels that are all heading in the same direction. A landscapeevades through different lengths of these voxels. A hill is modeled by some higher voxelswhile a valley would consist of some very low voxels. If you create a black and whitebitmap of the grid, where white pixels mark high voxels, you get a physical map of thelandscape.As a matter of fact these models are monotone in the direction of the voxels. That

makes them perfect to render landscapes and other objects that do have a monotonesurface. Apparently this simple model can only be used for three axis milling where thetool is unable to “cut behind“ the top surface. For more complex operations in 5 axismilling, they are not sufficient. In the following paragraph, we discuss the necessaryenhancements.To cope with cutting behind the surface, the IRM uses rays (or voxels) arranged onthree grids instead of one. Usually these grids are on the YZ-, XZ and XY-plane. Therays of a grid point orthogonal away from its plane. They are aligned such that the raysof the individual grids intersect and form a spatial grid by their intersection points. Weuse this grid for the extrapolation of the polygonal data, as we see later.A needle N is represented by the rays origin O = (u, v);u, v ∈ Z on the grid and a setof point sets Pts(N) = P0, P1, ..., Pn;n ∈ N. Pts(N) contains contains disjoint setsof points Pi = [ai, bi]; a, b ∈ R+, i ∈ 0, 1, ..., n on the ray. Thus, we denote a needle byN = O;P0, P1, ..., Pn. The rays direction is the same for all needles in the grid andtherefore won’t be stored in N . The union ∪(P0, P1, ..., Pn) of the point sets correspondsto the rays intersection with the object (the workpiece). For a convex object this is a

Page 16: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

10 CHAPTER 2. PREVIOUS WORK

Figure 2.2: A height grid. The vertices are lifted up where high values exist in the heightmap.

single interval on the ray. Usually the workpiece isn’t convex and therefore the needleholds multiple disjoint intervals.A boolean difference operation between two intersecting ray models is performed asfollows: every needle N ′ is intersected with the corresponding needle N ′′ of the secondIRM.The description given does solely explain how we can intersect two models of the IRM-representation. As the tool traces are given in form of polytopes, we need to “scan”them into an IRM first. This is performed by 3-dimensional scan line-transformation.It is much like the classic algorithm for rendering a polygon in 3-D described in [8]. Letus take a quick look at it. The scanning is performed independently for each grid. Weiterate over the facets. For each facet we calculate the rays that intersect its vertices.For these rays, we open an interval to the inside of the tool trace. Now we interpolatethe u,v and values of the ray between these corners to tag all rays with our intervalopening. In a post processing, we then intersect each rays the open intervals. As thepolytope we transformed into the IRM-space is bounded, the resulting intervals on therays are also bounded.The structure of the IRM is different from anything that we straightforwardly are able

to render. We know how to render polygons given by their vertices but how do we renderintervals on rays? A procedure that generates quite good results is a technique knownas the marching cubes [16]: The algorithm iterates over the 3-dimensional grid. Eightadjacent vertices in the grid form a cube. A vertex of this cube can be solid (inside theobject) or void (outside). There are 256 possible combinations, which after symmetricalobservations, reduce to 15 possible cases sketched in figure 2.3. For each of these cases,

Page 17: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

2.2. THE INTERSECTING RAY MODEL 11

Figure 2.3: The 15 classes of combinations, the marching cubes algorithm does distinguishbetween. The algorithm classifies each cube of 8 vertices and generates a fragment of thepolygonal surface as depicted. Blue spheres denote vertices that are tested as inside theobject. Green arrows denote the direction of normals of the faces, that are generated. Thepicture was copied from [25].

we define the set of polygons to draw. In a post processing step the polygons are shiftedand stretched to resemble the real position of the boundary between the two points ofthe grid. We calculate this position for the values of the interval-borders we store in theneedle. The needles of the X-Y-grid are used to shift the vertices in Z-direction. Theneedles of the X-Z-grid are used to shift in Y-direction and so on.In my order, the IRM is the best structure available for the specific problem. Because ofthe (almost) discrete structure of the IRM, boolean operations are totally robust. Theyare also very fast. Using the marching cubes or a similar technique, the rendered IRMlooks quite well. However there are drawbacks. The generation of the contour using themarching cubes is slow. The amount of memory needed to store the IRM is the squareof the precision of the grid. Thus the precision is limited to some extent. The staticdistribution of the needles disallows to render special regions in high detail.

Page 18: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

12 CHAPTER 2. PREVIOUS WORK

2.3 Other Techniques

BSP-Trees. A Binary Space Partitioning Tree is a binary tree. Everyone of its nodespartitions the space into two parts along a hyperplane. Objects are also partitioned oneither one of the sides. The tree recurses until only atomic objects remain.Whenever a face crosses one of the partitioning hyperplanes, it is cut into two faces.It we choose the partitioning planes to be the bounding ones of the convex polyhedronapproximating the workpiece, we generate a partitioning that already contains all in-formation necessary to perform boolean operations.Unfortunately, intersecting a face with a plane is similar to the problems we had to solvein the BRep approach. Still this approach may be used to improve the performanceof the algorithm, described in the first section of this chapter. However, generating aweighted BSP-tree in sufficient time is difficult. Hence there are no implementations ofthis idea.Anyhow a BSP tree could for example be used to accelerate the algorithm mentionedin 2.1.

Voxels. We touched it in 2.2. There are a lot of different techniques around, thatpartition the space into small discrete entities called voxels. Voxels are very popular inmedicine because they do not only resemble the surface but also the inside of the object.However a voxelization of the 3 dimensional space takes O(n3) space. Therefore, theprecision of voxel models is limited.Boolean operations on voxel-models are trivial: For each voxel, we decide if it is insideor outside the result of the operation. Unfortunately, the voxels are usually storedcompressed to work against the high needs for space. Performing boolean operations onthe compressed voxels is not that easy anymore. However, voxels provide an interestingapproach, that has not yet been fully examined for this specific application.

OpenGL Volumizer. The OpenGL Volumizer [22] is a package introduced by Sili-con Graphics. It partitions the space into tetrahedra and therefore may be consideredanother special voxel technique. However it does only run on Silicon Graphics hardwareand therefore does not provide a feasible solution to our problem.

Image Space Methods. Image space methods do not work on the the objects assuch. Instead, they do all the work, when the scene is being rendered. This means,every time, the system has to draw a pixel, it previously decides whether the pixel isvisible or not. This can be supported by the rendering hardware to some extent. How-ever there is no way to perform any operations that require the geometry of the object,simply because the geometry is not computed at all. This eliminates the possibility forcollision detection and similar tasks that are necessary inside a simulation system.Image space methods happen to be very fast as long as the number of intersections islow. However, they scale poorly as every face rendered needs to be checked againstevery face that may mask it. The number of faces climbs very fast, as every object,

Page 19: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

2.3. OTHER TECHNIQUES 13

that is for example subtracted, stays inside the scene forever.The method we are going to introduce in the next chapter is a combination of an imagespace method and the BRep approach.

Page 20: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling
Page 21: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

Chapter 3

The Convex Difference Aggregate

There’s as much difference between us and ourselves as between us and others.Michel de Montaigne, Essays, 1533-92

We now introduce the convex difference aggregate (CDA). The CDA is a structure tostore the difference of a containing convex polyhedron and other convex polyhedra insideit. Introduced by [20], its main purpose was computational solid geometry (CSG) mod-eling. CSG Modeling is used to construct complex objects by combining simple onesin set-theoretic operations. For example, the difference of two cylinders forms somekind of tube. For the person using a CSG-modeling system, fast feedback is essential.Therefore the CDA system is trimmed for interactive or almost interactive performance.During the simulation of an NC-program, there usually is no user interaction as far asthe boolean operations are concerned. Anyway, the aim is to create a simulation in realtime. Therefore fast boolean operations are a goal.The operations we perform in the simulation of milling are a subset of the ones neededfor CSG. Since the mill is only able to remove material from the workpiece, the onlyboolean set operation we need, is the difference.We now take a look at what the structure consists of. The only entities that form aCDA are convex polyhedra which we call polytopes in future. The word ”face” has aslightly different meaning in polytope theory, so we stick with calling them facets withinthis chapter. Convexity is a very strong assumption for polyhedra. It enables us to useeasier and clearer algorithms.The CDA is a container for cells. A cell is a convex polytope that has a particular charge.The CDA consists of positive, negative and zero charged cells. We now look at these cellsin detail. A CDA C is represented by a single positive cell Pos(C) = P , a set of nega-tive cells Neg(C) = N1, N2, ..., Nn and a set of zero cells Zero(C) = Z1, Z2, ..., Zz.Thus, we denote a CDA by C = P ;N1, N2, ..., Nn;Z1, Z2, ..., Zz.

A polytope is given by its vertices as points in 3-space and its facets. The facets of3-dimensional polytopes are polygons. We save these polygons as a counterclockwiseordered list of their vertices (or to be more precise: references to their vertices). Forlater use, we also store each facets normal and distance to the origin.Each polytope represents a point set. We call a point set of a polytope the set of allpoints inside and on the surface of it. Because a polytope is finite, the point set also

Page 22: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

16 CHAPTER 3. THE CONVEX DIFFERENCE AGGREGATE

Figure 3.1: A sample CDA.

is finite. Since the polytope is convex, the point set is convex, too. The point setrepresented by the CDA is the set difference of the point set represented by its posi-tive cell P and the union of the point sets represented by its negative cells N1, N2, ..., Nn.

C ≡ P\(N1 ∪N2 ∪ ... ∪Ni) (3.1)

A negative cell of the CDA can be considered a hole or concavity in the object. Thereby,all negative cells reside inside the positive cell. That implies, that their point sets arealways a subset of the point set of the positive cell.

Ni ⊆ P ∀Ni ∈ Neg(C) (3.2)

A zero cell represents the intersection of exactly two negative cells. Hence, in the worstcase, the number of zero cells equals the square of the number of negative cells.

Page 23: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

3.1. FACET BINDINGS 17

Figure 3.2: The negative cells of a CDA. Turquoise facets are bound up.

Zero cells solely exist to assist the rendering of the CDA. As far as the geometry isconcerned, the object is sufficiently described without them.We call a facet positive, if it is the facet of a positive cell. We will call it negative, ifit belongs to a negative cell and zero it bounds a zero cell. A facet always belongs toexactly one cell. Wherever two cells touch each other, there will be at least two facets:One for each cell.

3.1 Facet Bindings

We now describe facet bindings. These are used for rendering holes inside facets. A facetcan be bound down to multiple other facets. Areas of the facet, that are overlapped

Page 24: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

18 CHAPTER 3. THE CONVEX DIFFERENCE AGGREGATE

Figure 3.3: The zero cells of a CDA.

by facets it is bound down to, are masked. They will be invisible to the viewer of therendered scene.As we recall, a negative cell constitutes a hole in the positive cell and a zero cell is

the intersection of exactly two negative cells. Facets of two different cells can be boundtogether. Facet bindings are how holes and concavities in facets are represented usingCDA’s.If a facet is bound up to another facet, it means that it is a hole in that other facet.Each facet can be bound up to at most one other facet. Positive facets are never boundup. A facet is said to be bound down to another facet if that other facet is bound upto the original facet. A single facet can be bound down to many facets. This is to saythat a single facet can have many holes in it. The need for these facet bindings becomesclear in the later discussion of the rendering.Let’s remember, we want to use the CDA to simulate the operations performed by atool excavating material from a workpiece. As stated before, the path of the tool isapproximated by a set of polytopes. Hence, we need to subtract these polytopes fromthe workpiece. We chose a CDA to represent the workpiece. Therefore, we need todefine an operation, that subtracts a polytope from a CDA producing a new CDA, thatrepresents a point set that is disjoint to the point set represented by the polytope. We

Page 25: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

3.1. FACET BINDINGS 19

Figure 3.4: The positive top facet of the CDA. The negative facets, it is bound down arepainted black.

call this operation subtract. It is illustrated in algorithm 1. Whenever the result of an

Algorithm 1 The pseudocode for the subtract operation. It returns Cresult which is thepolytope S subtracted from a source CDA Csource

def subtractif Pos(Csource) ∩ S is not empty then

Pos(Cresult)← Pos(Csource)Zero(Cresult)← Zero(Csource)Neg(Cresult)← Neg(Csource)for all N ∈ Neg(Csource) do

if N ∩ S is not empty thenZ ← N ∩ Sfor all facets in Z, that are bound up do

add a downbinding to the corresponding facet in N or Send forZero(Cresult)← Zero(Cresult) ∪ Z

end ifend for

elseCresult ← Csource

end if

operation is not full-dimensional, we don’t perform any operations. Therefore we haveto detect these cases but don’t need to handle them. In practice these cases arise whenthe cutter touches a wall of the workpiece. An undefined ridge evades, that is unwantedby CNC machinists. Thus an NC-program generating such a case can be consideredfaulty.

The remaining work is to compute the intersection of two convex polyhedra. We willdiscuss this in the following chapter.

Page 26: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling
Page 27: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

Chapter 4

Intersection of Convex Polytopes

In this chapter, we discuss how to find the intersection of two convex polytopes. Unlikethe intersection of general polyhedra, the intersection of convex polytopes in threedimensions is an area discussed to some extent in computational geometry.We introduce two algorithms to compute the intersection. The first one mainly isdescribed because it constitutes a very interesting approach to the problem. It was notimplemented for some reasons mentioned later. The second algorithm is the one thatwas actually used to solve the problem. In the end of the chapter we mention otheralgorithms that do also solve this problem.Whenever we analyze an algorithm, we consider n to be the number of vertices. Sincemost computations are performed on objects that are combinatorially a planar graph,the number of faces and edges is linear to the number of vertices.

4.1 The Space Sweep Algorithm

A Leatherman combines almost any tool you may ever need in one handy form. Al-though it is just one tool, it has a thousand uses. The Leatherman of two-dimensionalproblems in computational geometry, is the plane-sweep. It is easy to understand, al-most grants a desirable running time of O(n log n) and easy to implement.

Unfortunately the paradigm of a plane sweep seems not to be extensible to 3-space thateasy. The algorithm by Hertel et al. described in [13] is one of the few algorithms inthree dimensions, using a space sweep. It computes the intersection of convex polytopesin O(n log n) running time, rendering it interesting for the problem we are discussingat the moment.We now briefly discuss plane sweeps which form the base for the space sweep we learnto know later. The first paper to explicitly use such a plane sweep was [24]. In it,Shamos used a sweep to solve a geometric problem. This paper is also considered theone, that initiated computational geometry. The name of plane sweeps algorithms isderived from their characteristic way of processing a figure in the plane: advancing astrait lined ”brush” from the top to the bottom. This brush never backs up and itdoes not look farther then to the next ”transition point”. Hence, the computationsperformed are strictly local.

Page 28: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

22 CHAPTER 4. INTERSECTION OF CONVEX POLYTOPES

In computational geometry, the edges of an object are often the most promising struc-tures to succeed in finding the result in adequate time. Therefore, it is not very surpris-ing, the authors chose to observe the edges of the resulting polytope. Let E be the setof edges in the resulting polytope P = P0∩P1. This set of edges consists of two subsetsE1 and E2. E1 is the set of line segments on the surface of both polytopes P0 and P1,while E2 is the set of edges that are edges or parts of edges of only one polytope. It isobvious that all edges have to be in either one of these subsets. As shown in figure 4.1,E1 is composed of connected components. In a more plastic view, it can be consideredthe contours of the edges where one polytopes border touches the others. As [13] states,

Figure 4.1: Two samples of intersecting bricks. Heavy lines are edges in E1. Dotted lines areedges in E2. The right sample depicts two independent components of E1 while the left oneshows only one connected component.

P can be computed in O(n) if at least one vertex of each of the components in E1 isknown. We now sketch the argumentation leading to that statement. Let S be the setof vertices for each component. Each s ∈ S is the intersection of at least 3 facets of theoriginal polytopes. It also resides on an edge of one of these polytopes. This edge is theintersection of two of the faces it resides on. We compute the resulting two intersectionsof the faces and get two edges for E1. We now tag all edges incident to s. The onesreaching inside one of the polytopes are obviously candidates for E2 while the ones wefound before, are members of E1. Off course, the new found edges have end points.These end points give us data to proceed on. Hence, we continue the steps above forthe new vertices until we have the entire components of E1. This computation can beperformed in O(n) for all elements of S.Finding E2 is done almost the same way. Because we already have got some candidatesfor E2 from the preceding computations, we now easily calculate the remaining verticeswith the method shown before. Again, this takes us O(n) running time.We still need to compute at least on point on each component of E1 to start our algo-rithm. Using a space sweep, we find points on the edge of one - and the surface of theother polytope for every component in E1.Plane-sweep algorithms operate by advancing a line trough the plane of the object.

Page 29: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

4.1. THE SPACE SWEEP ALGORITHM 23

Analogously, our space-sweep algorithm works a plane through space. The structure,that we maintain and create within our sweep, we call the crown. Symbolically, thecrown is a graph of edges. To generate it, we survey the plane while it intersects thetwo polytopes. The intersection of the sweep-plane with a polytope is obviously a con-vex polygon. We store this polygon and call its edges the base edges of the crown.Unlike the base edges, which have not been edges of the original polytope, the forwardedges are. They are the edges on top of the sweep plane, that intersect it. As a matterof fact, these edges all end in the vertices of the polygon of base edges. We also storethe prong-edges which interconnect the other ends of the forward edges. All these edgesform the crown which is the central data structure during the sweep. You can see acrown with its different edge types depicted in figure 4.2.We now construct two crowns, one for each polytope. Then we compute their intersec-

bb

b

b

f

f

f

f

f

p

p

pp

p

sweep-plane b

b

b

b

bb

b

p p

p

pp

p

f

f

f

f

f f

f

f

f

f

Figure 4.2: A crown. The different edge types are denoted by b, f and p. b are base edgeswhile forward edges are marked by a f and the prong by p. Right, you can see the crownprojected on the sweep plane.

tions as defined above. Remember, we can construct the complete contour, if we knowat least on point per component in E1. So what we are looking for are exactly thesepoints.

Lets start our sweep. We work through the joint vertices of the two polytopes P0 andP1 from top to bottom. For each vertex v, we update the crown Ci of the Polytopeit originally was a vertex of. This means, we update the crown C0 with v if and only

Page 30: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

24 CHAPTER 4. INTERSECTION OF CONVEX POLYTOPES

C1-i F

Figure 4.3: Although no edge of the facet F penetrates the crown C1−i, they intersect. C1−i

penetrates F . This intersection can only be found if the edges of a crown are tested againstthe facet.

if v is a vertex of P0. Otherwise, it must be a vertex of P1 and we update C1 withit. In the text following, we address the crown of a vertex by Ci and the crown of theother polytope by C1−i. If exactly one edge starts in v, we intersect it with the C1−i.Otherwise we know, that at least one facet starts in v. We now intersect all edges thatoriginate in v with C1−i. If we do not find any intersections, one of the facets may stillcompletely enclose an intersection contour. Figure 4.3 illustrates this case. To find thisparticular type of intersections, we chose a forward edge of C1−i and intersect it withall of the facets.Every time, we detect an intersection, we compute the vertex and add it to the solutionset. In the end of the algorithm (when the plane has swept over all of the vertices) wehave found at least one vertex of each component of E1. Algorithm 2 illustrates thetransition that is performed subsequently for all ordered vertices.

4.1.1 Analysis

We now briefly analyze the running time of the algorithm. As we already stated, weare able to compute the entire intersection contours in linear time if we know at leastone point on each component of E1. To find these points, we use a sweep. The sweeprequires us to sort the vertices of the polytopes in y-order. Sorting takes us at leastO(n log n) time. We obviously have to run the transition n times. There are two costs,we need to consider inside the transition. The first is the updating of the crown. Thesecond is the intersection of a line with the crown.We will now analyze the running time of the former. Let c be the maximum numberof forward edges before the transition and o = s + e be the number edges of starting

Page 31: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

4.1. THE SPACE SWEEP ALGORITHM 25

Algorithm 2 The Space Sweep Algorithm to find the intersection of polytopes.def transition( v, i )update crown Ci of polyhedron Pi

if only one edge e of Pi starts at v thenintersect e with C1−i of P1−i

add all intersections to set Selse

for all faces f of Pi that start in v doI ← intersection of the starting proper edges of f with the crown C1−i

if I ⊆ ∅ thenchose a proper forward edge ef of C1−i

I ← ef ∩ fS ← S ∪ I

elseS ← S ∪ I

end ifend for

end if

(s) and ending (e) in the new vertex v. If we store the cyclic structure of the crown ina balanced tree, we can locate the area of the tree that contains edges ending in v inO(log c) time. We then split the crown into two parts, one part left of the area we justlocated and the other one right of it. Splitting the crown along the outermost pathsagain takes O(log c) time. We then construct a new tree from the s edges that start inv. Constructing the tree takes us O(s) time. We then merge the trees together whichcosts O(log c) time, again. Thus, intersecting a line with a crown takes O(log c + s).Since c < n and the sum of all s’s over the polyhedron is O(n), the updating of a crowncan be computed in O(log n) time.We still need to prove that we are able to intersect a line with the crown in time O(log n).To stay below this margin we again need a tree-like structure for our data. We extendthe crown to a convex polyhedron by adding a face to its bottom. To [13] there is away of finding the intersection of this polyhedron and a line in time O(log n). All othersteps inside the transition routine can be performed in constant time. Therefore thealgorithm adds up to a total running time of O(n log n).

4.1.2 Notes and Comments

Sweep algorithms produce excellent solutions to many problems in computational ge-ometry. Again, I believe, the best explanation for this powerful technique is to be foundin [7].The algorithm we discussed needs a lot of information concerning the neighborhood ofedges and facets. To store these information, we use a data structure that is knownas the double connected edge list (DCEL). This structure centers on the edges of thepolytope and by that stores the neighborhood of facets. The DCEL depicts a planargraph and as proven in [7] and [30], the surface of a polytope in 3-space is always planar.The statement in the above section already indicates that although the algorithm itself

Page 32: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

26 CHAPTER 4. INTERSECTION OF CONVEX POLYTOPES

is short and clear, it builds on very complex structures to reach the desired runningtime. Especially the structures to compute the actual intersections in log n time arevery complex. The paper does not explicitly state how to handle special cases wherea line touches an edge or vertex. For all these reasons, we will abandon this algorithmand look for others in the following sections.

4.2 Intersecting Halfspaces

Sometimes it is a good practice to lean back, forget what you have already learnedand look at things from a different perspective. The French essayist and philosopherEmil-Auguste Chartier once stated in one of his aphoristic essays that ”Nothing ismore dangerous than an idea if it’s the only one you have”. Perhaps that sounds abit drastic, In our case it’s exactly that way. Trying to find the intersection of twopolytopes given by their vertices is very complicated. If you look at the polytope asthe intersection of halfspaces, things get a lot easier.

There is no disawing it: The algorithm in [13] solves our problem in an efficient way.Though it is practicable, it is hard to implement the complicated data structures itdepends on. Lets step back for a moment and look at the problem from a differentpoint of view.To [30], ”A polytope is a point set P ⊆ Rd which can be presented either as a v-polytopeor as an h-polytope.” All the time, we have been considering the polytopes to be definedby their vertices. In contradistinction to this representation, we now treat them as theintersection of halfspaces. The halfspaces building the polytope are bound by its facets.Hence they are easy to create from the data we already have. We define a point pto be below a plane (n, s) with the normal n and the distance s from the origin, ifthe inequality n · p ≤ s applies. For points inside the intersection of halfspaces, theinequalities of all of them must apply.In the world of halfspaces, the h-polytope that is created by the intersection of both ourpolytopes is easy to find. It simply is the intersection of the united halfspace of bothpolytopes. This reads easier than it actually is: Although the set of points that satisfyall inequalities is equivalent to the set of points of the intersection of the polytopes,there are a lot of inequations that do not influence the solution at all. They simplyare redundant. There are many reasons, these redundant halfspaces need to be foundand removed. An obvious one is, that the data generated by the algorithm over timewould be drowning in a quadratically rising swamp of irrelevant data. Besides, we stillhave to render to whole thing. The irrelevant halfspaces are bound by planes that areoutside the intersection of the polytopes. Painting them would render the polytopeitself invisible behind them. Hence, we do not only have to intersect the halfspaces. Wealso need to remove redundant ones. Additionally, we need to find the facets we needfor rendering. The next paragraph discusses, how this is done.Besides the two ways to present a polytope there is also an easy projection from theh-space into v-space and vice versa. It works as follows. An h-polytope defined by theintersection of halfspaces is polar to a polytope defined by the convex hull of the verticesdefined by the polar projection of the halfspaces. To [30], for any subset P ⊆ Rd, the

Page 33: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

4.3. LINEAR PROGRAMMING 27

polar set P4 is defined by

P4 := c ∈ (Rd)∗ : cx ≤ 1for all x ∈ P ⊆ (Rd)∗ (4.1)

The irrelevant halfspaces in primal space are vertices, that do not affect the convexhull in polar space. If we compute the convex hull of the polar halfspaces, and thentransform the hull back into primal space, we have gotten rid of all irrelevant halfspaces.Computing the convex hull in 3-space isn’t without problems, nither. Anyway, thereare some good algorithms and also some working implementations around. It’s alwaysgood to stick with something that has proven to work in a real environment, wherepossible. None knows what perils await you, when you implement an algorithm thatnobody implemented before.So lets take a closer look at this promising projection. It has one drawback. It dependson the origin being inside the polytope. Apparently we can not assume this to be thecase. We need to transform the polytope accordingly, before we project. What doesthis projection look like? It is the same projection as the one projecting any point tothe origin, whenever the point is located inside the polytope. So here is our next task:Find a point inside of the intersection of halfspaces.

4.3 Linear Programming

Finding a single solution to a set of linear inequalities is polynomial aquivalent to whatoperation researchers call linear programming. In linear programming, we search for aspecific solution that maximizes a given linear function within given constraints. Thefunction that we maximize is called the objective function. Combined with the con-straints, it is called a linear program. In a more mathematical way, a linear program ind dimensions is described as follows:

Maximize: c1x1 + c2x2 + ... + cdxd

Subject to: a1,1x1 + . . . + a1,dxd ≤ b1

a2,1x1 + . . . + a2,dxd ≤ b2

:an,1x1 + . . . + an,dxd ≤ bn

where ai,j , bi, ci ∈ R

As we already found out, the constraints can be viewed as halfspaces in Rd. We callthe intersection of these halfspaces, the feasible region of the linear program. A point isfeasible, if it is located in this region. Otherwise, it is infeasible. The objective functioncan be viewed as a direction in Rd. To our problem, it is irrelevant if the point ismaximal to some certain direction as long as it is inside the intersection. Hence, we justchoose a direction. If we want to maximize c1x1 + c2x2 + . . . + cdxd, we have to findthe point (x1, x2, ..., xd) that is extreme in the direction of the vector c = (c1, c2, ..., cd).Hence, we will use linear programming to find a point that is extreme in direction c andlocated in the polyhedron described by the constraints.

Page 34: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

28 CHAPTER 4. INTERSECTION OF CONVEX POLYTOPES

Since the two polyhedra we are going to intersect are polytopes and bounded, theirintersection is either a polytope or empty, saving us the work to handle the case, thatthe feasible region is unbounded in the direction of c.The projection to polar space does only work if the inner point is really inside the inter-section polytope. If the point is on the border of the resulting polytope, the facet it islocated on is transformed into a point with infinite distance. Therefore, the degeneratecase, where the intersection is not three dimensional, can not be transformed into polarspace this way.We now try to find in inner point to the intersection of two convex polytopes by incre-mental linear programming. We use Seidels algorithm [21] which is explained in [7].We assume the polytopes in a general position. This means, we are able to calulate adefined maximum value for all hyperplanes. To ensure this, we set the objective functionparallel to the x-axis. Additionally, we define a lexicographic order for the points. Iftwo points have the same x-coordinate, the point with the higher y-coordinate is higher.We compare the z-values, if the y-coordinates are the same, too.

While solving a problem in three dimensions, it is much easier to illustrate things intwo dimensions. Thus the images you see in the following description are 2-dimensional.As we see later, this should not prove a great problem. In fact the algorithm for twodimensions is just like the one in three.The algorithm we are using is incremental. That means, we add halfspaces one afteranother. The invariant is that, the point p is a valid and optimal solution to all inequal-ities yet added.The algorithm recurses into dimension by reducing the problem to the same problem

cfeasible area

Figure 4.4: A 1-dimensional linear program is solved on the line hj . The feasible interval ismarked red. We can find the optimal point on the line by finding the maximum value of allproper intersection points.

one dimension lower. The solution of a linear program in 1 dimension is easily calcu-lated. In fact we can solve it in linear time. We just have to find the maximum of theinterval denoted by the constraints. This task is equivalent to finding the maximumvalue in a list of numbers. We can solve it in O(n) time.We start the algorithm with d halfspaces, where d is the dimension. In our example,d is 3. For these halfspaces we know the hyperplanes that bind them. These planesintersect in a point p. p lies inside all the 3 halfspaces. This point is the initial value

Page 35: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

4.3. LINEAR PROGRAMMING 29

for our invariant point. The problem is, that this point has to be an optimal valueconcerning the objective function. How do we find the 3 necessary halfspaces for ourproblem? First lets argue why such halfspaces always exist: We remember that theactual entities we are intersecting are bound polytopes. Therefore, the intersection ofthem is bound, too. If the intersection is bound, there must always exist hyperplanesthat enclose the point set created by the intersection.For a fast negation of the intersection of two polytopes, we already compare theirbounding-boxes. A bounding-box is the smallest box, with faces parallel to the coordinate-planes, that encloses the polytope. The intersection of the two bounding-boxes clearlycontains the intersection of the polytopes. Hence we just take 3 halfspaces of the in-tersection of the bounding boxes for our initial 3 constraints. These constraints areobviously not very sharp, but they do fine for a start. We set the objective functionto maximize the coordinates, hence we choose the three maximum hyperplanes of theintersection of bounding boxes and add them to the beginning of the list of halfspaces.This way, we ensure the intersection to be bounded in the direction of the objectivefunction from beginning on.By intersecting the three hyperplanes, we just chose a p that is optimal to our initial

p c

Figure 4.5: The initial hyperplanes intersect in a point p. This point is optimal to the twohalfspaces. The initial halfspaces are chosen in a way, that they are the intersection of thebounding boxes of the two polytopes.

3 halfspaces. We now add the other halfspaces one after another. When adding a half-space, two cases may arise:In the trivial case, the new halfspace hi contains p. We just keep p the way it is andproceed with hi+1.In the more complex case, the new halfspace hi does not contain p. We now have to

find a new p, that is contained in the intersection of all halfspaces hj ∈ h1, h2, ..., hi.Adding a constraint to a linear program cannot extend the set of solutions. Thus, thepoint set spanned by the halfspaces may only shrink or stay the same when adding a

Page 36: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

30 CHAPTER 4. INTERSECTION OF CONVEX POLYTOPES

ppnew halfspace

c

Figure 4.6: When a halfspace is added and p is not above it, we have to find a new p.

halfspace hi. The intersection of halfspaces is always convex. Therefore, if the intersec-tion of halfspaces ∩(h1...hi) is not empty, there exists a point on the boundary of thenew halfspace hi, that lies inside all halfspaces.As we just found out, all we need to do is find a point on the hyperplane that bounds thehalfspace hi and applies to the constraints given by h1...hi−1. We observe this is a linearprogram of one dimension lower than the one we started with. If our linear programresides in two dimensions, the hyperplane of consideration would be a line of points.So what we have to calculate is the interval on this line, that fits to all constraintshk ∈ h1, h2, ..., hi−1. This whole interval is a valid solution to all constraints. We canfind this interval in time linear to the number of constraints. Again, it is equivalent tofinding the minimum and maximum of a list of numbers.We now switch to three dimensions. If p does not suffice the constraint for a newlyadded halfspace hj , we have to find a new p on the hyperplane on the boundary of hj .Hence, we have to solve a 2-dimensional linear program on the hyperplane hj . Since thethree initial halfspaces presented a maximum boundary to our 3 dimensional program,they also do this for the 2 dimensional one. For solving the 2 dimensional program, wemost likely will have to solve 1 dimensional linear programs. We already stated how tosolve linear programs in one and two dimensions.

Analysis. As stated above, with d = 1, we can solve a linear program in linear time.The recursion above obviously gives us an undesirable running-time of O(n · d). Ford = 3 this would be O(n3) which is disastrous.Fortunately the cubic running time is not what is to expect in most of the cases. Theoptimal vertex is not expected to change every time. In most cases, it changes a lotfewer, as we find out soon. Therefore lets check the expected running time of thealgorithm if we permute the vertices by random, before we start the algorithm. Thefollowing analysis is due [7].Lets first try to evaluate the expected running time of a randomized linear programming

Page 37: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

4.3. LINEAR PROGRAMMING 31

Algorithm 3 Linear Programming.Ensure: p lies in all the halfspaces denoted by HRequire: The intersection of the halfspaces is finite or the empty point set

def linearProgramming( p,H )p← intersection of the top, left and back bounding planecompute a random permutation of Hfor all hi ∈ H do

if p is above hi thenif (not (linearProgramming2D( hi, p, h0, ..., hi−1 )) then

return false (since there is no point in the intersection)end if

end ifend forreturn true

Ensure: p lies in all the halfplanes denoted by HRequire: The intersection of the halfplanes is finite or the empty set

def linearProgramming2D( l, p,H )p← a point on l that lies on the intersection of the top and left bounding box hyperplanecompute a random permutation of Hfor all hi ∈ H do

if p is above hi thenI ← the interval on l that applies to all constraints h0, ..., hi−1

if I ⊆ thenreturn false (since there is no point in the intersection)

else I is not emptyp← the point in I that is optimal to the objective function

end ifend if

end forreturn true

Page 38: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

32 CHAPTER 4. INTERSECTION OF CONVEX POLYTOPES

e3

e4

e5

e6

e7

e1

e2

Ob

jec

tive fu

nc

tion

Figure 4.7: A bad order for a 2-d-linear program. It produces a running time of O(n2). Pleasenote, that only this particular order is bad.

in two dimensions. With the analysis we did before, we would expect a worst caserunning time of O(n2). This worst case may actually emerge for a non randomizedapproach as figure 4.7 illustrates. If we add the halfspaces in the particular orderdepicted in the figure, we have to solve a linear program in 1-space every time we adda halfplane. The point is, that only this individual order produces the unwanted result.If we add the last halfplane earlier, the running-time is linear.It is hard to calculate the perfect order for adding the halfplanes (or halfspaces ingeneral). Fortunately, most orders are good. So we just pick a random order and hope,it is a good one. Let Xi be our random variable in step i. So Xi equals 1 if vi−1 /∈ hi andforces us to recurse into the dimension. Otherwise, if there is nothing to do but proceed,Xi equals 0. As stated before, a linear program in one dimension and i constraints canbe solved in O(i) time. If Xi = 0, we don’t have to solve a linear program. So theoverall running time for the recursion-step is:

n∑i=0

O(i) ·Xi (4.2)

As the linearity of expectation states, the expected value of a sum of random variablesis the sum of the expected values of the random variables. As this even holds if therandom variables are dependent, the expected running time for solving computing allrecursions is bound at:

n∑i=0

O(i) · E[Xi] (4.3)

Page 39: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

4.3. LINEAR PROGRAMMING 33

Let us look at the algorithm backwards. In step i of the algorithm, vi is the optimalvertex to all constraints in Ci. By the way that vi was created by the algorithm weknow that it is defined by the intersection of at least two of the hyperplanes of Ci. Letsnow look at Ci−1 = Ci \ hi where hi is the halfplane we added in the last step. We didhave to recurse if and only if hi is one of the halfplanes that define the optimal pointvi. The halfplanes are added in random order and at most two halfspaces define vi.Therefore the probability that hi is one of the halfplanes defining vi is equal or less than2/(i − 2). It equals 2/(i − 2) if vi is defined by exactly two halfplanes. If it is definedby more than two, the probability is even lower.This rule holds for any step i, so the bound for the expected total time for all therecursions in the algorithm for computing the linear program in two dimensions is

n∑i=3

O(i) · 2/(i− 2) = O(n) (4.4)

We just proved that the randomized version of the algorithm is expected to compute aninner point in 2 dimensions in O(r) running time, where r is the number of halfplanes.In 3 dimensions, the randomization works almost similar. Using the same argumentsas above, the expected running time with d = 3 is obviously:

n∑i=3

O(i) · E[Xi] (4.5)

In 3 dimensions, a point is defined by at least three halfspaces. Using backwards analysis,we find that the probability that the actual point did change since the last step is equalor less than 3/(i− 3). Again, we state ”less than” because the point may be defined bymore than three hyperplanes which would push the probability even below 3/(i− 3).The leads us to the conclusion, that the expected running time for the randomized linearprogramming in 3 dimensions is expected to be

n∑i=4

O(i) · 3/(i− 3) = O(n) (4.6)

Problems and Solutions. The algorithm we developed above does find a point in-side the intersection of two convex polytopes. Unfortunately this point is almost alwayson the border of at least one of the halfspaces of the intersection. This is venom for thepolar transformation as all points on the hyperplane would be transformed into infinity.Thus we need to slightly adjust the point into the inside of the polytope. This is not aseasy as it sounds. If we shift the point too far, we could find it being outside the topeor on some other border. If we shift it too slight, the numeric inaccuracy could blow usback on the border.The hyperplanes, that bound the optimal vertex for the linear program, form a cone.

As seen in figure 4.8, we shoot a ray from the optimal vertex trough the center of thiscone. There are some points on this ray, that are located inside the intersection. Wecompute the interval of these points by intersecting the ray with all hyperplanes. Thisagain takes us O(n) time and gets us an interval of points inside the intersection. If theintersection is not degenerated, the center of the interval is obviously a point that is

Page 40: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

34 CHAPTER 4. INTERSECTION OF CONVEX POLYTOPES

Figure 4.8: The cone spanned by the hyperplanes intersecting in the optimal vertex. Weshoot a ray trough the middle of it an compute its interval inside the polytope.

really located inside the intersection. We define a degenerate intersection as a polytopethat is not full dimensional. Therefore a degenerate intersection is a point, an edge ora polygon. If the result is degenerate, we can not find an point in the real inside. Thecone has a zero height. If the height of the cone is below a proper epsilon, we returnno inner point. Finding a proper epsilon is a bit tricky. Since the inner point is neededfor the transformation into polar space, an epsilon that is too low will produce pointsthat exceed the maximum value of the floating point numbers. On the other hand, werisk dropping small intersections, if the epsilon is too high. We produced useful resultswith values ranging from 10−3 to 10−2. Since the precision of common mills is 10−3 thisproves an acceptable compromise.

4.4 The Quickhull Algorithm

The input for the algorithm is a set of vertices in 3-space. We assume these verticesto be full-dimensional. From these our algorithm computes the vertices on the convexhull as well as the facets of the polytope, enclosing the hull. To construct the facialbindings, we also demand that no facets are coplanar and that coincident vertices aremerged together. We first create a convex hull and then postprocess it to get the desiredoutput.The algorithm we are going to use is called the Quickhull. It is described in [2] andimplemented in the qhull-library by the geometry center. Quickhull is an incrementaldivide and conquer algorithm. The points are successively divided on the facets of an

Page 41: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

4.4. THE QUICKHULL ALGORITHM 35

initial simplex. The facets are then split into multiple other facets reducing the numberof points. The estimated running time is O(n log n) which our algorithm is able toperform in.First we create an initial simplex. We divide the points upon the facets that are locatedabove. If the points are not above any facet, we simply drop them. Thus it would befine to have an initial simplex that contains as much points as possible.We construct it from the extreme points of the cloud. Therefore we calculate the 8extreme points, two to each dimension. If the number of disjoint points is lower then 4,the simplex has a dimension lower than 3, we are finished because the result is degener-ated. Otherwise we construct a simplex from a subset of 4 of these points. The pointsspanning the simplex need to be independent. We then divide the remaining points ofthe input into four sets. One for each of the facets of the simplex. (This also includesthe extreme points, we did not use for the actual simplex.) We insert a point into afacets set, if it is outside that facet. In our definition, outside means that the point islocated above the facet. Let f(n, d) be a facet with the normal n ∈ R3 and the distanced from the origin. Then a point p ∈ R3 is above f(n, d) if and only if:

n · p > d (4.7)

If a point is above more than one facet, it is inserted into the set of only one of themby random. If a point is below all facets, it does not contribute to the convex hull andis dropped.So much for the preprocessing. We now start our algorithms loop. We loop while there

Figure 4.9: A convex hull. The area seen by the eyepoint is marked white. The border ofthis area is the base for the cone created below the eyepoint.

exists a facet in the convex hull, whose outside set is not empty. For each point on eachfacet we now perform the following steps:

Page 42: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

36 CHAPTER 4. INTERSECTION OF CONVEX POLYTOPES

1. First we find the point in the facets outside set, that is farthest away from theplane of the facet. We call this point the eye point e.

2. We then compute the horizon of the current polytope as it would be seen from thepoint e.

3. We remove all facets of the horizon from the convex hull and mark all their re-maining points as unclaimed for later processing.

4. We then construct a cone above the polygon formed by the contour of the horizon.The cones top off course is the eye point e.

5. If some facets of the cone are coplanar to the facets they are connected to, wemerge them. Also the facets of the cone are tested coplanarity and - in case - arebeing merged. Merging is done by removing the separating edge and uniting thetwo facet-records into one. Also the points above both facets are united inside thefusioned one.

6. Having done that, we divide the points, we marked as unclaimed before, amongthe new facets of the cone. This is done the way described for the simplex: Pointsthat are not outside any of the facets be dropped. Points that could be insertedinto the outside set of multiple facets are put into only one of them by random.

We did not yet think about how we can compute the horizon-contour in step 2. Thissimply could be done by iterating through all facets which would lead us to a O(n2)algorithm. Fortunately we can do better.

We already know one facet that is visible from the eyepoint e. This facet is inside

S

1

2

2

1

Figure 4.10: The horizon contour is computed by a counterclockwise depth search. Thestarting point is marked by a black dot.

the horizon. From it we start a recursive search. We visit all neighbors of the facetin counterclockwise order. Please note that we recursively call the case differentiationfor neighbor facets in case 1. For each facet f(n, d) with the normal n ∈ R3 and the

Page 43: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

4.4. THE QUICKHULL ALGORITHM 37

distance d ∈ R, 3 cases are distinguished:1. f(n, d) is visible from e:

e · n > d (4.8)

We mark all vertices in the facets outside set as unclaimed. We also mark the facet asnot on the convex hull and recurse into all its neighbors.2. f(n, d) is not visible from e:

e · n ≤ d (4.9)

We append the edge to the horizon-contour and return.3. f(n, d) is marked as not on the convex hull:We simply return.Figure 4.10 illustrates how the algorithm recurses into the neighboring facets.

4.4.1 Analysis

In this section we will analyze the running time of the Quickhull algorithm. There aretwo parts of the algorithm that affect the running time. The first is adding a vertex tothe hull and the second is the creation of the outside sets. Since the number of verticesentered into the algorithm is n and the number of outside sets is proportional to n, arunning time of O(n2) is easy to prove. The question is, can we do better that that?When we add a vertex to the hull, we create new facets. The facets are the ones of acone over the horizon contour. Such a 3-dimensional cone has at least 3 facets. Howeverthe maximum number of facets can be very high. Lets take a look at the total numberof facets generated. We define r as the number of processed vertices. We also define fr

as the maximum number of facets for a 3-d polytope with r vertices. Since the surfaceof a 3-dimensional polytope can be considered a planar graph, we can use eulers formulato calculate fr = 2r − 4 which is O(r).

[2] states that in a balanced execution, the average number of new facets for the i-thprocessed point is fi/i. Hence, the average number of new facets is (2i− 4)/i which isbelow 2 for any i. Therefore, the total number of processed facets is

O(r∑

i=1

fi/i) (4.10)

Since every term fi/i ≤ fr/r (in a balanced execution), the total number of processedfacets is

O(fr) (4.11)

⇔ O(r) (4.12)

We now analyze the running time spent in the creation of the outside sets. In a balancedexecution, the average number of points that need to be partitioned for the i-th processedpoint is O((n − i)/i), where n is the number of vertices. Since we have to test if thepoint is above each new facet, the time necessary to partition one point is proportional

Page 44: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

38 CHAPTER 4. INTERSECTION OF CONVEX POLYTOPES

Algorithm 4 The Quickhull algorithm.def quickhull( V )P ← a maximal tetrahedron for Vdivide the points in V into the outside sets O(f) of all faces f of Pwhile ∃f ∈ P | O(f) 6= ∅ do

eyepoint← the point in O(f) that is the furthest away from fV ← ∅H ← computeHorizon( eyepoint, f , V )P ← P \HC ← a cone on top of H. If faces are coplanar, they are joinedP ← P ∪ C. If faces are coplanar, they are joined but kept in C.for all Vertices v ∈ V do

B ← all facets of C, that are below vif B is empty then

drop v since it is not on the convex hullelse

add v to the outside set of a random member of Bend if

end forend whilereturn a polyhedron P given by vertices and facesdef computeHorizon( e, f , V , H )mark f as not on the convex hullfor all Vertices v in f do

V ← V ∪ vend forc← a random edge of ff(c)← the face on the other side of ccrossEdge( e, c, f(c), H, V )return Hdef crossEdge( e, c, f , H, V )if f is not on the convex hull then

mark c as not on the convex hull and returnend ifif e is above f then

mark f as not on the convex hullfor all Vertices v in f do

V ← V ∪ vend forc← the edge following c on f in counterclockwise orderif c is on the convex hull then

f(c)← the face on the other side of cmark c as not on the convex hullcrossEdge( e, c, f(c), H, V )

end ifend if

Page 45: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

4.5. COMPUTING THE FACET BINDINGS 39

to the number of new facets. Thus the total time spent in computing the outside setsis the product of the number of points and facets:

O(r∑

i=1

(fi/i · (n− i)/i)) (4.13)

⇐⇒ O(nr∑

i=1

1/i) (4.14)

⇐⇒ O(n log r) (4.15)

Since fr is O(r), if the balance condition holds, the creation of the outside sets takes:

O(n log r) (4.16)

We asses r by n to produce a worst case running time for the Quickhull algorithm forn points in 3 dimensions of O(n log n) if the balance condition holds.We did not yet discuss how we grant a balanced execution. In fact we can’t. It dependson picking good random members in the partitioning. The authors of [2] compare thisto the the behavior of the quicksort algorithm starting with a bad pivot. However,[2] gives empirical results supporting the assumption. My own measurements and theresults produced in chapter 7 also point to a running time that is well below O(n2).Using the point that is the farthest away from a facet, does provide a vertex of the finalconvex hull, in many cases.

4.5 Computing the Facet Bindings

This section describes how the information of facet bindings is retrieved from the outputgenerated by the convex hull code. Let’s first discuss in which cases a facet binding mayneed to be added. A facet is bound down to exactly all facets that are bound up to it.Hence, it is sufficient to figure each facets upbindings. Positive facets are not bound upat all. Negative facets are bound up to positive facets and zero facets are bound up tonegative ones. Bindings solely exist between facets, residing in the same hyperplane.New bindings are created exclusively when new cells are added to the CDA. In thefollowing paragraph, we reason how we can utilize this knowledge.Whenever our virtual tool excavates material from the CDA, we call the subtract routine.This routine gets the polytopes approximating the path of the tool trough space andoperates on the CDA to subtract the objects from the CDA. Subtracted objects aredepicted by negative cells. These are generated by computing the intersection of thepositive cell with some tool path contour. Zero cells are generated if this new negativecell intersects with one of the negative ones that are already part of the CDA. The pointhere is, that all cells, except for the initial positive one, are generated by the outputof the intersection code. Fortunately, positive facets do not have upbindings at all. Inthe next paragraph, we use the knowledge, that facet bindings are added right aftercomputing the intersection.The cell containing a facet f is generated from the intersection of two cells C1 andC2. Although f may actually be in the same hyperplane with other cells facets, it

Page 46: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

40 CHAPTER 4. INTERSECTION OF CONVEX POLYTOPES

may only be bound up to facets of C1 or C2. Remember the polytope was transformedinto polar space before we ran the convex hull code on it? In polar space, hyperplanesbecome vertices and vice versa. Since the objects, we are dealing with are convex,every hyperplane matches exactly one facet. Hence, every facet of the source polytopes,corresponds to a vertex in polar space. Remember we are computing the convex hullof these vertices? We are lucky, the above statement applies, as otherwise, the wholeconvex hull computation would be useless.Let’s see how we can use this knowledge to our advantage. The convex hull computationleaves us with a subset of the original vertices. Hence every vertex v of the convex hull isalso a vertex of either one or both of the original (polar space) polytopes and thereforematches a facet f of the original (primal space) polytopes. After projecting the convexhull polytope back into primal space, v4 describes the hyperplane of a facet of theintersection.

a) b)

Figure 4.11: Examples for the two classes of cases, where a facet of the intersection is coplanarto facets of both of the two polytopes.

We assume the source polytopes to be convex and full-dimensional. Hence there is atmost one facet per source polytope, that resides in the same hyperplane. Since theoriginal v has to be originating from one of the sources, there also has to be at leastone facet, that resides in the plane of v4. One of the following statements is true.

1. v4 is in the same hyperplane as one facet of the source polytopes. Therefore, v isa vertex of only one of the polar source polytopes

2. v4 is in the same hyperplane as either one facet of the source polytopes. Therefore,v is a vertex of both of the polar source polytopes.

The first case is the trivial one. Here, we just add an upbinding from v4 to the facetof the source polytope. Figure 4.11 shows examples for the second case. The case inFigure 4.11.b arises when the intersection is not full dimensional. The facet of the result

Page 47: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

4.5. COMPUTING THE FACET BINDINGS 41

of the intersection, is coplanar to a facet of both of the intersected polytopes and thenormals of these facets are oriented different. Cases like this occur when a tool excavatesto the exact margin of the material. Even in nature (the milling world), the result isundefined. Therefore we report this case as an error.Figure 4.11.a depicts a case where the facet would normally require to be bound upto both of the facets. Within the structure of the CDA, this is impossible. To finda feasible solution, lets take a closer look at the cases causing the coplanarity. If wesubtract a polytope from the CDA, there are two types of intersection calculations. Ina single initial step, the intersection of the polytope and the positive cell is computed.After that, the polytope itself is no longer of any interest. Hence, upbindings are onlyrelevant to the positive cell and will solely be done to it. The result is then intersectedwith all negative cells and inserted into the list of negative cells. Whenever two negativecells intersect the way depicted in figure 4.11.a, at least a part of the boundaries of thetwo cells is the same. Unlike 4.11.b, the normals of the facets are oriented the same.Thus, the hole in the facet of C1 that would be created by the upbinding would exactlymatch the facet of C2. and vice versa. Therefore the common parts of both facets wouldmasked and thus invisible. Is this the awaited result?Imagine drilling a hole into so piece of steel. To prevent the drill from getting too hot,you withdraw it for a moment and then push it back into the hole to continue. In thesimulation, this (very common) behavior produces a case like figure 4.11.a. The drillpushes into the material on the same path. Hence the negative cells, on the path of thedrill have facets in the same hyperplane as the new cell created by the drilling. Imaginepeering into the hole you just drilled. It hopefully looks like the inside of a cylinder.The walls of the cylinder are approximated by convex polygons. As you pushed in thedrill multiple times, there are a some overlapping negative cells. There are also zerocells where the negative ones intersect. The cells are all looking like slices of the cylinderyou look into. The zero facets on the walls are coplanar to facets of both of the negativecells they are produced by and would therefore mask them out. Not seeing the wallswhere the cells collide is not what we expect. We need to paint the area masked by thezero facet if it masks facets of both cells. Thus, we bind the zero facet to a single oneof the facets, leaving the other one to be painted.This leads us to the following binding policy:

if f is facet of a negative cell N produced by the intersection of positive cell P andsome polytope T then

if f is coplanar to a facet p of P thenbind f up to padd f to the downbindings of p

end ifelse

if f is facet of zero cell Z produced by the intersection of the negative cells N1 andN2 then

if f is coplanar to a single negative facet n of N1 or N2 thenbind f up to nadd f to the downbindings of n

end if

Page 48: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

42 CHAPTER 4. INTERSECTION OF CONVEX POLYTOPES

end ifend if

4.6 The Assembly

We now assemble the algorithms we acquired in this chapter. We use the linear program-ming to find an inner point. We then translate the joint hyperplanes bounding the poly-topes to this inner point. The polar of the set of halfplanes is a set of points of which wecompute the convex hull. The result is transferred back into primal space. Facet bind-ings are added. The following algorithm illustrates this.

def intersect( C1, C2 )H ← the joint halfspaces of C1 and C2

if linearProgramming(H, p) thenAdjust H to the inner point pV ← polar( H )P ← quickhull( V )for all v ∈ vertices(P ) do

plane ← polar( v )F ← facets adjacent to v in counterclockwise orderV ← ∅for all f ∈ F do

add polar(f) to Vend forG← a new facet with vertices V in plane planeif C1 is a positive or negative cell then

add an upbinding to G if it is in the same plane as a facet of C1

end ifif C2 is a positive or negative cell then

add an upbinding to G if it is in the same plane as a facet of C2

end ifend forreturn the polytope created by the facets

elsereturn null

end if

Besides the algorithms we described in the sections before, there is one tricky part.It is the generation of the resulting polytope. For the rendering we need a completerepresentation of the polytope. This means we need all its facets given by their verticesin counterclockwise order. The facets are found easily. They are the polar to thevertices. The vertices of a facet correspond to the facets that are adjacent to the vertexin polar space. To create a facet record, we therefore use the facets adjacent to thepolar facet (which is a vertex).

Page 49: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

4.7. ANALYSIS 43

4.7 Analysis

In this section we will analyze the total running time of finding the intersection oftwo polytopes in three dimensions. Let n be the total number of vertices. Since 3dimensional polytopes resemble a planar graph, the number of facets and edges is O(n).Finding an inner point to the intersection of the polytopes takes O(n) estimated runningtime. If the polytopes do not intersect, this is also the time it takes to find it out. If theyintersect, it takes us O(n) time to translate them to make the origin an inner point. Thetransformation of the halfspaces into polar space again takes O(n) time. Computing theconvex hull of n vertices, will take O(n log n) time as long as the balance condition holds.Given the connectivity information for facets paired with the knowledge of the originalpolytope of a vertex, we can compute the facial bindings in O(n) time. Transformingthe resulting polytope back into primal space can be done in O(n).Hence the total running time for finding the intersection of two polytopes is O(n log n) ifwe assume a balanced execution of Quickhull. Since we are unable to prove that all – orat least the majority of the executions is balanced, the upper bound for the intersectionalgorithm is O(n2).

4.8 The Evils of Floating Point Numbers

We use floating point arithmetic for all geometric computations. The imprecision causedby floating point numbers produces problems that we are going to discuss in this sec-tion. There are mainly two classes of problems arising from the use of floating pointarithmetic. These include:

Representation Error. Representation errors are produced by numbers that have toomany digits to be represented in a variable. Numbers like 1

3 can not completely bestored inside a float since the number of their digits is infinite.

Roundoff Error. Roundoff errors occur when the result of a calculation is rounded toa fixed number of digits. This error is related to the above one. A roundoff errormay turn a small negative number into a small positive one.

Roundoff errors provide great danger to our algorithms. For example a roundoff errormay let a point residing slightly below a facet appear as a point above it. Our solutionfor this particular problem is mainly to make a facet thick. This means, we will considerpoints, which compute slightly above or below a facet, as lying on it. Therefore, theimplementation of the algorithms may produce results, that are imprecise. The linearprogramming may fail to compute an inner point in very small intersections. It mayalso fail for intersections that have very sharp angled facets. In this context failingmeans, that the implementation does not provide an inner point and thus we are unableto calculate the intersection at all. On the other hand we may succeed in finding aninner point, but the point may be afflicted with problems. We will detect this whenwe transform the halfspaces into polar space and a halfspace has a very high or verylow distance to the origin. In all of these cases the algorithm retries a new randomperturbation of the halfspaces. In a repeated failing, it bails out.The computation of the convex hull has to cope with the same problems. Apart from

Page 50: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

44 CHAPTER 4. INTERSECTION OF CONVEX POLYTOPES

the problem of detecting whether a point is above a hyperplane, it has to generatevalid facets. For imprecision reasons, these facets may become concave or non planar.Quickhull uses some heuristics to repair damage, done. Like our linear programming,it considers a facet as thick. Hence, there is a small epsilon above and below the facetshyperplane, that actually may contain vertices.All these methods do not provide a fail-proof solution. However suffice our needs. Sincewe are simulating a physical process, and since we use our results only for its visual-ization, the errors we do are tolerable. Whenever we perform a subtract operation, theonly input we use is the halfspaces of the participating polytopes. If the union of theentered halfspaces does not have an inner point, we will not perform any boolean op-erations. Therefore subtractions of small polytopes may not be performed. Due to thefact that the precision of the machine we are simulating is limited, we can live with that.

4.9 Notes and Comments

The intersection of two ponvex polytopes can be done in linear time. [5] gives an optimalalgorithm to compute the intersection of convex polytopes. Although Chazelle statesdifferent in the paper, I consider it hard to implement. It depends on very complex datastructures for the intersection-computation. For an initial vertex inside the intersection,which it needs the same way as the algorithm we used.Linear programming solved the way we did here is fine as long as the dimension of theprogram is relatively low. The O(n) estimated running time, we analyzed it to performwhere d = 3 becomes an O(d!n) for a variable dimension d. Therefore it is obvious thatthe approach we did is only feasible for low-dimensional problems. For higher dimen-sions the simplex algorithm found in [6] is a working and well performing solution.Because I was unable to completely resolve the stability issues with the version of theQuickhull algorithm, I implemented, I used the one available from the geometry center.Their implementation is amazingly stable and generates good results. There are someother convex hull packages, which I tried. The main problem was, that they neededto be able to handle floating point numbers. Of the ones, that were able to, Qhullwas the best. The problem, that made most of the implementations useless, was thatthey triangulate the surface of the polytope. A triangulated surface may be good forsome applications but for the facial bindings, it is useless. The reason is, that the clearstructure for facial bindings is broken by the triangulation. There is more than oneway to triangulate a polygon. If a contained cells facet is triangulated different fromthe one it is bound up down to, it would need to be bound to multiple facets. Thiswould ruin the whole rendering code and therefore is intolerable. Furthermore, I neededan implementation, that was as stable as possible. The heuristics used in Quickhull tocorrect the output performed quite well doing this.

Page 51: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

Chapter 5

Working on the CDA

5.1 Rendering the CDA

For rendering, the CDA is a specialized scenegraph of depth 3. To render a CDA, weneed to render all its cells. To render a cell, we simply render all its facets, that arenot bound up. To render a facet we first render the facets that it is bound down toonto a stencil plane. This plane is used as a mask to all further rendering. At everyscreen coordinate, where the stencil is set, no rendering is performed. Dependent of thestencil, we render the facet itself to the color buffer, thereby deleting the stencil bufferagain. The algorithm 5 should clarify things. A more detailed description of the stencilbuffer is also given in the next section.Zero cells are not rendered at all. Their facets are solely to assist rendering (stencil mask)the adjacent negative cells. Although they are not rendered directly, facets of a zerocell are bound up to facets of negative cells. Since facets render all their downbindingson the stencil, the facets of a zero cell are actually rendered.

5.1.1 The Stencil Buffer

OpenGL and similar APIs present their users different buffers they may manipulate.OpenGL has three main buffers: The color, depth and stencil buffer. Usually, thedrawing is performed in the color buffer. The depth buffer stores a depth value for eachpixel. The main purpose of this buffer, which often is referenced as the z-buffer, is hiddensurface removal. The stencil buffer is used to restrict drawing to certain portions of thescreen. It is accessed in conjunction with the depth buffer and enables us to paint pixelson a stencil plane rather than the depth- or color-plane. In a second rendering pass, weare now able to render our polygons restricted by on the stencil buffer. Wherever the abit on the stencil-plane is set, we won’t render a pixel on the visual plane. We use thisto create holes in a polygons visualiszation. For a detailed description of the variousbuffers and their uses consult [29] and [26].

Page 52: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

46 CHAPTER 5. WORKING ON THE CDA

Algorithm 5 Illustration of the rendering of a CDA.def visitCDA( C )visitCell( Pos(C) )for all n ∈ Neg(C) do

visitCell( n )end fordef visitCell( L )for all facets f in L do

if f is visible thenvisitFacet( f )

end ifend fordef visitFacet( f )for all facets d in the faces f is bound down to do

render d on the stencil bufferend forrender f on the color and depth buffer where the stencil is not setclear the stencil buffer in the area of f

5.1.2 Problems

Using the stencil buffer requires us to make multiple rendering passes. The first pass isdone to mask out the pixels we do not want the facet to be painted on. In the secondpass we actually render the facet and clear the stencil plane to ensure our masking doesnot affect other facets.Given that alone is something most systems can easily handle. Unfortunately the num-ber of zero cells can become the square of the number of negative cells. In that case,the system spends a lot of time painting masks on the stencil buffer. As stated above,the zero cells may intersect and thus it is possible that we actually mask a lot of pixelsa lot of times. Exactly this happens in the wave sample discussed later and exactly thisis the reason for its bad performing in that sample.

5.2 Collision Detection

This section describes how collision detection can be performed with the CDA. Un-wanted collisions of tools with the workpiece often ruin the tool and workpiece. Sincethese are expensive, collision detection is a key feature of the simulation package. Itallows developers of NC-programs to verify their programs.Whenever an entity of the machine moves through space, a collision detection is per-formed with the workpiece. We designed the CDA to accumulate tooltraces, that in-tersect the workpiece. Whenever an object collides with the workpiece, they have somecommon intersection. Hence, if an object has a common intersection with the CDA, itcollides with the workpiece.To speed up the collision detection and because it makes things quite easy, we approx-imate all entities, we need to test for collisions with the CDA, by polytopes. A convex

Page 53: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

5.2. COLLISION DETECTION 47

point set O collides with the CDA C if all of the following requirements are fulfilled:

1. The intersection of the positive cell with the object Pos(C) ∩O is not empty.

2. The intersection Ni ∩O is empty for all Ni ∈ Neg(C).

We already developed an algorithm to detect whether two polytopes intersect. Addi-tionally the algorithm also produces an inner point of the common intersection. Thisinner point is returned by the algorithm as a certificate and point of collision.Generally, the objects that need to be tested for collisions are not convex. However,we assume them to be. If an object is concave, we approximate it by its convex hullbefore we test it for collisions. Obviously, we may detect false collisions this way. Thus,we need to verify the reported collisions. The inner point, we produced as a certificate,lies inside both of the convex polytopes. If the concave polyhedron, that we originallywanted to test for collisions also contains this point, it really collides with the CDA.Otherwise it doesn’t. Therefore, we test if the certificate lies inside the polyhedron. De-tecting whether a point lies inside a polyhedron is a classic algorithm that for exampleis described in [7]. As collision detection is not the focus of this paper, we will onlybriefly discuss the algorithm. The algorithm to solve the problem is called ray shooting.As the name suggests, we shoot are ray through space. The ray originates at the pointwe want to test. Wandering along the ray, we find the face of the polyhedron, that isthe closest to the ray. If the point is above the face, or there is no face at all, the pointis outside the polyhedron. Otherwise it is inside.

Page 54: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling
Page 55: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

Chapter 6

The Implementation

As stated in the introduction, the STA GmbH develops software for the MicrosoftWindowsoperating system. The algorithm, packages containing it and the structures itoperates on are implemented in C++. They use the Standard Template Library [1]. Weused MicrosoftVisual C++ 6 to compile them. Apart from the RenderVistor, the codeis not platform dependent and should be easily portable to other operating systems.Because of the specific design chosen for the RenderVisitor, it is easily replaceable byan equivalent providing graphical output in some other system like Direct3D.

6.1 Package Overview

The system consists of multiple packages. The packages are resembled by namespacesin C++. The package STA contains the framework for the algorithm. It is created andmaintained by the STA GmbH and not focus of this paper. It’s code handles the inter-pretation of the CNC-code as well as the graphical framework and some basic routinesto handle vectors and matrices.The package Quickhull contains the quickhull implementation by the geometry center.The code was slightly modified to work in a Microsoft Windows environment.The package CDA contains all the specific code written to realize this paper. It containstwo minor packages. Namely: CDA::GL, CDA::Profiling. The CDA-package itself con-tains the basic data structures of the CDA. The implementations for finding an innerpoint and intersecting halfspaces are also part of this package. The CDA:GL-packageconsists of a single class: The RenderVisitor. This visitor walks through the CDA-treeand renders it calling the OpenGLmachine. The CDA:Performance-package containsof a single class derived from the class CDA:Visitor, too. This specific visitor was usedfor the performance tests that generated the results posted later on. The visitor is usedto gather the information needed from the CDA-tree. It writes them into a text file.The interface to the rest of the application is done by deriving from the abstract classCstaWpModel. As stated in the introduction, this class enables the application toabstract from a specific structure and algorithm. It is overridden by the class CCDAW-pModel. This class contains a CDA and forwards all calls to the CDAs methods.

Page 56: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

50 CHAPTER 6. THE IMPLEMENTATION

6.2 Static Structure

The Static Structure of the packages is depicted in figure 6.1. Its classes are describedin the following paragraph.

6.3 Class Description

CDA::CCDA. This is the Container for the CDA. It contains a single positive cell,a list of negative cells and a list of zero cells.The CCDA.subtract method can be used to subtract a convex polytope from the CDA.

CDA::CCell. The CDA::Cell class is the data structure that describes a cell insidethe CDA. Hence a Cell is mainly a structure specifies a polytope. Aside from theinformation if the cell is positive, negative or zero, it contains the vertices of the convexhull. Each cell has a bounding box. Since it is affine, it is given by two of its extremevertices. The cell also contains the polytopes facets which are stored inside a list ofobjects of the class CDA::CFacet, which is described in the next paragraph.There are two global functions handling cells:The first, namely intersect( const CCell c1, const CCell c2 ) intersects the twocells c1 and c2 and returns the resulting cell.findInnerPoint( const CCell c1, const CCell c2, CVertex p ) is a functionwhich tests the two cells for intersection. It returns true if they intersect. Also thevariable parameter p is set to an inner point to the intersection. Otherwise it returnsfalse. These two routines are used by the CCDA class to implement the subtractoperation.

CDA::CFacet. A CDA::CFacet is the structure to store a facet of a polytope. Thepolytope is convex, hence all its facets are convex polygons residing in 3-space. Thiscomes in handy when the facet is rendered, since rendering machines are usually onlycapable of rendering convex polygons.Apart from indices of the vertices of the polygon, CFacet stores additional information.It stores the normal vector and distance of the facet. It stores a reference to one facetit is bound up to and a list of references to facets it is bound down to.

CDA::CVisitor. This abstract class is made to perform operations on the CDA.It follows the pattern of same denominator, described in [10]. Classes derived fromCVisitor must override its three methods visitCDA, visitCell and visitFacet. Each ofthese methods gets a reference to the part of the CDA their name proximates. As theVisitor is a friend of the CCDA, CCell and CFacet, it may perform any operation onthem. Therefore, the Visitor enables us to define a new operation on the CDA withoutchanging the CDA-classes themselves. It keeps the classes of the CDA core lean bysourcing out most of the stuff, that is not immediately necessary.I used Classes derived from CVisitor to render the CDA, to write it to the disk and togenerate most of the measured data, included in this document.

Page 57: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

6.3. CLASS DESCRIPTION 51

CDA::GL::CRenderVisitor. The CRenderVisitor is derived from the class CVisi-tor. It renders the CDA using the OpenGL machine. A CDA is rendered by renderingall its positive and negative cells. A cell is rendered by rendering all its facets thatare not bound up. A facet is rendered in two passes. In the first pass, all polygonsdescribed by the facets that it is bound down to are rendered onto the stencil buffer. Inthe second pass, the polygon described by facet is rendered wherever the stencil bufferis not set. Furthermore, the stencil buffer is cleared for the whole area of the polygon.When a negative facet is rendered, the vertices are ordered clockwise. This is done sincethe negative facet is the inside of some hole. We are not looking at the negative cellfrom the outside by are looking inside it.

CDA::Statistics::CStatsVisitor. The CStatsvisitor is derived from CVisitor to gatherinformation about the CDA. Aside from simple tasks, like counting the number of thedifferenct cell and facet types, it measures the time spent in different parts of theCCDA::subtact and rendering code. The output is written into a plain text file ascomma separated values that to be imported easily into analysis tools.

CDA::XML::CFileVisitor. The CFileVisitor is made to write an XML documentof the CDA. I used it mostly for debugging purposes. However, it can be used togenerate output that is usable in other applications. Like in the CRenderVisitor, theinner structure of the CDA is represented in the XML document. A CDA node containsa single positive cell node, and multiple negative and zero cell nodes. each cell containsmultiple facet nodes and multiple vertex nodes. Each facet node contains multiplevertex nodes and a single plane node.

Page 58: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

C DA

-accept(in vis itor : C V is itor)

-facets : C F acetList-vertices : C V ertex

C DA::C C ell

+addB inding(in facet : C F acet)-accept(in vis itor : C V is itor)

-plane : C P lane-vertexIndices : int

C DA::C F ac et

+subtract(in cell : C C ell)-accept(in vis itor : C V is itor)

#pos itiveC ell : C C ell#negativeC ells : C C ellLis t#zeroC ells : C C ellLis t

C DA::C C DA

+vis itC DA(inout cda : C C DA)+vis itF acet(inout facet : C F acet)+vis itC ell(inout cell : C C ell)

C DA::C V is itor

+scal(in vertex : C V ertex) : double+cross(in vertex : C V ertex) : C V ertex

#x : double#y : double#z : double

C V ertex

+isB elow(in vertex : C V ertex) : bool+dist(in vertex : C V ertex) : double

+normal : C V ertex+distance : double

C P lane

C DA::C C ellL is t

C DA::C F ac etL is t

1*

1*

1 1

1

*

1

*

1 1

11

*

*

G L::C R enderV is itor

+setLogF ile(in filename : s tring(idl))

#file

S tatis tics :: C S tats V is itor

+setF ileName(in name : s tring(idl))

#file

XML::C F ileV is itor

C DA::G LC DA::XML C DA::S tatis tic s Quic khull

+clone() : C staWpModel+create(in poly : C P olyhedron)+subtract(in poly : C P olyhedron)+render()

C s taWpModel

#vertices : C V ertex#faces : C F acet

C P olyhedron

* *

*

*

+clone() : C C DAWpModel+create(in poly : C P olyhedron)+subtract(in poly : C P olyhedron)+render()

#cda : C C DA

C DA::C C DA WpModel

1

1

Figure 6.1: The UML diagram [9] of the static structure of the CDA package.

Page 59: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

Chapter 7

Analysis and Results

Do not believe in anything simply because you have heard it. Do not believe in any-thing simply because it is spoken and rumored by many. Do not believe in anythingsimply because it is found written in your religious books. Do not believe in anythingmerely on the authority of your teachers and elders. Do not believe in traditions be-cause they have been handed down for many generations. But after observation andanalysis, when you find that anything agrees with reason and is conducive to the goodand benefit of one and all, then accept it and live up to it.

The Buddha

In this chapter we post the results of some measurements. We analyze three differentnc-programs. You can see the workpiece generated by them in figures 7.3, 7.4 and 7.5.We will discuss three different diagrams for each of the programs. The first one showsdifferent timing measurements. Namely these are the times spent in the linear program-ming, the convex hull computation and the rendering. We subdivide the times in theconvex hull and lp-computation into the time to create a negative cell and to create azero cell. If a tool trace approximates a nonlinear movement, it may create multiplenegative cells. Since each new negative cell may intersect many old ones, it may alsocreate multiple zero cells. As the tool performs a constant movement, a new negativecell intersect others most of the time. Thus the time spent in the computation of zerocells prevails.

In the second diagram, we list the amount of facets. We distinguish three types offacets. The first one are stenciled negative facets. These are the facets of negative cellsthat are bound up. They are not rendered on the color buffer but they are used by thepositive cell to mask out its holes.The visible negative facets are the ones that belong to the second type. These are theremaining facets of negative cells. They are not bound up. However, the may be bounddown to facets of the third type, which will we discuss now.The third line charts the number of zero facets that are drawn on the stencil. We statedbefore, that zero facets are not rendered directly. However, they are rendered indirectlyby the negative facets, that they are bound up to.

The third diagram depicts the ratio of negative cells to zero cells. This ratio gives us animpression of how many convex hulls we expect to compute for each new cell we add.In a way it also shows the performance of the CDA. The number of cells the CDA may

Page 60: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

54 CHAPTER 7. ANALYSIS AND RESULTS

contain, is limited to some extent. One limit is given by the amount of memory thesystem has. Another one is given by the number of facets, the system is able to renderin acceptable time.

Unless stated different, the measuring is done on a MS Windows 2000 machine withan Intel Celeron 466 processor. An 32MB nVidia Riva TNT2-MX board is used forrendering. The resolution is set to 1024x768 at a 32 bit colordepth. The machine has256MB SDRAM clocked at 133Mhz on a mainboard with a VIA chipset. The screenrefresh rate is set to 60Hz.

Page 61: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

55

c) Zer o Cel ls / Negat ive Cel ls

0

2

4

6

8

10

12

14

0 2 4 6 8 10 12 14 16 18 20

Zero Cells per Negative Cell

b) Facets

0

500

1000

1500

2000

2500

0 2 4 6 8 10 12 14 16 18 20

Number of Negative Cells

Nu

mb

er

of

Fa

ce

ts

Stencilled Negative Facets Drawn Negative Facets Stencilled Zero Facets

a) Time Spent

0

10

20

30

40

50

60

70

80

0 2 4 6 8 10 12 14 16 18 20

Number of Negative Cells

Tim

ein

ms

Linear Programming (Negat ive) Convex Hull (Negative) Linear Programming (Zero) Convex Hull (Zero Rendering

Figure 7.1: The Performance of the ’sim-ple.nc’ program.

a) Time Spent

0

100

200

300

400

500

600

0 20 40 60 80 100 120

Negative Cells

tim

ein

ms

Convex Hull (Negative Cells) Linear Programming (Zero Cell s) Convex Hull (Zero Cells) Rendering Linear Programming (Negative Cell s)

b) Developement of Facets

0

5000

10000

15000

20000

25000

30000

35000

40000

45000

0 20 40 60 80 100 120

Number of Negative Cells

Nu

mb

er

of

Fa

ce

ts

Stencilled Negative Facets Visible Negative Facets Stencilled Zero Facets

c ) N e u t r a l C e l l s v s . N e g a t i v e C e l ls

0

5

10

15

2 0

2 5

3 0

0 2 0 4 0 6 0 8 0 100 120

N u m b e r o f N e g a t i v e C e l l s

Figure 7.2: The Performance of the ’com-plex.nc’ program.

Page 62: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

56 CHAPTER 7. ANALYSIS AND RESULTS

7.1 The Simple CNC Program

Figure 7.3: The workpiece generated by the ’simple’ program.

The simple.nc program performs a low number of operations. The movements performedduring the program are only linear and the number of intersections between two tooltraces is relatively low. During the program, the tool is rotated around the x-axis at avery low degree. Therefore, it qualifies to test the linear programming and convex hullcode for its stability. Figure 7.3 shows the workpiece, the program produces.Our algorithm performs fast and stable. The time spent in the linear programming isbelow the accuracy of the system clock. The rendering time is stable. Because of lownumber of polygons, the hardware handles it in a single refresh of the screen. Since themovements are linear, the number of negative cells added per step is 1. The time spentin the convex hull is very low. The maximum amount of hulls computed is three (step15). Usually the number is two or one.

Page 63: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

7.2. THE COMPLEX CNC PROGRAM 57

7.2 The Complex CNC Program

Figure 7.4: The workpiece generated by the ’complex’ program.

The complex.nc program performs a chaotic mix of linear and circular movements.Thereby it tests the implementation for stability and performance. The output producedby the program is illustrated in figure 7.4. During the execution of the program, thenumber of facets raises fast. Therefore it is no wonder that the rendering time alsoraises to 3 − 5 frames per second. The number of zero cells per negative cell is higherthan in any other program. As shown in figure 7.2.c, it quickly jumps to 14 and gets to25 at the end of the program.

The computation of the convex hulls remains around 100ms until it breaks of shortlybefore the 100th negative cell. We find the reason if we look what happens in thismoment. The tool moves a diagonal line over the top of the workpiece. There hasalready been a lot of carving done on the surface. The diagonal movement produces alot of new intersections. Hence, the long time spent in the convex hull computations iscaused by the many intersections that are added during these steps. Figures 7.2.b and

Page 64: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

58 CHAPTER 7. ANALYSIS AND RESULTS

7.2.c support this statement. The curves also register a steep gain around the 100thnegative cell.

7.3 The Wave CNC Program

Figure 7.5: The workpiece generated by the ’wave’ program.

The wave program produces a surface of sine waves. It can be interpreted by a 3-axismill as in solely works on the top surface of the workpiece. Anyhow it is interesting toevaluate as it performs unexpectedly terrible in our algorithm. As you can see in figure7.5, the surface of the resulting object is exceedingly curved from the crossed sine waves.This makes it necessary to produce many very small convex objects to approximate thecurved path of the tool. As these objects are lined up by the program, many of themintersect with each other.You can see in the diagrams in figure 7.6.c the number of intersections per cell rapidly

raises to 14. This means we have to compute approximately 14 cell-intersections for eachline in the NC-program. We remember our aim was to do multiple steps per second.Lets see if we can make up to that aim.As shown in figure 7.6.a, the performance of the computations is quite sufficient. Thetime spent in the convex hull and linear program solver remains below 1/4s for the entire

Page 65: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

7.3. THE WAVE CNC PROGRAM 59

execution. You can also see the pulsing of the curves. It is caused by the turnover ofthe milling tool in the end of a line.Unfortunately we did not yet take the rendering into account. Figure 7.6.a also showsthe performance, when rendering is concerned. As you can see, the frame rate drops tounacceptable values below 1 frame per second. After taking a look a figure 7.6.b, thereason is obvious: The number of facets raises rapidly. Soon, their number exceeds themaximum of what can be rendered in a second.

Analyzing the Problem. Please take a second look at the diagram in figure 7.6.a.Besides the large numbers, it does present, there is one thing in it that is very exiting.The number of zero facets is dominating the diagram. In the 900s step their number isroughly 850000 compared to about 130000 negative facets.What are the zero cells for? They characterize holes in the negative cells they are boundup to. Now these holes may overlap and the numbers suggest that this happens a lot.There is no straightforward way of finding and resolving these overlappings. We couldcheck for zero-facets that are completely redundant - but even that isn’t done quite easyin adequate time. Additional tests for this specific example indicated that the numberof these facets is extremely low.

Page 66: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

b) Number of Facets

0

200000

400000

600000

800000

1000000

0 200 400 600 800 1000

Negative Cells

Stencilled Negative Visible Negative Zero Facets

a) Time Spent (Logarithmic)

1

10

100

1000

10000

100000

1000000

0 200 400 600 800 1000

Negative Cells

mil

liseco

nd

s

LP Negative Convex Hull Negative LP Zero

Convex Hull Zero Rendering Time

c) Zero Cells vs. Negative Cells

024

68

1012

1416

0 200 400 600 800 1000

Number of Negative Cells

Zero

Cells p

er

Neg

ati

ve

Cell

Figure 7.6: a. illustrates the time spent in different parts of the algorithm when addinga negative cell. b. depicts the number of the different classes of facets and c. shows thedevelopment of the number of zero cells divided by the number number of negative cells.This depicts the middle number of intersection calls done in each step.

Page 67: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

Chapter 8

Future Work

As pointed out in the last chapter, the algorithm has some major drawbacks. It performsugly in some cases. In the following chapter, we think about what can be done to solvethese problems. We also analyze the prize to pay for the changes and list features thatcan be added to complete the package.

8.1 Getting Rid of Zero Cells

The headline might sound a bit provocative but thats exactly what could be done. Thezero cells are not relevant for the model as far as the geometry is concerned. They aresolely to assist rendering. As accented above, their assistance is at least sometimes morethan harmful to the performance. Lets try to resolve this by removing them completely.If we had no zero cells, there would be no zero facets to mask out the holes inside thenegative ones. We need to find some other way to get to these holes.

Analyzing the Problem. As a zero facet is produced by the intersection of thenegative cell to which facet is is bound up to, it must always be completely containedin even this facet. The zero facet is equivalent to the region of the zero cell, that we donot want to be seen.Let us save a second representation of the negative facet. This representation is apolygonal map of regions that need to be rendered. This map of course is initialized bythe negative facet itself. Every time, we bind a zero facet up to it, we need to subtractthe zero facets region.Everything happening on the facet is strictly happening in the plane, the facet resideson. Thus, to perform the above steps, we need boolean difference in 2 dimensions.

8.2 Exporting a Polyhedron

In some occasions, it may become necessary to export a workpiece into an externalprogram, for example a CAD-system. To export the CDA into a common graphics

Page 68: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

62 CHAPTER 8. FUTURE WORK

Figure 8.1: Two negative cells intersecting in a zero cell. Many of the negative cells facets tocompletely match the surface of the zero cell. Instead of not rendering them at all, we renderthem twice. Once on the stencil and second time on the color buffer.

format like VRML, we need to extrapolate to polyhedron it describes. In the followingparagraph we will sketch how this is performed. A polyhedron is described by its faces.The faces are described by their vertices. Each face of the target polyhedron correspondsto exactly one positive or negative facet of the CDA. To compute the faces, we need tofind the visible components of the CDAs facets. The visible components are the ones,that will not be masked by the stencil buffer, when rendering the CDA. In other words,we need to find the regions inside each facet, that are not overlapped by the facets theyare bound down to. We denote the positive facets of a CDA C by FP and its negativefacets by FN . The set of facets a facet f is bound down to is denoted by Down(f). Forevery f ∈ FP ∪ FN we compute f \Down(f). The union of the nonempty facets is theboundary for the resulting polyhedron.To compute the difference of two point sets that reside in a plane, we need to performboolean operations in 2-d. This is a problem that is discussed for example in [7].However writing stable code for boolean operations in 2-d still isn’t trivial.

Page 69: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

Figure 8.2: This shows an example case for a negative facet, sketched in blue, that is over-lapped by a set of zero facets. As you can see, the (dark filled) area is the only one that isactually painted is relatively small. On the other side (bright filled), the number of pixelsrendered on the stencil buffer is very high. A lot of these pixels even gets rendered multipletimes.

Page 70: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling
Page 71: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

Chapter 9

Conclusion

The greatest of all weaknesses is the fear of appearing weak.J. B. Bossuet, Politics from the Holy Writ, 1709

In this thesis, we presented a structure and algorithm to simulate the milling of a work-piece in an NC milling machine. We compared it to other algorithms. Of these, wediscussed the Intersecting Ray Model and the algorithm to compute the intersection oftwo polyhedra by Laidlaw et. al. We worked out advantages and disadvantages of ourstructure.

The presented structure consist of convex polyhedra that are charged positive, negativeor zero. Since all objects we deal with are convex, the algorithm to actually perform thesimulation of the milling requires the finding of the intersection of two convex polyhedra.We discussed two very different approaches, namely a spaces sweep and the half spaceintersection. We gave detailed instructions how to implement the half space intersection.

We discussed the implementation and gave an UML overview of the package. The im-plementation, which is done in C++, uses the Standard Template Library. It generatesoutput for OpenGL and XML. Additionally, it provides a flexible and easy interface toadd other output formats.

Using the package, we evaluated three different NC-programs. The algorithm is ableto compute the result of all of them. It produces fast and stable results at high visualquality. It works fine with NC-programs of short and medium length, even if theyperform complicated movements. However, it performs bad on long programs especiallyif they are composed of small movements of the tool. We explained and analyzed thebehavior in these particular cases. Having found the reason, we tried to point out asolution.

The algorithm is part of the NC-milling simulation by the STA GmbH. It is one of itsthree selectable algorithms. Each of these algorithms has its advantages and drawbacks.A solution that is stable, exact and scalable remains to be found.

Page 72: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling
Page 73: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

Appendix A

Color Slides

Figure A.1: The Milling Simulation Package by STA using our algorithm.

Page 74: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

68 APPENDIX A. COLOR SLIDES

Figure A.2: A 3-dimensional model of the mill while it works on the wave program.

Page 75: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

Appendix B

Deutsche Zusammenfassung

CNC-Frasen ist ein Vorgang zum Fertigen von dreidimensionalen Objekten aus zwei-und dreidimensionalen digitalen Informationen, die durch ein NC-Programm gegebensind. NC-Programme, die fur die Ausfuhrung auf NC-Maschinen geschrieben werden,sind oft fehlerhaft und erfordern weitere Fehlersuche.Dieses Dokument beschreibt ein Verfahren, das den Prozess des Herausfrasens aus einemWerkstuck simuliert. Das Werkstuck ist durch ein Polyeder approximiert und wird inForm eines Convex Difference Aggregate [20] gespeichert. Der beschriebene Algorith-mus bildet die boolesche Differenz des Convex Difference Aggregate mit einem Polyeder.Mehrere aufeinanderfolgende solcher Operationen ermoglichen die Simulation sehr kom-plexer CNC-Programme.Das prasentierte Verfahren ist robust. Seine Implementation wird beschrieben. Anhandvon praktischen Beispielen werden Probleme des Verfahrens aufgedeckt und diskutiert.Der beschriebe Algorithmus ist implementiert und wird von der STA Frassimulation[27] benutzt.

Page 76: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

List of Figures

1.1 A tool and the 5 milling axes it can move on. The x, y and z-axisare for three-axis-milling. In five-axis-milling, they are extended by therotational a and b-axis. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.2 An example picture of a small CNC milling machine with 5 axes. . . . . 2

1.3 Examples of a tool traces. The original pictures are in [12]. . . . . . . . 3

1.4 The layers inside the nc-milling simulation. Shaded areas are the partsdiscussed in this paper. . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2.1 Examples for the 6 possible classes, how a line can intersect a convexpolygon. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

2.2 A height grid. The vertices are lifted up where high values exist in theheight map. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2.3 The 15 classes of combinations, the marching cubes algorithm does dis-tinguish between. The algorithm classifies each cube of 8 vertices andgenerates a fragment of the polygonal surface as depicted. Blue spheresdenote vertices that are tested as inside the object. Green arrows denotethe direction of normals of the faces, that are generated. The picture wascopied from [25]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

3.1 A sample CDA. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

3.2 The negative cells of a CDA. Turquoise facets are bound up. . . . . . . 17

3.3 The zero cells of a CDA. . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

3.4 The positive top facet of the CDA. The negative facets, it is bound downare painted black. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

4.1 Two samples of intersecting bricks. Heavy lines are edges in E1. Dot-ted lines are edges in E2. The right sample depicts two independentcomponents of E1 while the left one shows only one connected component. 22

4.2 A crown. The different edge types are denoted by b, f and p. b are baseedges while forward edges are marked by a f and the prong by p. Right,you can see the crown projected on the sweep plane. . . . . . . . . . . . 23

4.3 Although no edge of the facet F penetrates the crown C1−i, they intersect.C1−i penetrates F . This intersection can only be found if the edges of acrown are tested against the facet. . . . . . . . . . . . . . . . . . . . . . 24

Page 77: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

LIST OF FIGURES 71

4.4 A 1-dimensional linear program is solved on the line hj . The feasibleinterval is marked red. We can find the optimal point on the line byfinding the maximum value of all proper intersection points. . . . . . . . 28

4.5 The initial hyperplanes intersect in a point p. This point is optimal tothe two halfspaces. The initial halfspaces are chosen in a way, that theyare the intersection of the bounding boxes of the two polytopes. . . . . . 29

4.6 When a halfspace is added and p is not above it, we have to find a new p. 30

4.7 A bad order for a 2-d-linear program. It produces a running time ofO(n2). Please note, that only this particular order is bad. . . . . . . . . 32

4.8 The cone spanned by the hyperplanes intersecting in the optimal vertex.We shoot a ray trough the middle of it an compute its interval inside thepolytope. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

4.9 A convex hull. The area seen by the eyepointis marked white. The borderof this area is the base for the cone created below the eyepoint. . . . . . 35

4.10 The horizon contour is computed by a counterclockwise depth search.The starting point is marked by a black dot. . . . . . . . . . . . . . . . . 36

4.11 Examples for the two classes of cases, where a facet of the intersection iscoplanar to facets of both of the two polytopes. . . . . . . . . . . . . . . 40

6.1 The UML diagram [9] of the static structure of the CDA package. . . . 52

7.1 The Performance of the ’simple.nc’ program. . . . . . . . . . . . . . . . 55

7.2 The Performance of the ’complex.nc’ program. . . . . . . . . . . . . . . 55

7.3 The workpiece generated by the ’simple’ program. . . . . . . . . . . . . 56

7.4 The workpiece generated by the ’complex’ program. . . . . . . . . . . . 57

7.5 The workpiece generated by the ’wave’ program. . . . . . . . . . . . . . 58

7.6 a. illustrates the time spent in different parts of the algorithm whenadding a negative cell. b. depicts the number of the different classes offacets and c. shows the development of the number of zero cells dividedby the number number of negative cells. This depicts the middle numberof intersection calls done in each step. . . . . . . . . . . . . . . . . . . . 60

8.1 Two negative cells intersecting in a zero cell. Many of the negative cellsfacets to completely match the surface of the zero cell. Instead of notrendering them at all, we render them twice. Once on the stencil andsecond time on the color buffer. . . . . . . . . . . . . . . . . . . . . . . . 62

8.2 This shows an example case for a negative facet, sketched in blue, that isoverlapped by a set of zero facets. As you can see, the (dark filled) areais the only one that is actually painted is relatively small. On the otherside (bright filled), the number of pixels rendered on the stencil buffer isvery high. A lot of these pixels even gets rendered multiple times. . . . 63

A.1 The Milling Simulation Package by STA using our algorithm. . . . . . . 67

Page 78: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

72 LIST OF FIGURES

A.2 A 3-dimensional model of the mill while it works on the wave program. 68

Page 79: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

Bibliography

[1] Austern, M. H. Generic programming and the STL: using and extending the C++Standard Template Library. Addison Wesley Longman, Inc., 1998.

[2] Barber, C. B., Dobkin, D. P., and Huhdanpaa, H. The quickhull algorithm forconvex hulls. ACM Transactions on Mathematical Software 22, 4 (1996), 469–483.

[3] Benouamer, M., and Michelucci, D. Bridging the gap between csg and brep via atriple ray representation. In Proceedings of the fourth symposium on Solid modeling andapplications (1997).

[4] Bowman, M., Debray, S. K., and Peterson, L. L. Reasoning about naming sys-tems. ACM Trans. Program. Lang. Syst. 15, 5 (November 1993), 795–825.

[5] Chazelle, B. An optimal algorithm for intersecting three-dimensional convex polyhe-dra. SIAM J. Comput. 21, 4 (1992), 671–696.

[6] Dantzig, G. B. Linear programming and extensions. Tech. rep., Princeton UniversityPress, Princeton, NJ, 1963.

[7] de Berg, M., van Kreveld, M., Overmars, M., and Schwarzkopf, O. Compu-tational Geometry - Algorithms and Applications. Springer, Heidelberg, 1997.

[8] Foley, J. D., van Dam, A., Feiner, S. K., and Hughes, J. F. Computer graphics:principles and practice. Addison Wesley Longman, Inc., 1990.

[9] Fowler, M., and Scott, K. UML distilled: a brief guide to the standard objectmodeling language, 2nd ed ed. Addison Wesley Longman, Inc., 1999.

[10] Gamma, E., Helm, R., Johnson, R., and Vlissides, J. Design Patterns: elementsof reusable object-oriented software. Addison Wesley Longman, Inc., 1995.

[11] The Geometry Center. Imprecision in Qhull.http://www.geom.umn.edu/software/qhull/html/qh-impre.htm, 2001.

[12] Glaeser, G., and Groller, E. Efficient volume-generation during the simulation ofnc-milling. Tech. rep., Institute of Computer Graphics and Algorithms, Vienna Univer-sity of Technology, A-1040 Karlsplatz 13/186/2, April 1997.

[13] Hertel, S., Mantyla, M., Mehlhorn, K., and Nievergelt, J. Space sweepsolves intersection of convex polyhedra. In Acta Informatica 21 (1984), Springer Verlag,pp. 501–519.

[14] Krishnaswamy, R., Alijani, G. S., and Su, S.-C. On constructing binary spacepartitioning trees. In Proceedings of the 1990 ACM annual conference on Cooperation(February 1990), pp. 230–235.

Page 80: Using Boolean Operations to Simulate CNC-Milling · PDF file4.9 Notes and Comments ... STA is a software company that specializes in creating simulations for CNC-machines. Its 3D Milling

74 BIBLIOGRAPHY

[15] Laidlaw, D. H., and Trumbore, W. B. Constructive solid geometry for polyhedralobjects. ACM 20, 4 (1986), 161–168.

[16] Lorensen, W. E., and Cline, H. E. Marching cubes: A high resolution 3d surfaceconstruction algorithm. In Proceedings of SIGGRAPH (1987), vol. 21, ACM, pp. 163–169.

[17] Megiddo, N. Linear-time algorithms for linear programming in r3 and related problems.SIAM J. Comput. 12, 4 (November 1983), 759–776.

[18] Muller, D. E., and Preparata, F. P. Finding the intersection of two convex poly-hedra. Theoretic Computer Science 7 (1978), 217–236.

[19] Purgarhofer, W., Tobler, R., and Galla, T. Acsgm - an adaptive csg meshingalgorithm. In Set theoretic Solid Modeling Techniques and Applications (1996), Proceed-ings of the CSG.

[20] Rappoport, A., and Spitz, S. Interactive boolean operations for conceptual design of3-d solids. In Computer Graphics Proceedings, Annual Conference Series (1997), ACMSIGGRAPH, pp. 269–278.

[21] Seidel, R. Small-dimensional linear programming and convex hulls made easy. InDiscrete Computational Geometry (1991), vol. 6, pp. 423–434.

[22] SGI. Sgi - opengl volumizer webpage.http://www.sgi.com/software/volumizer/.

[23] Shamos, M. I. Geometric complexity. In Proceedings of the 7th ACM STOC (1975),pp. 224–233.

[24] Shamos, M. I., and Hoey, D. Geometric intersection problems. In Proceedings of the17th IEEE FOCS Sympossium (1976), pp. 208–215.

[25] Sharman, J. The marching cubes algorithm.http://www.exaflop.org/docs/marchcubes/ind.html.

[26] Shreiner, D., Ed. OpenGL reference manual: the official reference document toOpenGL, version 1.2, 3rd edition ed. Addison Wesley, 2000.

[27] STA. The homepage of the sta gmbh.http://www.sta-soft.de.

[28] The VRML Consortium Incorporated. The Virtual Reality Modeling Language.http://www.vrml.org/technicalinfo/specifications/vrml97/index.htm, 1997.

[29] Woo, M., Neider, J., Davis, T., and Shreiner, D. OpenGL programming guide:The official guide to learning OpenGL, version 1.2, 3rd edition ed. Addison Wesley, 1999.

[30] Ziegler, G. M. Lectures on Polytopes. Springer, 1998.