2.4. Primitive Tests - Closest point

Slides:



Advertisements
Similar presentations
Everything you ever wanted to know about collision detection
Advertisements

Determinants and Areas. The intention here is to prove that application of a 2 x 2 matrix to regions of the plane multiplies the area by the absolute.
Higher Unit 3 Vectors and Scalars 3D Vectors Properties of vectors
2.4. Primitive Tests - Closest point
2.1. A SSUMED M ATHS Core mathematical underpinnings.
2.5. B ASIC P RIMITIVE I NTERSECTION Details of common forms of primitive intersection test.
Computational Geometry
ADA: 15. Basic Math1 Objective o a reminder about dot product and cross product, and their use for analyzing line segments (e.g. do two segments.
Intersection Testing Chapter 13 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
2.3. B OUNDING V OLUMES Bounding volumes of use for collision detection.
Collision Detection CSCE /60 What is Collision Detection?  Given two geometric objects, determine if they overlap.  Typically, at least one of.
Collision Detection and Resolution Zhi Yuan Course: Introduction to Game Development 11/28/
Geometry Primer Lines and rays Planes Spheres Frustums Triangles Polygon Polyhedron.
Computational Geometry II Brian Chen Rice University Computer Science.
Here is where my object is Here is where my object is going to be Here is where I want my object to be.
Advanced Computer Graphics Spring 2014

Vectors Strategies Higher Maths Click to start Vectors Higher Vectors The following questions are on Non-calculator questions will be indicated Click.
Collision Detection CSE 191A: Seminar on Video Game Programming Lecture 3: Collision Detection UCSD, Spring, 2003 Instructor: Steve Rotenberg.
Vectors.
Week 13 - Wednesday CS361.
Section 9.5: Equations of Lines and Planes
Geometric Intuition Randy Gaul. Vectors, Points and Basis Matrices Rotation Matrices Dot product and how it’s useful Cross product and how it’s useful.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
UNIVERSITI MALAYSIA PERLIS
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
Introduction to 3D Graphics Lecture 4: Scenes and Scene Graphs Anthony Steed University College London.
COMP 175: Computer Graphics March 24, 2015
1. Show geometrically that given any two points in the hyperbolic plane there is always a unique line passing through them. § 23.1 Given point A(x1, y1)
Physics 203 – College Physics I Department of Physics – The Citadel Physics 203 College Physics I Fall 2012 S. A. Yost Chapter 3 Motion in 2 Dimensions.
7.1 Scalars and vectors Scalar: a quantity specified by its magnitude, for example: temperature, time, mass, and density Chapter 7 Vector algebra Vector:
Higher Unit 2 EF Higher Unit 3 Vectors and Scalars Properties of vectors Adding / Sub of vectors Multiplication.
Chapter 5.1 Common Core - G.CO.10 Prove theorems about triangles…the segment joining the midpoint of two sides of a triangle is parallel to the third side.
Collision handling: detection and response
H.Melikyan/12001 Vectors Dr.Hayk Melikyan Departmen of Mathematics and CS
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
1.3 Lines and Planes. To determine a line L, we need a point P(x 1,y 1,z 1 ) on L and a direction vector for the line L. The parametric equations of a.
3.4. C ONTACT G ENERATION Generating contacts between rigid bodies.
Week 13 - Monday.  What did we talk about last time?  Exam 2!  Before that…  Polygonal techniques ▪ Tessellation and triangulation  Triangle strips,
Linear Interpolation (for curve 01).  This chapter discusses straight lines and flat surfaces that are defined by points.  The application of these.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
EXAMPLE 2 Use the Midsegment Theorem In the kaleidoscope image, AE BE and AD CD. Show that CB DE. SOLUTION Because AE BE and AD CD, E is the midpoint of.
Matrices A matrix is an array of numbers, the size of which is described by its dimensions: An n x m matrix has n rows and m columns Eg write down the.
DOT PRODUCT CROSS PRODUCT APPLICATIONS
1 Graphics CSCI 343, Fall 2015 Lecture 9 Geometric Objects.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
4. Affine transformations. Reading Required:  Watt, Section 1.1. Further reading:  Foley, et al, Chapter  David F. Rogers and J. Alan Adams,
Vectors Chapter 2.  Scalars and vectors : A scalar quantity: is a quantity that has magnitude only. Mass, time, speed, distance, pressure, Temperature.
Section 5.2 Perpendicular Bisectors Chapter 5 PropertiesofTriangles.
Core mathematical underpinnings
LESSON 90 – DISTANCES IN 3 SPACE
Chapter 3 VECTORS.
3D Coordinates In the real world points in space can be located using a 3D coordinate system. For example, air traffic controllers find the location a.
Coordinate Geometry – Outcomes
Collision handling: detection and response
C H A P T E R 3 Vectors in 2-Space and 3-Space
Higher Maths Vectors Strategies Click to start.
Introduction to Computer Graphics with WebGL
2.5. Basic Primitive Intersection
PMC and Booleans Point-Membership Classification
Ray Tracing Polyhedra ©Anthony Steed
Proving simple Geometric Properties by using coordinates of shapes
Similar Right Triangles
Computer Animation Algorithms and Techniques
11 Vectors and the Geometry of Space
VECTORS 3D Vectors Properties 3D Section formula Scalar Product
CHAPTER 3 VECTORS NHAA/IMK/UNIMAP.
Point To Triangle(intro)
GPAT – Chapter 7 Physics.
Presentation transcript:

2.4. Primitive Tests - Closest point Closest point forms of intersection detection

Closest point forms of intersection detection Finding the closest point between two objects provides a number of benefits. If positive, the objects are separated, if negative, the objects are interpenetrating (and knowledge of the closest point can be used to provide contact information). Two different approaches can be used to find the minimum point: Keeping a record of the closest points between two objects can often be incrementally maintained at a low cost (object coherency), providing fast collision testing. Formulate the test as a minimisation problem and solve it using calculus. Use the geometric properties of the objects to geometrically derive the closest point (considered here).

Forms of closest point test Consult the recommended course text for details of the following tests: Closest Point on Plane to Point Closest Point on Line Segment to Point Closest Point on AABB to Point Closest Point on OBB to Point Closest Point on Triangle to Point Closest Point on Convex Polyhedron to Point Closest Points of Two Lines Closest Points of Two Line Segments Closest Points of a Line Segment and a Triangle Closest Points of Two Triangles Two illustrative forms of closest point test are explored next.

Point to OBB Closest point between an OBB and a Point

Closest point on an OBB to a Point Consider an OBB with centre point C, orthogonal unit vectors (u0, u1, u2) and half-width distances (e0, e1, e2) and a point P.

Closest point on an OBB to a Point The closest point on/in the OBB to P can be determined by: Transforming the point P into the local coordinate system of the OBB, Computing the point on the OBB (now effectively an AABB) closest to the transformed point. Transforming the resulting point back into world coordinates

Closest point on an OBB to a Point ● P P-C (P-C)● uo u0 Transform P into the OBB coordinate system: The transformed point Q is found from: i.e. the distance vector of the point from the centre of the OBB as projected onto each defined OBB axis Qx = (P – C)● uo Qy = (P – C)● u1 Qz = (P – C)● u2

Closest point on an OBB to a Point ● P u0 u1 Q e1 e2 2. Computing OBB point closest to the transformed point. If the transformed point u0, u1, u2 distances are respectively longer than e0, e1, e2 then clamp to half- width extents 3. Transform the point back into world coordinates Qi = (P–C)● ui if(Qi>ei) Qi=ei if(Qi<-ei) Qi=-ei Qi = C + Qiui

Closest point on an OBB to a Point Expressed as code: ClosestPointToOBB(Point point, OBB box, out Point closestPt) { Vector distance = point- box.centre; closestPt = box.centre; for (int i = 0; i < 3; i++) { float length = Dot(distance, box.axis[i]); if (length > box.extent[i]) length = box.extent[i]; if (length < -box.extent[i]) length = -box.extent[i]; closestPt += length * box.axis[i]; } Initially set closest point as box centre Iterate over box axis Determine projection along axis Clamp if needed Build world location component by moving determine distance along OBB axis

Closest point on an OBB to a Point The separation (actual or squared) can then be determined simply as: float distance = (closestPt – point).length() Somewhat obviously, if all components of the closest OBB point (expressed in OBB space) are less than the half-width extents, then the point is within the OBB.

Point to Triangle Closest point between a Triangle and a Point

Closest point on a triangle to a point Given a triangle defined by points ABC and a point P, assume Q defines the point of ABC closest to P. An efficient means of computing Q is: Determine which triangle Voronoi region P is within (i.e. find which feature P is closest to). Orthogonally project P onto the determined closest feature. A B C Voronoi region of vertex A Voronoi region of edge CB

Closest point on a triangle to a point Intersection with the Voronoi region for vertex A, B and C can be determined as the intersection of the negative half-space of the two planes through that point, e.g. for A each plane passes through A, one with a normal (B- A) and the other with normal (C- A). A Voronoi region of vertex A C B

Closest point on a triangle to a point B C A Voronoi region of edge CB Closest point on a triangle to a point The Voronoi region of each triangle edge can be efficiently computed by determining the triangle barycentric coordinates of P. Assuming n is the normal of triangle ABC and R is the projection of P onto the triangle’s plane, i.e. R = P – tn some for t, the barycentric coordinates of R (R = uA + vB + wC) are given by: Aside: the barycentric coordinates of R are given as the ratios of the signed areas of triangles RAB, RBC, and RCA to the signed area of ABC n = (B-A)×(C-A) rab = n ● ((A-P)×(B-P)) rbc = n ● ((B-P)×(C-P)) rca = n ● ((C-P)×(A-P)) abc = rab + rbc + rca u = rbc/abc, v = rca/abc, w = rab/abc

Closest point on a triangle to a point To determine if P is within a triangle edge Voronoi region the following conditions must hold: B C A (X-A)●(B-A) > 0 (X-B)●(A-B) > 0 Calculated area of the barycentric region must be <= 0 (i.e. for AB, rab <= 0) The point must be within the positive half- spaces of the planes (assuming an edge AB): (X-A)●(B-A) = 0 and (X-B)●(A-B) = 0 Aside: It is not sufficient just to test if P is outside AB, in that for a triangle with an obtuse angle at A, P could be outside AB and actually be located in the Voronoi region of edge CA (see figure).

Closest point on a Triangle to a Point Points ABC defined the triangle, point P is the source point, point Q is the closest triangle point to P ClosestPointToTriangle( Point a, Point b, Point c, Point p, out Point q { Vector ab = b – a, ac = c – a, bc = c - b; float snom = Dot(p - a, ab), sdenom = Dot(p - b, a - b); float tnom = Dot(p - a, ac), tdenom = Dot(p - c, a - c); if (snom <= 0.0f && tnom <= 0.0f) return a; float unom = Dot(p - b, bc), udenom = Dot(p - c, b - c); if (sdenom <= 0.0f && unom <= 0.0f) return b; if (tdenom <= 0.0f && udenom <= 0.0f) return c; Build edge vectors Determine the parametric position s for the projection of P onto AB (i.e. P’ = A+s*AB, where s = snom/ (snom+sdenom), and then parametric position t for P projected onto AC Vertex Voronoi region hit early out Parametric position u for P projected onto BC Aside: the projection of P onto AB from point A is: (P-A)●(B-A) and from P onto BA is: (P-B)●(A-B). Added together they sum to the length of AB

Closest point on a Triangle to a Point Aside: The Lagrange identity (a × b) · (c × d) = (a · c)(b · d) − (a · d)(b · c) can be used to express the three scalar triple products in a manner that can be calculated more quickly. Determine if P is outside (or on) edge AB by finding the area formed by vectors PA, PB and the triangle normal. A scalar triple product is used. Vector n = Cross(b - a, c - a); float vc = Dot(n, Cross(a - p, b - p)); if (vc <= 0.0f && snom >= 0.0f && sdenom >= 0.0f) return a + snom / (snom + sdenom) * ab; float va = Dot(n, Cross(b - p, c - p)); if (va <= 0.0f && unom >= 0.0f && udenom >= 0.0f) return b + unom / (unom + udenom) * bc; float vb = Dot(n, Cross(c - p, a - p)); if (vb <= 0.0f && tnom >= 0.0f && tdenom >= 0.0f) return a + tnom / (tnom + tdenom) * ac; float u = va / (va + vb + vc); float v = vb / (va + vb + vc); float w = 1.0f - u - v; // = vc / (va + vb + vc) return u * a + v * b + w * c; } If P is outside of AB (signed area <= 0) and within Voronoi feature region, then return projection of P onto AB Repeat the same test for P onto BC Repeat the same test for P onto CA P must project onto inside face. Find closest point using the barycentric coordinates

Directed reading Directed Reading Directed mathematical reading

Directed reading Directed reading Read Chapter 5 (pp125-155) of Real Time Collision Detection Related papers can be found from: http://realtimecollisiondetection.net/books/rtcd/references/

To do: Summary Read the directed material Today we explored: Notion of closest point forms of intersection testing. Closest point to an OBB or triangle To do: Read the directed material After reading the directed material, have a ponder if this is the type of material you would like to explore within a project.