Computational Geometry Lab: SEARCHING A TETRAHEDRAL MESH

Similar documents
3D convex hulls. Computational Geometry [csci 3250] Laura Toma Bowdoin College

3D convex hulls. Computational Geometry [csci 3250] Laura Toma Bowdoin College

Weighted and Continuous Clustering

Basics of Computational Geometry

Suggested problems - solutions

Exploring Fractals through Geometry and Algebra. Kelly Deckelman Ben Eggleston Laura Mckenzie Patricia Parker-Davis Deanna Voss

THE TANGENT PLANE 6.1 INTRODUCTION TO THE TANGENT PLANE CHAPTER 6:

Steiner's Porism: An Activity Using the TI-92 Paul Beem Indiana University South Bend, IN

2-D Geometry for Programming Contests 1

Math 451: Euclidean and Non-Euclidean Geometry MWF 3pm, Gasson 204 Homework 8 Solutions

THE TANGENT PLANE 6.1 INTRODUCTION TO THE TANGENT PLANE CHAPTER 6:

Naming Angles. One complete rotation measures 360º. Half a rotation would then measure 180º. A quarter rotation would measure 90º.

Lesson 20: Exploiting the Connection to Cartesian Coordinates

Objective- Students will be able to use the Order of Operations to evaluate algebraic expressions. Evaluating Algebraic Expressions

Geometric Primitives. Chapter 5

Computational Geometry: Lecture 5

6th Bay Area Mathematical Olympiad

Calculus With Analytic Geometry by SM. Yusaf & Prof.Muhammad Amin CHAPTER # 08 ANALYTIC GEOMETRY OF THREE DIMENSONS. Exercise #8.1

Tight Cocone DIEGO SALUME SEPTEMBER 18, 2013

As a consequence of the operation, there are new incidences between edges and triangles that did not exist in K; see Figure II.9.

Lesson Plan #39. 2) Students will be able to find the sum of the measures of the exterior angles of a triangle.

An Interesting Way to Combine Numbers

The statement implies that any three intersection points of two distinct planes lie on a line.

CS195H Homework 5. Due:March 12th, 2015

1 Affine and Projective Coordinate Notation

Page 1 of 32. Website: Mobile:

Polygon Triangulation

Lecture 16: Voronoi Diagrams and Fortune s Algorithm

1 Vertical and Horizontal

COMP 175 COMPUTER GRAPHICS. Ray Casting. COMP 175: Computer Graphics April 26, Erik Anderson 09 Ray Casting

5200/7200 Fall 2007 Concurrence theorems for triangles

Differential Geometry: Circle Patterns (Part 1) [Discrete Conformal Mappinngs via Circle Patterns. Kharevych, Springborn and Schröder]

Engineering Mechanics Prof. Siva Kumar Department of Civil Engineering Indian Institute of Technology, Madras Statics - 4.3

Introduction to Quadratic Functions

Electrical Circuits and Random Walks: Challenge Problems

Electrical Circuits and Random Walks

3. Voronoi Diagrams. 3.1 Definitions & Basic Properties. Examples :

3D Modeling Parametric Curves & Surfaces

Rational Numbers and the Coordinate Plane

Analogy :24:47 / rev ebd

My Favorite Problems, 4 Harold B. Reiter University of North Carolina Charlotte

CS 532: 3D Computer Vision 14 th Set of Notes

If three points A (h, 0), P (a, b) and B (0, k) lie on a line, show that: a b 1.

3D Modeling Parametric Curves & Surfaces. Shandong University Spring 2013

How shapes are represented in 3D Graphics. Aims and objectives By the end of the lecture you will be able to describe

Unit 14: Transformations (Geometry) Date Topic Page

Chapter 8: Applications of Definite Integrals

Lecture 5. If, as shown in figure, we form a right triangle With P1 and P2 as vertices, then length of the horizontal

5 Applications of Definite Integrals

CSE 417 Dynamic Programming (pt 4) Sub-problems on Trees

Spherical Maze Generation

Paul's Online Math Notes Calculus III (Notes) / Applications of Partial Derivatives / Lagrange Multipliers Problems][Assignment Problems]

Mathematical Analysis of Tetrahedron (solid angle subtended by any tetrahedron at its vertex)

Linear Transformations

Discrete Exterior Calculus How to Turn Your Mesh into a Computational Structure. Discrete Differential Geometry

A simple problem that has a solution that is far deeper than expected!

Partial Derivatives. Partial Derivatives. Partial Derivatives. Partial Derivatives. Partial Derivatives. Partial Derivatives

Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 24 Solid Modelling

Intermediate Mathematics League of Eastern Massachusetts

Surfaces and Partial Derivatives

CS 109 C/C ++ Programming for Engineers w. MatLab Summer 2012 Homework Assignment 4 Functions Involving Barycentric Coordinates and Files

Practical Linear Algebra: A Geometry Toolbox

The Simplex Algorithm

ACT Math test Plane Geometry Review

COORDINATE GEOMETRY. 7.1 Introduction

Basic Triangle Congruence Lesson Plan

Surfaces and Partial Derivatives

ACT SparkNotes Test Prep: Plane Geometry

Boardworks Ltd KS3 Mathematics. S1 Lines and Angles

Caltech Harvey Mudd Mathematics Competition March 3, 2012

4. Simplicial Complexes and Simplicial Homology

2-9 Operations with Complex Numbers

CMPSCI611: The Simplex Algorithm Lecture 24

Lesson 9. Three-Dimensional Geometry

x y

The Distributive Property and Expressions Understand how to use the Distributive Property to Clear Parenthesis

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Shortest Paths Date: 10/13/15

Review for Mastery Using Graphs and Tables to Solve Linear Systems

COMPUTATIONAL GEOMETRY

Curvature Berkeley Math Circle January 08, 2013

Combinatorial Gems. Po-Shen Loh. June 2009

Chapter 1. Essentials of Geometry

Collisions/Reflection

Chapter 5. Transforming Shapes

Starting Boolean Algebra

SDC. Engineering Analysis with COSMOSWorks. Paul M. Kurowski Ph.D., P.Eng. SolidWorks 2003 / COSMOSWorks 2003

Computational Geometry

Slide 2 / 222. Algebra II. Quadratic Functions

Overview for Families

Elementary Planar Geometry

CS 410/584, Algorithm Design & Analysis, Lecture Notes 8!

SMMG September 16 th, 2006 featuring Dr. Jessica Purcell Geometry out of the Paper: An Introduction to Manifolds

Week 8 Voronoi Diagrams

Vector Calculus: Understanding the Cross Product

3.5 Equations of Lines and Planes

On a nested refinement of anisotropic tetrahedral grids under Hessian metrics

Mathematics 308 Geometry. Chapter 9. Drawing three dimensional objects

Basic Euclidean Geometry

Chapter 1. Linear Equations and Straight Lines. 2 of 71. Copyright 2014, 2010, 2007 Pearson Education, Inc.

GEOMETRIC OPTICS MIRRORS

Transcription:

Computational Geometry Lab: SEARCHING A TETRAHEDRAL MESH John Burkardt Information Technology Department Virginia Tech http://people.sc.fsu.edu/ jburkardt/presentations/cg lab search tet mesh.pdf December 23, 2010 1 Introduction This lab continues the topic of Computational Geometry. Having studied tetrahedrons and tetrahedral meshes (or tet meshes ), we will now turn to the question of searching. In particular, we will suppose that we have a computational region R, and a set of points P which are contained in R. (Actually, we will also allow the possibility that some points are outside the region.) We further suppose that we have constructed a tet mesh τ of R, consisting of t num tetrahedrons, with a typical tetrahedron indicated by T i. We now wish to know, for each point p i, the identity of the tetrahedron T i that contains the point. If the point is shared by several tetrahedrons, it is sufficient to give just one tetrahedron. If the point does not lie in any of the tetrahedrons, then we may be satisfied with a flag value of -1, or perhaps we would be interested in the index of a tetrahedron that is near to the point. We already know, from a previous lab, how to determine whether a point lies inside a tetrahedron. So if we have a tet mesh, and ask which tetrahedron contains a point, we could simply check each tetrahedron, stopping as soon as we find one. This would mean that on average we d have to check about t num/2 tetrahedrons. It s hard to imagine, but it s possible to carry out this task much faster. There is a method called the Delaunay search, which makes roughly only 3 t num/2 checks to locate a point in a tet mesh. It is not unusual for a tet mesh to have a million tetrahedrons, in which case the Delaunay method would be about 10,000 times faster than the straightforward searching method. This faster method only works on special tet meshes, namely, those that have the Delaunay property, which is explained and discussed in another lab. Moreover, a certain amount of preprocessing must be done in order to record which tetrahedrons are neighbors of each other. However, once that is done, the algorithm works beautifully, starting with a random tetrahedron as a first guess, and then walking from one tetrahedron to the next, more or less directly towards the correct one. 1.1 Where is a Point Relative to a Tetrahedron? Let us recall information from the lab on barycentric coordinates for tetrahedrons. We suppose we have a tetrahedron T={a,b,c,d} and a point p. The following function V(T) returns a quantity which is equal to the volume of the tetrahedron, possibly multiplied by -1. V = 1 a.x a.y a.z 1 b.x b.y b.z 1 6 c.x c.y c.z 1 d.x d.y d.z 1 1

The fact that there s a possibility of a minus sign isn t so important. The important thing is that the value of V(T) changes sign in a consistent way. In particular, if we fix three vertices of T but allow one vertex to move, then V(T) will stay the same sign until the vertex touches the plane of the other three vertices, and will switch sign if the vertex moves through that plane to the other side. This property allows us to compute barycentric coordinates of a point p with respect to a tetrahedron in essentially the same way we did for triangles. The barycentric coordinates of p are defined as: V(p, b, c, d) ξ a = V(a, p, c, d) ξ b = V(a, b, p, d) ξ c = V(a, b, c, p) ξ d = It should be clear that the sum of the barycentric coordinates is 1. Moreover, the values of the coordinates tell us about the position of p. If p is inside the tetrahedron, then all the coordinates are positive; on a face, one coordinate is zero; on an edge, two coordinates are 0; a vertex, three coordinates are 0, and one is 1; outside the tetrahedron, then one, two or perhaps three of the coordinates will be negative. In particular, if ξ a is negative, then relative to the face {b,c,d}, the point p lies on one side and vertex a on the other. Similar statements hold for the other three barycentric coordinates. 1.2 Program #1: Where is a Point Relative to a Tetrahedron? reads the definition of a tetrahedron T={a,b,c,d}; reads a point p; computes the barycentric coordinates (ξ a, ξ b, ξ c, ξ d ) of p with respect to T; prints p, the barycentric coordinates, and the word inside or outside, depending on whether p is inside T or not. Use the tetrahedron Tet1 defined by { {1.0, 2.0, 3.0} {4.0, 1.0, 2.0} {2.0, 4.0, 4.0} {3.0, 2.0, 5.0} } For p, use the points 2

Figure 1: The Channel tet mesh. {2.70, 2.40, 3.90}, {2.50, 2.25, 3.50}, {1.15, 3.80, 6.05}, {3.00, 2.00, 5.00}, {2.10, 3.00, 4.10}, {2.60, 3.10, 3.40} 1.3 Channel, an Example Tet Mesh For some of the coming exercises, we will want to have a simple tet mesh to work with. We will use the Channel tet mesh, which is illustrated and partially defined here. The full definitions of the arrays are available on the web site. There are 63 nodes in the mesh. The full data is available at http://people.sc.fsu.edu/ burkardt/latex/cg lab search tet mesh/channel nodes.txt. The first 20 entries of the node coordinate array for Channel are: 0.0 0.0 0.0 0.0 0.0 0.5 0.0 0.0 1.0 0.0 0.5 0.0 3

0.0 0.5 0.5 0.0 0.5 1.0 0.0 1.0 0.0 0.0 1.0 0.5 0.0 1.0 1.0 0.5 0.0 0.0 0.5 0.0 0.5 0.5 0.0 1.0 0.5 0.5 0.0 0.5 0.5 0.5 0.5 0.5 1.0 0.5 1.0 0.0 0.5 1.0 0.5 0.5 1.0 1.0 1.0 0.0 0.0 1.0 0.0 0.5 There are 144 elements in the mesh. The full data is available at http://people.sc.fsu.edu/ burkardt/latex/cg lab search tet mesh/channel elements.txt. The first 20 entries of the node element array are: 1 2 4 10 2 4 5 10 2 5 10 11 2 3 5 11 4 5 10 13 3 5 6 11 5 10 11 13 4 5 7 13 5 6 8 14 5 7 8 13 6 8 9 14 11 13 14 19 12 14 15 20 3 6 11 12 5 6 11 14 6 9 14 15 6 11 12 14 6 12 14 15 7 8 13 16 5 8 13 14 There are 144 rows in the neighbor array (to be defined shortly). The full data is available at http://people.sc.fsu.edu/ burkardt/latex/cg lab search tet mesh/channel neighbors.txt. The first 20 sets of neighbors are: 2-1 -1-1 5 3 1-1 7-1 4 2 6 3-1 -1 7-1 8 2 15 14 4-1 21 24 5 3 4

10-1 5-1 11 20 15-1 19 20 8-1 22 16 9-1 34 35 21 24 36 42 23 18 17-1 -1 6 17 24 9 6 26 18-1 11 23 18 15 14 13 16-1 17 25-1 -1 10 25 24 9 10 1.4 Where is a Point Relative to a Tet Mesh? Now suppose we have a tet mesh τ and a point p. How do we determine the index of the tetrahedron Ti that contains the point? How quickly can we do this? The obvious approach, known as the naive search, simply checks each tetrahedron. Such a search can take up to t num steps. If the point is guaranteed to be in at least one of the tetrahedrons, and if we stop as soon as we find that tetrahedron, the average number of steps is actually t num/2. When we check a tetrahedron Ti to see if it contains p, we actually simply compute the barycentric coordinates of p with respect to Ti. If all coordinates are nonnegative, we have found our tetrahedron. Otherwise, we prepare to check the next tetrahedron in the list. 1.5 Program #2: Where is a Point Relative to a Tet Mesh? Reads the element node and node coordinate arrays of a tet mesh τ; Reads a point p. Performs the naive search algorithm to find the tetrahedron containing p; Prints the tetrahedron index, and the number of steps required. For your tet mesh, use the Channel example. For your point p, try each of the following: {0.9,0.9,0.9}, {0.6,0.3,2.4}, {0.4,1.0,2.5}, {0.0,1.0,3.0}, {2.0, 0.5, 1.5}. It s possible that a point is not contained in any tetrahedron. In that case, let s print out the value -1 in place of the tetrahedron index. 1.6 The Neighbor Tetrahedron Array In order to apply a faster method for finding points in a tet mesh, we must define the neighbor tetrahedron array, a crucial piece of information that will help us find our way to the answer. The neighbor tetrahedron array is easily defined. If we think about the faces in a tet mesh, most of them are shared by two tetrahedrons. The exceptions occur if a face lies on the exterior boundary, or an internal hole of the region. So, given any tetrahedron in the tet mesh, we can ask, for each of its faces, whether there is another tetrahedron that shares that face, and if so what the index of that tetrahedron is. It will be convenient to call this array neighbor, and to assume it has the shape 4 x t num. We will also order the neighbors of tetrahedron t so that neighbor(1,t) is the neighbor across the face {b,c,d}, (and hence opposite the first node, a). Similarly, neighbors 2, 3 and 4 share faces {a,c,d}, {a,b,d} and {a,b,c} 5

respectively. It is of course possible that there is no neighbor that shares a given face. In that case, we can give that array entry the special value of -1. Consider the Channel tet mesh shown in the figure. Since a 3D figure is hard to label and to view, you ll probably want to refer to the element node table. If the nodes of element 9 are listed in the order {5, 6, 8, 14}, then the 9th row of the neighbor array will be {11, 20, 15, -1}. You can check that tetrahedron 9 shares nodes 6, 8 and 14 with its neighbor tetrahedron 11, which is why the first element of the 9th row of the neighbors array is 11. Similarly, depending on the ordering of the nodes in the 11th element, one of the entries in the 11th row of the neighbors array must be 9. These relationships are easy to track down one by one. But is it possible to compute, automatically, the whole array of neighbors, having only the element node array to work with? Imagine that we needed to know the neighbors of element 18. Tetrahedron 18 has the faces {6,12,14,15}, so it has faces {12,14,15}, {6,14,15}, {6,12,15} and {6,12,14}. To find the neighbors of tetrahedron 18, we have only to search the element node array for the occurrence of these faces. Of course, when looking for a neighbor along the face {12,14,15}, we have to consider the possibility that the nodes may occcur in this order or the reverse order. Then we also have to realize that, because of wrap around, the nodes 12, 14 and 15 can show up in the element node array in any one of eight ways: { 12, 14, 15, xx } { xx, 12, 14, 15 } { 15, xx, 12, 14 } { 14, 15, xx, 12 } { 12, xx, 15, 14 } { 14, 12, xx, 15 } { 15, 14, 12, xx } { xx, 15, 14, 12 } Since the tetrahedron can have at most one neighbor along a given face, just one of these 8 patterns can occur somewhere in the element node array. We can search for it by looking for the first node 12, then checking to see if the previous or next node is 14, and if so, whether the next (going in whichever is the appropriate direction) node is 15. While doing this, we have to think of the four entries in a row of the element node array as wrapping around in a circuit. The details of programming this search can be painful, but the idea is pretty straightforward. By considering each tetrahedron, and each face of that tetrahedron, and searching the element node array for occurrences of the sequence of nodes that form that face, we can construct the entire neighbor array. 1.7 Program #3: The Neighbor Tetrahedron Array Reads the element node array of a tet mesh τ; Constructs the tetrahedron neighbor array neighbor; Prints the tetrahedron neighbor array. For input to your program, use the Channel tet mesh. 1.8 Where is a Point Relative to a Delaunay Tet Mesh? Now let us see whether we can come up with a faster answer to our question about finding the tetrahedron in a tet mesh that contains a given point. It turns out that we can only promise a faster answer if we know that our triangulated region is convex, and that the tet mesh is a Delaunay tet mesh. These matters are discussed in the lab on Delaunay tet mesh; for this discussion, we will assume that these conditions are met. 6

Note, however, that the convexity condition means, in particular, that the tet mesh is guaranteed not to have any internal holes, or indentations in the outer boundary. The Delaunay search algorithm can be thought of as walking through the tet mesh, from one tetrahedron to a neighboring one, until the correct one is found. We start at a random tetrahedron. Our movement strategy rests on two key points: the barycentric coordinates tell us which direction we should move; the neighbor array tells us what tetrahedron lies in each direction. Let s make this more clear by imagining that our tet mesh is the Box3 example, that the point p is the centroid of tetrahedron t16, and that as our random starting point, we choose tetrahedron t8. Our walk begins by asking whether p actually lies in tetrahedron t8. We answer this question by computing the barycentric coordinates of p relative to t8. It turns out that two of the coordinates are negative, corresponding to the faces {3,8} and {8,7}. That means that we are on the wrong side of both of those faces. We may choose to move either north or east. Let s say we choose to go north. The neighbor array tells us that we have now moved to tetrahedron t9. Again we compute the barycentric coordinates of p. This time, only the coordinate corresponding to edge {8,12} is negative, so our only choice is to move east. The neighbor array tells us we ve moved to tetrahedron t10. We continue in this way until we reach t8, when the barycentric coordinates of p are all positive, so that we know we ve reached our goal. If we ever try to move in a particular direction, and discover that the neighbor array value is -1, then our search has terminated, and the point p actually lies outside the tet mesh. That is only true because we are assuming the tet mesh is convex. The walking procedure described here can fail if the tet mesh does not have the Delaunay property. In that case, the walk may end up going in a cycle instead of reaching the goal. To estimate the efficiency of the algorithm, we can start by supposing that we have t num tetrahedrons, that a typical tet mesh has a width and height and depth of about 3 t num, and a random starting tetrahedron might therefore be on average about 3 t num/2 tetrahedrons distant from the corrrect one. The naive search will typically search t num/2 tetrahedrons, and this means there s a considerable difference in performance between these two search methods. 1.9 Program #4: Where is a Point Relative to a Delaunay Tet Mesh? Reads the element node and node coordinate arrays of a tet mesh τ; Constructs the tetrahedron neighbor array neighbor; Reads a point p. Performs the Delaunay search algorithm to find the tetrahedron containing p; Prints the number of steps required. For your tet mesh, use the Channel example. For your point p, try each of the following: {0.9,0.9,0.9}, {0.6,0.3,2.4}, {0.4,1.0,2.5}, {0.0,1.0,3.0}, {2.0, 0.5, 1.5}. 7