Geometric Computations for Simulation

Similar documents
Basics of Computational Geometry

Other Voronoi/Delaunay Structures

Collision and Proximity Queries

2-D Geometry for Programming Contests 1

Computational Geometry

This blog addresses the question: how do we determine the intersection of two circles in the Cartesian plane?

Collision Detection. These slides are mainly from Ming Lin s course notes at UNC Chapel Hill

Elementary Planar Geometry

References. Additional lecture notes for 2/18/02.

11.2 RECTANGULAR COORDINATES IN THREE DIMENSIONS

Computational Geometry

Unit 12 Topics in Analytic Geometry - Classwork

Computational Geometry. Algorithm Design (10) Computational Geometry. Convex Hull. Areas in Computational Geometry

Problems of Plane analytic geometry

Multivariable Calculus

PS Computational Geometry Homework Assignment Sheet I (Due 16-March-2018)

COMPUTATIONAL GEOMETRY

Distance and Collision Detection

Polar Coordinates. 2, π and ( )

Geometry. Zachary Friggstad. Programming Club Meeting

Conjectures concerning the geometry of 2-point Centroidal Voronoi Tessellations

In what follows, we will focus on Voronoi diagrams in Euclidean space. Later, we will generalize to other distance spaces.

GEOMETRIC TOOLS FOR COMPUTER GRAPHICS

Planes Intersecting Cones: Static Hypertext Version

Background for Surface Integration

Chapter 2 Basic Structure of High-Dimensional Spaces

Lecture 25: Bezier Subdivision. And he took unto him all these, and divided them in the midst, and laid each piece one against another: Genesis 15:10

Critique for CS 448B: Topics in Modeling The Voronoi-clip Collision Detection Algorithm

Computational Geometry

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

Glossary of dictionary terms in the AP geometry units

Computational Geometry

2D/3D Geometric Transformations and Scene Graphs

Developmental Math An Open Program Unit 7 Geometry First Edition

Describe Plane Shapes

1. Use the Trapezium Rule with five ordinates to find an approximate value for the integral

CSCI 4620/8626. Coordinate Reference Frames

Collision detection. Piotr Fulma«ski. 1 grudnia

Lecture 2 - Introduction to Polytopes

Unit 1, Lesson 1: Moving in the Plane

Thomas Jefferson High School for Science and Technology Program of Studies TJ Math 1

08: CONTACT MODELLING 15/02/2016

Collision detection. Piotr Fulma«ski. 19 pa¹dziernika Wydziaª Matematyki i Informatyki, Uniwersytet Šódzki, Polska

Path Planning by Using Generalized Voronoi Diagrams and Dijkstra Algorithm. Lai Hon Lin. Project Proposal. Computational Geometry

Math 7 Glossary Terms

Week 8 Voronoi Diagrams

REGULAR POLYTOPES REALIZED OVER Q

Point A location in geometry. A point has no dimensions without any length, width, or depth. This is represented by a dot and is usually labelled.

Lesson 05. Mid Phase. Collision Detection

Analytic Geometry Vocabulary Cards and Word Walls Important Notes for Teachers:

Math 414 Lecture 2 Everyone have a laptop?

Lecture 5: Simplicial Complex

Computational Geometry. HKU ACM ICPC Training 2010

Course Number: Course Title: Geometry

Proof of Constant Width of Spheroform with Tetrahedral Symmetry

d f(g(t), h(t)) = x dt + f ( y dt = 0. Notice that we can rewrite the relationship on the left hand side of the equality using the dot product: ( f

Collision Detection of Cylindrical Rigid Bodies for Motion Planning

1 Proximity via Graph Spanners

High-Dimensional Computational Geometry. Jingbo Shang University of Illinois at Urbana-Champaign Mar 5, 2018

CS S Lecture February 13, 2017

A GENTLE INTRODUCTION TO THE BASIC CONCEPTS OF SHAPE SPACE AND SHAPE STATISTICS

Topic. Section 4.1 (3, 4)

Math 2 Coordinate Geometry Part 3 Inequalities & Quadratics

An angle that has a measure less than a right angle.

CURVES OF CONSTANT WIDTH AND THEIR SHADOWS. Have you ever wondered why a manhole cover is in the shape of a circle? This

Triangulation and Convex Hull. 8th November 2018

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

Answer Key: Three-Dimensional Cross Sections

1. CONVEX POLYGONS. Definition. A shape D in the plane is convex if every line drawn between two points in D is entirely inside D.

LECTURE 7. Announcements

Math 8 Honors Coordinate Geometry part 3 Unit Updated July 29, 2016

1/60. Geometric Algorithms. Lecture 1: Introduction. Convex Hulls

Collision Detection between Dynamic Rigid Objects and Static Displacement Mapped Surfaces in Computer Games

Planar Graphs. 1 Graphs and maps. 1.1 Planarity and duality

Tiling Three-Dimensional Space with Simplices. Shankar Krishnan AT&T Labs - Research

Convex Geometry arising in Optimization

7. The Gauss-Bonnet theorem

ACT Math test Plane Geometry Review

66 III Complexes. R p (r) }.

Lecture 16: Voronoi Diagrams and Fortune s Algorithm

ACT SparkNotes Test Prep: Plane Geometry

A GJK-Based Algorithm for Constrained Least Squares

MATH 890 HOMEWORK 2 DAVID MEREDITH

Geometric and Algebraic Connections

Deductive reasoning can be used to establish area formulas.

Identify parallel lines, skew lines and perpendicular lines.

Light: Geometric Optics

Clipping and Intersection

Voronoi diagram and Delaunay triangulation

Collision Detection CS434. Daniel G. Aliaga Department of Computer Science Purdue University

POLYHEDRAL GEOMETRY. Convex functions and sets. Mathematical Programming Niels Lauritzen Recall that a subset C R n is convex if

Appendix E Calculating Normal Vectors

Unit 1 Algebraic Functions and Graphs

Intersecting Simple Surfaces. Dr. Scott Schaefer

TOURNAMENT OF THE TOWNS, Glossary

Math 7, Unit 8: Geometric Figures Notes

The radius for a regular polygon is the same as the radius of the circumscribed circle.

(Refer Slide Time: 00:02:24 min)

What is dimension? An investigation by Laura Escobar. Math Explorer s Club

Chapter 8. Voronoi Diagrams. 8.1 Post Oce Problem

Transcription:

1 Geometric Computations for Simulation David E. Johnson I. INTRODUCTION A static virtual world would be boring and unlikely to draw in a user enough to create a sense of immersion. Simulation allows things to happen in the virtual world, either as initiated by a user, or autonomously. There are two main computational aspects to an effective simulation: setting up consistent physics for the world, so that reactions to events can be predicted, and accurate detection of events such as collisions, so that actions are initiated when expected, and not, for example, when a virtual hand is halfway through a virtual wall. Since contact and collision are the foundation for interaction between objects, these topics will be discussed first. The mathematics for this is often classified as geometric computation, and includes such things as collision detection, distance computations, and overlap measures. It is worth discussing what is meant by collision and distance measures and learning some simple ideas for computing these on modeling primitives such as lines and circles. A. Collision and Distance When you think of a collision, you probably think of some portion of two objects occupying (or trying to occupy) the same location in space. Many common-sense definitions can be more precisely defined using sets and set notation. The collision between two sets can be defined as C = {a = b : aɛa, bɛb} where A and B are two sets representing objects in the environment and C is the collision set. If C is empty, then there is no collision. The distance between two sets is more complicated. In general, when distance is used as a measure between two objects, what is really meant is the minimum distance between the two objects, as there are any number of distances between different parts of the objects. So, mindist(a, B) = min{dist(a, b) : aɛa, bɛb}. 1) Metrics and Norms: However, we have not yet defined what the distance between two elements, or points, in the sets is, so this definition is not yet complete. Distance is a function defined as a metric on a set M, where dist : M M R, and a metric space is (M, dist) which satisfies dist(a, b) = 0 a = b dist(a, b) = dist(b, a) dist(a, b) + dist(b, c) dist(a, c) Using these, we can show that dist(a, b) 0. dist(a, b) + dist(b, c) dist(a, c) Substituting a for c dist(a, b) + dist(b, a) dist(a, a) 2dist(a, b) dist(a, a) dist(a, b) 0 Most people think of Euclidean distance when they think of distance, defined for n-dimensional points a and b as

2 dist(a, b) = ( n a i b i 2 ) 1 2, which does satisfy the definition of a distance function in a metric space. There are a number of other distance metrics possible. Some examples are the Manhattan distance ( n ) dist(a, b) = a i b i, which corresponds to distance if you are only able to move in one dimension at a time, and the chessboard distance dist(a, b) = lim p ( n a i b i p ) 1 p, where diagonals have the same cost as axis-aligned movements. Other metrics are possible by using different values of p, but they have little practical importance. The concept of these different distance metrics is closely related to that of vector norms. A vector norm a p is defined as a p = ( n a i p ) 1 p. Since the difference between two points is a vector, these are essentially identical to the distance metrics. These vector norms are also known as L-p norms, such as L-1 and L-2 norms. 2) Dot, Inner, or Scalar Product: A convenient way of computing the Euclidean distance is to find the vector between the two points and compute its L-2 norm using the dot or inner product operation on vectors. The dot product for two vectors a and b is a b = n a i b i If a vector is dotted with itself, the squared L-2 norm results, since a a = n a i a i = n a i 2 = a 2 2 The dot product has several other nice properties which will be used in computing distances between geometric primitives. In the general case a b = a b cos θ, where θ is the angle between the vectors. Therefore, the dot product of perpendicular vectors is zero and the dot product of parallel vectors the product of their norms. If b is unit length, then the dot product a b is the projection of a onto b, or the length of a in the b direction. One can also think of projection as moving the head of a onto b as quickly as possible, or along the shortest path. So there is a connection between projection and computing minimum distance.

3 B. Geometric Computations on Modeling Primitives This idea of projection now leads to ways of computing distances between various geometric primitives, such as points, lines, circles, and triangles. A point projected onto a primitive gives the straight-line distance to that object, or the minimum distance. For example, the closest point on a plane P to a point a is the projection of a onto the plane. To make the connection between projection and minimum distance more explicit, consider the problem in a slightly different form. A plane can be defined as going through a set of vertices V 1, V 2, V 3, which create an internal coordinate system with axis vectors (V 2 V 1, V 3 V 1, N). This system then defines the plane in parametric form, T (u, v), where P (u, v) = V 1 + u(v 2 V 1 ) + v(v 3 V 1 ) (1) The distance, D, between a point a and every point on the plane is then D(u, v) = a P (u, v) (2) The closest point on the plane is the minimum of Equation 2. Minima, and really all extrema, occur at common zeros of the partial derivative of an equation. Since the distance, as expressed above, involves finding vector magnitude with a square root, a common trick is to use the squared distance instead. The squared distance shares roots with the Euclidean distance and has a simplified system of partial derivatives. Therefore, using the correspondence between the squared L-2 norm and dot product D 2 (u, v) = a P (u, v) 2 (3) = (a P (u, v)) (a P (u, v)). (4) The minimum distance occurs at simultaneous zeros of F, the system of partial derivatives of D 2 (u, v). In the following equation, partials are denoted by a subscripted parameter. The partials are found by using the chain rule on D 2 (u, v). F = [ ] D 2 u (u, v) Dv(u, 2 = v) [ ] 2(a P (u, v)) Pu (u, v) = 2(a P (u, v)) P v (u, v) [ ] 0. (5) 0 This probably does not seem like a very natural way to find the distance to a plane, and it would be computationally inefficient to use it directly. However, it does provide justification for the geometric projection operation used earlier. Looking at the system of partials, F, it describes the conditions that need to be met where there is a minima in distance. The condition is that the vector between a and the proposed solution point on the plane, P (u, v), must be orthogonal to both the surface tangents at P (u, v). This is because the dot product between that vector and each tangent must equal zero for F to be a root. An equivalent way of stating these constraints is that the vector between a and the proposed solution point must be parallel to the normal, since the normal is orthogonal to both surface tangents. Therefore, the projected straight-line distance concept is equivalent to the idea of projecting along the normal to find the closest point and this is an idea that is very easily translated into algorithmic form. 1) Distance from a Point to a Plane: A plane P can be defined implicitly with a point P a and a unit normal P N, as in P : (a P a ) P N = 0. All points a that satisfy this equation are part of the plane. Note that when a lies on P, then the vector a P a is orthogonal to the normal, so the dot product is zero. This plane equation is sometimes written as P : a P N + d = 0, where d = P a P N, which can be precomputed. The distance from a point a to the plane can be found by evaluating the plane equation. Note that the plane equation forms the vector a P a, and finds its projection onto the unit normal, thus giving its length in the normal direction. Since projecting along the normal gives the closest point on a surface, this projection is the minimum distance.

4 However, this is not quite correct. The point a may lie on either side of the plane, in which case the equation for distance can go negative, whereas distance should always be positive. The signed distance between two objects is useful in these cases and has other uses in computer simulation, like distingushing between contact and penetration. The closest point on the plane is the original point a moved along the normal by its distance to the plane. So the closest point cp is cp = a ((a P a ) P N )P N. 2) Distance from a Point to a Circle: Given a two-dimensional point a and a circle C in the plane with its center C c and radius C r. Then C is C : a C c C r = 0 The distance between a and C is just a plugged into the equation for the circle. Again, this can produce negative distances when a is inside the circle. Note that the normal at any point on a circle is the vector from that point to the circle center, so this fulfills the projection along the normal paradigm for closest point. 3) Distance from a Point to a Line: A line L in parametric form is defined by two points P 0 and P 1 L(t) = P 0 + t(p 1 P 0 ) The vector along the line (P 1 P 0 ) is usefully written as v L. The distance from a point a to the line L(t) can be found by projecting a onto the line, then computing the distance between the closest point projection and a. So the closest point cp on the line is ( cp = P 0 + (a P 0 ) v L ) vl v L v L and the distance is a cp. If you just want the distance and not the closest point, there is a clever trick using the properties of cross products showing that dist(a, L) = v L (a P 0 ). v L 4) Distance from a Point to a Line Segment: A line segment is a bounded line. The logic for distance from a point to a line segment is similar to that for a line, but the closest point must lie within the bounded line segment. This can be checked by seeing if the projection of a onto v L lies between zero and v L. 5) Circle-Circle Overlap: Collision tests are often easier than distance measures, but for simple primitives they are often equal in complexity. For two cirles C 0 and C 1, they are separated if their centers are further apart than the sum of their radii. So, collide(c 0, C 1 ) = C 0c C 1c (C 0r + C 1r ). 6) Line Segment-Line Segment Intersection: When line segments are generally positioned, then they intersect when the endpoints of each are on opposite sides of the line formed by the other line segment. One way is to find the vectors between the closest points on the line and the endpoints and to see if the vectors point in the same or different directions. Another approach is to use the cross product between the line vector and a vector from a line point to an endpoint, which either points out or into the plane depending on the direction. Care must be taken when dealing with degenerate cases where an endpoint lies on the other line. C. Contact and Distance for Convex Objects An important class of primitives are convex polytopes. Convexity is often loosely defined as the shape a rubber band would take when placed around a 2D object. More formally, a set is convex if the line segment between any two points in the set lies within the set. So a convex polytope also has no places where a line can cross out of the polytope and then back in again. In 2D, a polygon can be tested for convexity by checking the angle between all line segments; if the turn angle is always in the same direction then the polygon is convex.

5 1) The Convex Hull: The convex hull of a set of points X amde up of N points, p 1,..., p N, is the smallest convex set that contains X, basically the convex polytope made from some of the points and with all the other points in its interior. The convex hull is denoted CH(X). It can also be defined as the boundary of all possible weighted sums of the points where the weights are non-negative and sum to one, or ( N ) N CH(X) = boundary λ i p i : λ i 0 and λ i = 1 This may look fairly strange, but if you think of a line segment as a weighted combination of two points, then the line segment definition of convexity is a simplification of this. Convex objects are powerful in simulation because collision and distance can be computed very rapidly for them, yet many more complex shapes can be decomposed into sets of convex shapes. Many commercial physics engines rely on convex shapes as the primary primitive used. One could imagine processing collisions between two convex objects in a fashion similar to triangles that is, check for crossings of facets of one polytope with the other and then checking for total containment of each within the other. The facet crossing check is essentially a triangle-triangle intersection test, and as each facet of one has to be checked against all the facets of the other, this could require mn triangle tests for objects with m and n trianglular facets. Fortunately, faster methods exist. There are two seemingly different primary approaches, Minkowski difference methods, sometimes known as GJK methods for the authors that originally used the approach, and Voronoi diagram methods, originally proposed by Lin. 2) Minkowski Sum and Difference: The GJK approach is built upon a geometric operation known as the Minkowski sum, defined for two sets A and B as A B = a + b : aɛa, bɛb. This is often described as fattening A by B, or sweeping B around A. If this seems confusing, think of translating a shape B by some offset (x, y). The offset is added to each point in B. The Minkowski sum is just that operation, but by using every point in A for (x, y), resulting in a set of translated Bs. While the Minkowski sum is interesting, the closely related operation of Minkowski difference has some useful properties. The Minkowski difference is A B = a b : aɛa, bɛb. It is also the Minkowski sum of A and the reflection of B across the origin. The Minkowski difference can be used to determine collision, distance, and penetration between A and B. When A is colliding with B, then there is some point a = b : aɛa, bɛb, which implies that some point in the Minkowski difference is the origin. Note that this is not necessarily on the boundary of the difference, just that it is contained within the boundary. When we speak of the distance between A and B, the minimum distance is really meant. The minimum distance between A and B is just the smallest length between any two points in the sets, min( a b : aɛa, bɛb). which can be directly written in terms of the nearest point on the Minkowski difference to the origin O min( d : dɛa B). The penetration depth between A and B is the minimum translation needed to get A and B out of overlap. Since the Minkowski difference of the two contains the origin during overlap, this is equivalent to asking what is the closest point on the boundary to the origin. If one convex shape is moved that distance, then have moved apart. This is the same measure used for minimum distance, since the minimum distance tells how far the shapes need to move before they are in collision. While it is pleasant that these properties are directly recoverable from the Minkowski difference, they do not indicate whether it is efficient to do so in this space. GJK does make it efficient to work in this space by avoiding explicit computation of the Minkowski difference, and instead efficiently computing points on the boundary of the difference as needed.

6 3) GJK: The basic approach of GJK is to generate a series of simplices which shares vertices with the boundary of the Minkowski difference. A simplex in n-dimensions is the simplest shape with that dimensionality, or an n-dimensionsal analogue of a triangle. So for 3D objects, GJK uses a series of tetrahedra. If a tetrahedron contains the origin, then overlap has been detected between the original convex models. GJK can start with a random simplex. The origin is projected onto the simplex and tested for containment. If there is no containment, then the simplex is first reduced by a dimension by removing the vertex that does not support the face with the projected origin. Then the simplex is extended in the direction opposite the projection, in an effort to contain the origin. The new point for the simplex is found through a support mapping operation, which maps directions to points. The support point P for a given direction d is s A (d) = maxd (a origin) : aɛa. The support point is the point on the set furthest along the direction d. In GJK, d is opposite the projection of the origin onto the current simplex, so it tends to expand the simplex rapidly. One trick for efficiency is that the support mapping for the Minkowski difference can be decomposed into a linear combination of the mappings for the two convex shapes s A B (d) = s A (d) s B ( d) So the support mapping does not need to examine all vertices of the difference. GJK terminates either by containing the origin or by collapsing the simplex against the boundary of the Minkkowski difference, in which case the support mapping cannot find any new, closer vertices and the projection of the origin finds the minimum distance between A and B. GJK is particularly efficient for repeated calls, where the simplex from the previous step can be used to initialize the new search. Often only a single update to the simplex is needed to find the new distance or collision.