Advanced Computer Graphics Spring 2009

Slides:



Advertisements
Similar presentations
2.5. B ASIC P RIMITIVE I NTERSECTION Details of common forms of primitive intersection test.
Advertisements

Intersection Testing Chapter 13 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
CSE 681 Bounding Volumes. CSE 681 Bounding Volumes Use simple volume enclose object(s) tradeoff for rays where there is extra intersection test for object.
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/
Computer graphics & visualization Collisions. computer graphics & visualization Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization.
Geometry Primer Lines and rays Planes Spheres Frustums Triangles Polygon Polyhedron.
Ray Tracing CMSC 635. Basic idea How many intersections?  Pixels  ~10 3 to ~10 7  Rays per Pixel  1 to ~10  Primitives  ~10 to ~10 7  Every ray.
APPLICATIONS OF INTEGRATION
Extended Gaussian Images
Here is where my object is Here is where my object is going to be Here is where I want my object to be.
CHAPTER 12 Height Maps, Hidden Surface Removal, Clipping and Level of Detail Algorithms © 2008 Cengage Learning EMEA.
Convex Hulls in Two Dimensions Definitions Basic algorithms Gift Wrapping (algorithm of Jarvis ) Graham scan Divide and conquer Convex Hull for line intersections.
Advanced Computer Graphics Spring 2014
CS 450: Computer Graphics OVERVIEW OF POLYGONS
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.
CS447/ Realistic Rendering -- Solids Modeling -- Introduction to 2D and 3D Computer Graphics.
Discrete geometry Lecture 2 1 © Alexander & Michael Bronstein
Informationsteknologi Thursday, November 22, 2007Computer Graphics - Class 111 Today’s class Clipping Parametric and point-normal form of lines Intersecting.
Christian Lauterbach COMP 770, 2/11/2009
Collision Detection CSE 191A: Seminar on Video Game Programming Lecture 3: Collision Detection UCSD, Spring, 2003 Instructor: Steve Rotenberg.
1 Geometry A line in 3D space is represented by  S is a point on the line, and V is the direction along which the line runs  Any point P on the line.
Geometric Modeling Surfaces Mortenson Chapter 6 and Angel Chapter 9.
OBBTree: A Hierarchical Structure for Rapid Interference Detection Gottschalk, M. C. Lin and D. ManochaM. C. LinD. Manocha Department of Computer Science,
Apex Point Map for Constant-Time Bounding Plane Approximation Samuli Laine Tero Karras NVIDIA.
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.
Chapter 15: Geometric Solids Brian BarrDan Logan.
Photo-realistic Rendering and Global Illumination in Computer Graphics Spring 2012 Stochastic Radiosity K. H. Ko School of Mechatronics Gwangju Institute.
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
Week 15 - Friday CS361.
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
CSE 381 – Advanced Game Programming Quickhull and GJK.
Collision handling: detection and response
UNC Chapel Hill M. C. Lin Linear Programming Reading: Chapter 4 of the Textbook Driving Applications –Casting/Metal Molding –Collision Detection Randomized.
CS 325 Introduction to Computer Graphics 04 / 26 / 2010 Instructor: Michael Eckmann.
Week 13 - Friday.  What did we talk about last time?  Ray/sphere intersection  Ray/box intersection  Slabs method  Line segment/box overlap test.
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Collisions & Contact.
Week 13 - Monday.  What did we talk about last time?  Exam 2!  Before that…  Polygonal techniques ▪ Tessellation and triangulation  Triangle strips,
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
10.7 Moments of Inertia for an Area about Inclined Axes
PRESENTED BY – GAURANGI TILAK SHASHANK AGARWAL Collision Detection.
1 KIPA Game Engine Seminars Jonathan Blow Ajou University December 6, 2002 Day 10.
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
1 Dr. Scott Schaefer Intersecting Simple Surfaces.
3D Game Engine Design 1 3D Game Engine Design Ch D MAP LAB.
Arrangements and Duality Motivation: Ray-Tracing Fall 2001, Lecture 9 Presented by Darius Jazayeri 10/4/01.
Chapter 11 Collision Detection 가상현실 입문 그래픽스 연구실 민성환.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
1 11. Polygons Polygons 2D polygons ( 다각형 ) –Polygon sides are all straight lines lying in the same plane 3D polyhedra ( 다면체 )  chap. 12 –Polyhedra.
Presented by Paul Phipps
Robust Watermarking of 3D Mesh Models. Introduction in this paper, it proposes an algorithm that extracts 2D image from the 3D model and embed watermark.
Geometry Vocabulary. Triangle Triangle: a polygon with three sides. 180⁰ Sum of the interior angles of a triangle = 180⁰.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
Week 13 - Wednesday CS361.
Collision Detection Spring 2004.
Parts of these slides are based on
Collision handling: detection and response
2.5. Basic Primitive Intersection
Computer Animation Algorithms and Techniques
Collision Detection.
David Johnson Cs6360 – Virtual Reality
GPAT – Chapter 7 Physics.
Presentation transcript:

Advanced Computer Graphics Spring 2009 K. H. Ko Department of Mechatronics Gwangju Institute of Science and Technology

Today’s Topics Intersection Test Methods Ray/object Object/object

Introduction Intersection testing is often used in computer graphics. Click the mouse on an object. (Object picking) Determine whether two objects collide. Make sure we maintain a constant height for our viewer as we navigate a building.

Definitions and Tools A ray r(t) is defined by an origin point o and a direction unit vector, d. r(t) = o + td. The scalar t is a variable that is used to generate different points on the ray. t < 0 : points that lie behind the ray origin (not part of the ray). t > 0 : points that lie in front of the origin. In practice we often store a current distance l, which is the maximum distance we want to search along the ray.

Definitions and Tools Implicit Surfaces Explicit Surfaces A surface defined by an implicit function f(p) = f(px,py,pz) = 0. Explicit Surfaces A surface defined by a vector function f and some parameters rather than a point on the surface f(u,v) = (fx(u,v),fy(u,v),fz(u,v))

Definitions and Tools Three Bounding Volumes AABB: Axis-Aligned Bounding Box OBB: Oriented Bounding Box k-DOP: k – Discrete Oriented Polytope

Definitions and Tools AABB An Axis-aligned Bounding Box (also called rectangular box), is a box whose faces have normals that coincide with the standard basis axes.

Definitions and Tools OBB An Oriented Bounding Box is a box whose faces have normals that are all pairwise orthogonal. It is an AABB that is arbitrarily rotated.

Definitions and Tools K-DOP A k-Discrete Oriented Polytope is defined by k/2 (where k is even) normalized normals (orientations), ni, 1 ≤ i ≤ k/2 and with each ni, two associated scalar values dimin and dimax where dimin < dimax. Each triple(ni,dimin,dimax) describes a slab, Si, which is the volume between the two planes, пimin : niᆞx + dimin = 0 and пimax : niᆞx + dimax = 0 and where the intersection of all slabs, ∩1≤l ≤k/2 Sl is the actual k-DOP volume.

Definitions and Tools K-DOP An 8-DOP in two dimensions

Definitions and Tools Separating Axis Theorem (SAT) For any two arbitrary, convex, disjoint polyhedra, A and B, there exists a separating axis where the projections of the polyhedra, which form intervals on the axis, are also disjoint.

Definitions and Tools Separating Axis Theorem (SAT) If A and B are disjoint, then they can be separated by an axis that is orthogonal to either a face of A a face of B An edge from each polyhedron

Bounding Volume Creation Given a collection of objects, finding a tight fitting bounding volume is important to minimizing intersection costs. The chance that an arbitrary ray will hit any convex object is proportional to that objects’ surface area. Minimizing this area increases the efficiency of any intersection algorithm as a rejection is never slower to compute than an intersection. It is often better to minimize the volume of BV for collision detection algorithms.

AABB and k-DOP Creation The simplest bounding volumes to create is an AABB. Take the minimum and maximum extents of the set of polygon vertices along each axis and the AABB is formed.

AABB and k-DOP Creation Project the vertices onto each normal, ni, of the k-DOP. Extreme values (min,max) of these projections are stored in dimin and dimax. These two values define the tightest slab for that direction. Together, all such values define a minimal k-DOP.

Sphere Creation Form an AABB for the polygon set and then use the center and the diagonal of this box to form the sphere. This sometimes gives a poor fit, and the fit can often be improved by another quick pass. Starting with the center of the AABB as the center of the sphere BV. Go through all vertices once again and find the one that is farthest from this center. This is then the new radius.

Sphere Creation Ritter’s algorithm: a near optimal bounding sphere. Find the vertex that is at the minimum and the vertex at the maximum along each of the x, y and z axes. For these three pairs of vertices, find the pair with the largest distance between them. Use this pair to form a sphere with its center at the midpoint between them and a radius equal to the distance to them. Go through all the other vertices and check its distance d to the center of the sphere. If the vertex is outside the sphere’s radius r, move the sphere’s center toward the vertex by (d-r)/2, set the radius to (d+r)/2 and continue. This step has the effect of enclosing the vertex and the existing sphere in a new sphere. After this second time through the list, the bounding sphere is guaranteed to enclose all vertices.

Sphere Creation Welzl’s algorithm Expected to be linear for a randomized list of vertices. The idea is to find a supporting set of points defining a sphere. When a vertex is found to be outside the current sphere, its location is added to the supporting set. The new sphere is computed and the entire list is run through again. This process repeats until the sphere contains all vertices. This algorithm guarantees that an optimal bounding sphere is found.

OBB Creation Gottschalk’s method A tight-fitting OBB enclosing an object can be found by computing an orientation from the triangles of the convex hull. Formulae for computing a good fit OBB using a statistical method The convex hull of an object must be computed. O(nlog(n)). Quickhull algorithm. This gives us n triangles defined as Δpkqkrk, (vertices of triangle k), the area of triangle k as ak, and the total area of the convex hull as aH, the sum of ak.

OBB Creation Gottschalk’s method The convex hull of an object must be computed. O(nlog(n)). The centroid of the whole convex hull, mH.: the weighted mean of the triangle centroids. Construct a 3 by 3 covariance matrix C.

OBB Creation Gottschalk’s method Compute the eigenvalues of C, which are the direction vectors for a good-fit box, au, av, and aw. Find the center and the half-lengths of the OBB. This is done by projecting the points of the convex hull onto the direction vectors and finding the minimum and maximum along each direction. This will determine the size and position of the box and fully specify the OBB according to its definition.

OBB Creation Eberly’s method A method for computing a minimum-volume OBB using a minimization technique.- Iterative algorithm. The convex hull need not be computed. For a box with the axis au, av and aw, the points are projected onto these axes. The min, kumin and kumax along au are found. Then, kvmin, kvmax, kwmin, and kwmax are computed similarly. The center of this box is then

OBB Creation Eberly’s method The set of possible directions of the box are sampled and the axes are used whose box is smallest as a starting point for the numeric minimizer. Then Powell’s direction set method is used to find the minimum volume box.

Rules of Thumb For faster, more robust and more exact intersection tests, Perform computations and comparisons that might trivially reject or accept various types of intersections to obtain an early escape from further computations. If possible, exploit the results from previous tests. If more than one rejection or acceptance test is used, then try changing their internal order, since a more efficient test may result. Do not assume that what appears to be a minor change will have no effect. Postpone expensive calculations until they are truly needed. The intersection problem can often be simplified considerably by reducing the dimension of the problem.

Rules of Thumb For faster, more robust and more exact intersection tests, If a single ray or object is being compared to many other objects at a time, look for precalculations that can be done just once before the testing begins. Whenever an intersection test is expensive, it is often good to start with a sphere around the object to give a first level of quick rejection. Make it a habit always to do timing comparisons on your computer, and use real data and testing situations for the timings. Try to make your code robust. This means it should work for all special cases and that it will be insensitive to as many floating point precision errors as possible. Be aware of any limitations it may have.

Ray/Sphere Intersection Mathematical solution A sphere can be defined by a center point, c, and a radius r. f(p) = ||p-c|| - r = 0, p is any point on the sphere’s surface. Given a ray r(t), we can find the intersections as follows: f(r(t)) = ||r(t) –c|| - r = 0.

Ray/Sphere Intersection Mathematical solution The equation is of quadratic form t2+2tb+c=0, b=dᆞ(o-c), c = (o-c)ᆞ(o-c) - r2.

Ray/Sphere Intersection For the other quadrics, e.g., the cylinder, ellipsoid, cone and hyperboloid, the mathematical solutions to their intersection problems are almost as straightforward as for the sphere. Sometimes, it is necessary to bound a surface (cylinder).

Ray/Sphere Intersection Optimized Solution Intersections behind the ray origin are not needed. Compute a vector l = c – o, the vector from the ray origin to the center of the sphere. The squared length of the vector : l2 = lᆞl. If l2 < r2, the ray origin is inside the sphere. This guarantees that the ray hits the sphere.

Ray/Sphere Intersection Optimized Solution Compute the projection of l onto the ray direction d: s = lᆞd. If s < 0 and the ray origin is outside the sphere, then the sphere is behind the ray origin and we can reject the intersection. Otherwise, the squared distance from the sphere center to the projection is computed using the Pythagorean theorem: m2 = l2-s2. If m2 > r2 the ray will definitely miss the sphere and the rest of the calculations can safely be omitted. If the sphere and ray pass this last test, then the ray is guaranteed to hit the sphere.

Ray/Sphere Intersection Optimized Solution Computation of the real intersection points Calculate the squared distance q2 = r2 – m2. Since m2 <= r2, q = q1/2 The distances to the intersections are t = s ± q If we are interested in only the first, positive intersection point, then t1 = s – q for the case where the ray origin is outside the sphere. t2 = s + q when the ray origin is inside.

Ray/Sphere Intersection Optimized Solution Computation of the real intersection points

Ray/Box Intersection Three methods for determining whether a ray intersects a box are introduced. Both AABBs and OBBs Faster than the first one but can deal with only the simpler AABB. Based on the separating axis theorem and handles only line segments versus AABBs.

Ray/Box Intersection (Slabs Method) A slab is the volume between the two parallel planes. A box is considered to be a set of three slabs in 3D (2 in 2D)

Ray/Box Intersection (Slabs Method) For each slab, there is a minimum and a maximum t-value and these are called tmini and tmaxi i = u, v, w. The next step is to compute the variables as follows tmin = max(tminu,tminv,tminw) tmax = min(tmaxu,tmaxv,tmaxw) The clever test: If tmin ≤ tmax, then the ray intersects the box. Otherwise it misses. A generalized of the slabs method can be used to compute the intersection of a ray with a k-DOP, frustum, or any convex polyhedron.

Ray/Box Intersection (Woo’s Method) Some smart optimizations for finding the intersection between a ray and an AABB. Given a ray and an AABB, denoted B, the idea is to identify three candidate planes out of the six planes composing the AABB. For each pair of parallel planes, the back-facing plane can be omitted from further consideration. After finding these three planes, we compute the intersection distances (t-values) between the ray and the planes. The largest of these distances corresponds to a potential hit.

Ray/Box Intersection (Woo’s Method) If a potential hit is found, the actual intersection point is computed. If it is located on the corresponding face of B, then it is a real hit. d o

Ray/Box Intersection (Line Segment/Box Overlap Test) The separating axis theorem can be used to determine whether a line segment overlaps an AABB. The line segment has finite length in contrast to a ray. The line segment is defined by a center c and a half vector w. Both the AABB, denoted B, and the line segment have been translated so the AABB’s origin is (0,0,0). The size of the box is (2hx,2hy,2hz), h is the half vector of the box.