2.5. Basic Primitive Intersection

Slides:



Advertisements
Similar presentations
Collisions using separating-axis tests
Advertisements

Collisions using separating-axis tests Christer Ericson Sony Computer Entertainment
2.4. Primitive Tests - Closest point
2.5. B ASIC P RIMITIVE I NTERSECTION Details of common forms of primitive intersection test.
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.
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
Computational Geometry & Collision detection
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
By: Andrew Shatz & Michael Baker Chapter 15. Chapter 15 section 1 Key Terms: Skew Lines, Oblique Two lines are skew iff they are not parallel and do not.
Collision Detection CSE 191A: Seminar on Video Game Programming Lecture 3: Collision Detection UCSD, Spring, 2003 Instructor: Steve Rotenberg.
OBBTree: A Hierarchical Structure for Rapid Interference Detection Gottschalk, M. C. Lin and D. ManochaM. C. LinD. Manocha Department of Computer Science,
Collision Detection David Johnson Cs6360 – Virtual Reality.
Computer graphics & visualization Collision Detection – Narrow Phase.
Week 13 - Wednesday CS361.
12/4/2001CS 638, Fall 2001 Today Using separating planes/axes for collision testing Collision detection packages.
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.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
Haptic rendering Part 1 4/CY/B3 Part 1. Collision detection and response Nic Melder Part 2. Manipulation and polygon transitions (T.B.A.)
Collision handling: detection and response
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Collisions & Contact.
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,
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
Quadratic Equations and Functions
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Chapter Area, Pythagorean Theorem, and Volume 14 Copyright © 2013, 2010, and 2007, Pearson Education, Inc.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Advanced Computer Graphics Spring 2009
CS 551/651: Advanced Computer Graphics
Section 12-1 Exploring Solids. Polyhedron Three dimensional closed figure formed by joining three or more polygons at their side. Plural: polyhedra.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Week 13 - Wednesday CS361.
Volume and Surface Area
Computer Graphics Lecture 21 Triangles and Planes Taqdees A
Core mathematical underpinnings
Surface Area and Volume
Collision Detection Spring 2004.
Intersecting Simple Surfaces
In this section, we will learn about: Using integration to find out
Parts of these slides are based on
DIMENSION PLACEMENT By: Muhammad Zahid.
Collision handling: detection and response
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
SECTIONS OF SOLIDS Chapter 15
Geometry.
Geometry – Pre-requisite Skills Mr. Rosilez
10.1 Vocab Day 1 Grab a notes page from the back under Geometry on Wednesday Have notebook and homework out.
2.4. Primitive Tests - Closest point
Equations of Straight Lines
Day 151 – Arguments about volume of common solids
Ray Tracing Polyhedra ©Anthony Steed
Chapter 6: Analytic Geometry
Day 138 – Equation of ellipse
Chapter 6: Analytic Geometry
Computer Animation Algorithms and Techniques
Collision Detection.
CO Games Concepts Week 12 Collision Detection
Game Programming Algorithms and Techniques
David Johnson Cs6360 – Virtual Reality
Geometry.
3.3: Rectangle Collisions
GPAT – Chapter 7 Physics.
Separating Axis Theorem (SAT)
Presentation transcript:

2.5. Basic Primitive Intersection Details of common forms of primitive intersection test

Basic Primitive Intersection Tests Basic primitive intersection testing concerns determining if two primitives intersect. Testing if two primitives intersect is often easier (and faster) than determining how two primitives intersect (e.g. generating contact information such as the distance of interpenetration, etc.).

Types of basic primitive test Consult the recommended course text for details of the following tests: Separating-axis test Sphere against plane Box against plane Cone against plane Sphere against AABB Sphere against OBB Sphere against triangle Sphere against polygon AABB against polygon Triangle against triangle Two illustrative forms of closest point test are explored next.

Separating Axes Overview of the separating axis theory

Separating-axis test The separating-axis test provides a core tool for implementing a range of intersection tests. The test is based on the separating hyperplane theorem, which states that given two convex sets A and B, either the two sets are intersecting or there exists a separating hyperplane P such that A is on one side of P and B is on the other. The theory is intuitive as two convex objects cannot “curve” around each other. Thus, when they are not intersecting there will be a gap between them into which a plane can be inserted to separate the two objects.

Separating-axis test A separating axis is a line which is perpendicular to some separating hyperplane. It is called a separating axis because the orthogonal projections of A and B onto the separating axis result in two non-overlapping intervals. In principle, a test for a separating axis or hyperplane is equally valid, however, in practice, it is less expensive to test for separation on an axis.

Separating-axis test: Symmetrical primitives For symmetrical primitives with a defined centre point (e.g. AABBs, OBBs, spheres, etc.), the centre point will always project onto the middle of the projection interval along the tested axis. An efficient separation test of two symmetrical objects A and B is to compute the halfwidth, or radii, of their projection intervals and compare the sum of them against the distance between their centre projections. If the sum is less than the distance between the centre projections, the objects must be disjoint.

Separating-axis test: Arbitrary primitives Given two arbitrary convex hulls (i.e. polyhedra) the following forms of intersection are possible: face-face, face-edge, and edge-edge. For face-face and face-edge cases, the face normals of both objects should be tested as potential separating axes. For edge-edge case, the cross product of the two edges should be tested as the potential separating axis (the points on the edges closest to each other form the feet of a perpendicular between the two edges). In summary, to determine intersection of two polyhedral objects, the following axes should be tested for separation: Aside: More fully: this list also includes face-vertex, edge-vertex and vertex-vertex, however, the vertex combinations can be considered a special case of edge contact. Axes parallel to face normals of object A Axes parallel to face normals of object B Axes parallel to the vectors resulting from the cross products of all edges in A with all edges in B

Separating-axis test: Arbitrary primitives As soon as a separating axis is found, a test can exit immediately, i.e. it is not until all identified axes have been tested with no separating axis that the objects must be intersecting. Aside: The separating-axis test can also be used to derive contact information, e.g. instead of exiting early when an overlap is detected, all axes are tested for overlap. After all axes have been tested, the axis with the least (normalized) overlap can be used as the contact normal, and the overlap can be used to estimate the penetration depth. With some extra work, contact points can also be computed with the help of the separating axis.

Sample Plane Intersection Tests Sphere and box plane-intersection tests

Sphere vs Plane Intersection It is possible to test a sphere against a plane in several ways, e.g. testing if the sphere intersects the plane, or if the sphere intersects the negative halfspace of the plane. bool TestSphereAndHalfspace( Sphere sphere, Plane plane) { float separation = Dot(sphere.Centre, plane.Normal) - plane.Distance; return separation <= sphere.Radius; }

Box vs Plane Intersection Given that the box vertices represent the points furthest away from the centre of the box, they need only be compared for distance against the plane. By projecting each vertex along the plane’s normal and accumulating the result, the maximum projection radius is obtained. Comparing this to the distance of the OBB’s centre from the plane determines if it is in intersection. C ● Projected radius e0 (P-C)● uo u0 u1 n e1 Centre-plane distance

Box vs Plane Intersection ● Projected radius e0 (P-C)● uo u0 u1 n e1 Centre-plane distance Box vs Plane Intersection bool IsOBBIntersectingPlane(OBB box, Plane plane) { float radius = box.e[0] * abs( dot( plane.n, box.u[0] ) ) + box.e[1] * abs( dot( plane.n, box.u[1] ) ) + box.e[2] * abs( dot( plane.n, box.u[2] ) ); float distance = dot( plane.n, box.c ) – plane.d; return abs(distance) <= radius; } Accumulate the projections of each box half-width along the plane normal to determine the total box radius along towards the plane. Determine distance of box’s centre from the plane Intersection if distance is within ±radius

Ray Intersection Tests Intersection tests involving rays

Intersecting lines rays and segments Consult the recommended course text for details of the following tests: Intersecting segment against plane Intersecting ray or segment against sphere Intersecting ray or segment against box Intersecting line against triangle Intersecting line against quadrilateral Intersecting ray or segment against triangle Intersecting ray or segment against convex polyhedron An illustrative form of ray test is explored next.

Ray or Segment vs. Sphere Given a ray defined as R(t) = P + td, t ≥ 0, where P is the ray origin and d the normalized direction vector (for a defined segment 0 ≤ t ≤ tmax). For a sphere defined as (X-C)●(X-C)=r2, the point(s) of intersecti0n can be found by substituting R(t) for X and solving for values of t, i.e. Rearranging the above provides a quadratic expression in terms of t, i.e.: Solving for t will enable the points of intersection to be determined, i.e. t = -b±√(b2-c) where b=m●d and c=(m●m)-r2 Zero, one or two solutions will be found, negative solutions should be ignored! (P+td-C)●(P+td-C)=r2 t2 + 2(m●d)t+(m●m)-r2 = 0, where m=P-C

Ray or Segment vs. Sphere bool IntersectRaySphere( Point p, Vector d, Sphere s, out float t, out Point q) { Vector m = p - s.c; float b = dot(m, d); float c = dot(m, m) - s.r * s.r; if (c > 0.0f && b > 0.0f) return false; float discr = b*b - c; if (discr < 0.0f) return false; t = -b - sqrt(discr); if (t < 0.0f) t = 0.0f; q = p + t * d; return true; } P ● r C d t Q Determine b and c for use within t = -b±√(b2-c) Return false if the ray origin is outside of the sphere (i.e. c>0) and pointing away from the sphere (b>0) If the discriminant is negative, i.e. No real solutions, then the ray misses sphere Determine the smallest (non-negative) value of t which gives the nearest point of intersection. If negative, then clamp to zero (ray started within sphere)

Directed Reading Directed reading on primitive intersection Directed

Directed reading Read Chapter 5 of Real Time Collision Detection: pp156-174 for primitive intersection tests pp175-200 for line, ray and segment intersection pp201-231 for dynamic and other forms of intersection test Related papers can be found from: http://realtimecollisiondetection.net/books/rtcd/references/

To do: Summary Read the directed material Today we explored: Basic primitive intersection tests Separating axis theory Sample plane and ray intersection tests 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.