Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.

Slides:



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

Christian Lauterbach COMP 770, 2/16/2009. Overview  Acceleration structures  Spatial hierarchies  Object hierarchies  Interactive Ray Tracing techniques.
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
Intersection Testing Chapter 13 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
HAWKES LEARNING SYSTEMS math courseware specialists Copyright © 2011 Hawkes Learning Systems. All rights reserved. Hawkes Learning Systems: College Algebra.
Review for Test 3.
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.
Course Website: Computer Graphics 4: Viewing In 2D.
Computer Graphics Viewing.
Viewing & Clipping In 2D. 2 of 44 Contents Windowing Concepts Clipping –Introduction –Brute Force –Cohen-Sutherland Clipping Algorithm Area Clipping –Sutherland-Hodgman.
CMPE 466 COMPUTER GRAPHICS Chapter 8 2D Viewing Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth Edition by Donald Hearn,
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
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.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Collision Detection CSE 191A: Seminar on Video Game Programming Lecture 3: Collision Detection UCSD, Spring, 2003 Instructor: Steve Rotenberg.
1cs533d-winter-2005 Notes  More optional reading on web for collision detection.
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
OBBTree: A Hierarchical Structure for Rapid Interference Detection Gottschalk, M. C. Lin and D. ManochaM. C. LinD. Manocha Department of Computer Science,
CS 376 Introduction to Computer Graphics 04 / 06 / 2007 Instructor: Michael Eckmann.
VECTORS AND THE GEOMETRY OF SPACE Vectors VECTORS AND THE GEOMETRY OF SPACE In this section, we will learn about: Vectors and their applications.
VECTORS AND THE GEOMETRY OF SPACE 12. VECTORS AND THE GEOMETRY OF SPACE A line in the xy-plane is determined when a point on the line and the direction.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
Computer graphics & visualization Collision Detection – Narrow Phase.
Week 13 - Wednesday CS361.
Solving Equations. Is a statement that two algebraic expressions are equal. EXAMPLES 3x – 5 = 7, x 2 – x – 6 = 0, and 4x = 4 To solve a equation in x.
October 8, 2013Computer Vision Lecture 11: The Hough Transform 1 Fitting Curve Models to Edges Most contours can be well described by combining several.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
2-Dimension Viewing and Clipping
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
1 Preliminaries Precalculus Review I Precalculus Review II
Introduction to 3D Graphics Lecture 4: Scenes and Scene Graphs Anthony Steed University College London.
COMP 175: Computer Graphics March 24, 2015
HAWKES LEARNING SYSTEMS math courseware specialists Copyright © 2011 Hawkes Learning Systems. All rights reserved. Hawkes Learning Systems: College Algebra.
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
1 Ray Tracing Polyhedra ©Anthony Steed
Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a.
UNC Chapel Hill M. C. Lin Linear Programming Reading: Chapter 4 of the Textbook Driving Applications –Casting/Metal Molding –Collision Detection Randomized.
Vectors and the Geometry of Space 9. Vectors 9.2.
Copyright © Cengage Learning. All rights reserved. 12 Vectors and the Geometry of Space.
CS 325 Introduction to Computer Graphics 04 / 26 / 2010 Instructor: Michael Eckmann.
College of Computer and Information Science, Northeastern UniversityOctober 12, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2006.
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,
CS 376 Introduction to Computer Graphics 04 / 20 / 2007 Instructor: Michael Eckmann.
Geometric Objects and Transformation
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
1Computer Graphics Implementation II Lecture 16 John Shearer Culture Lab – space 2
Implementation II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Basic Perspective Projection Watt Section 5.2, some typos Define a focal distance, d, and shift the origin to be at that distance (note d is negative)
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Advanced Computer Graphics Spring 2009
Computer Graphics I, Fall 2010 Implementation II.
CS 551/651: Advanced Computer Graphics
Vectors and the Geometry of Space Section 10.4 Lines and Planes in Space 2015.
Section 1-1 Points and Lines. Each point in the plane can be associated with an ordered pair of numbers, called the coordinates of the point. Each ordered.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
CS 376 Introduction to Computer Graphics 02 / 14 / 2007 Instructor: Michael Eckmann.
Lecture 9 From Vertices to Fragments. Objectives Introduce basic implementation strategies Clipping Rasterization hidden-surface removal.
Computer Graphics Lecture 14 CLIPPING I Taqdees A. Siddiqi
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
2.5. Basic Primitive Intersection
Computer Animation Algorithms and Techniques
Collision Detection.
Presentation transcript:

Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology

2 Ray/Box Intersection (Line Segment/Box Overlap Test) One should first test against an axis that is orthogonal to a face of both objects to be tested.

3 Ray/Box Intersection (Line Segment/Box Overlap Test) Since the line segment does not have a face, it does not generate any test. The box generates three axes to test: (1,0,0), (0,1,0) and (0,0,1). Finally, the axes formed from the cross product between line segment direction and the box axes should be tested.  The test for the axis (1,0,0) is as follows: |c x | > |w x | + h x.  If the test is true then the line segment and the box do not overlap.

4 Ray/Box Intersection (Line Segment/Box Overlap Test) The cross product axis a = w ⅹ (1,0,0) =(0,w z,-w y ) is tested as follows:  The extent of the box projected onto a is h y |w z | + h z |w y |.  Next we need to find the projected length of the line segment, and the projection of the line segment center.  The projection of the line segment direction w onto a is zero, since w ⅹ (w ᆞ (1,0,0))=0. Thus the test becomes |c y w z -c z w y | > h y |w z | + h z |w y | If the test is true, then there is no overlap.

5 Ray/Triangle Intersection In real-time graphics libraries, triangle geometry is usually stored as a set of vertices with associated normals.  Each triangle is defined by three vertices.  The normal of the plane in which the triangle lies is often not stored. It must be computed if needed.  Significant memory savings are possible. We can reduce the problem to two dimensions by projecting the intersection point and the triangle vertices on the axis-aligned plane where the area of the triangle is maximized.  We need only decide whether the 2D point is inside the 2D triangle.

6 Ray/Triangle Intersection The ray  r(t) = o + td. A Triangle is defined by three vertices  v 1, v 2 and v 3, i.e. Δv 1 v 2 v 3.

7 Ray/Triangle Intersection (Intersection Algorithm) A point t(u,v) on a triangle is given by the explicit formular  t(u,v) = (1-u-v)v 0 +uv 1 +vv 2, (u,v) are the barycentric coordinates, u,v≥0, u+v≤1.  u and v are the amounts by which to weight each vertex’s contribution to a particular location, with w=(1-u-v) being the third weight.

8 Ray/Triangle Intersection (Intersection Algorithm) Intersection between the ray, r(t) and the triangle, t(u,v) is equivalent to r(t)=t(u,v).  o+td = (1-u-v)v 0 + uv 1 + vv 2.  We construct the linear system of equations whose roots are the barycentric coordinates (u,v) and the distance t from the ray origin to the intersection point.

9 Ray/Triangle Intersection (Intersection Algorithm) Intersection between the ray, r(t) and the triangle, t(u,v) is equivalent to r(t)=t(u,v).

10 Ray/Triangle Intersection (Intersection Algorithm) Solution (e 1 =v 1 -v 0,e 2 =v 2 -v 0 and s=o-v 0 )

11 Ray/Polygon Intersection Triangles are the most common rendering primitive. But having a routine that computes the intersection between a ray and a polygon is useful. A polygon of n vertices is defined by an ordered vertex list {v 0,v 1,v 2,…,v n-1 }  Vertex v i forms an edge with v i+1.  The polygon is closed by the edge from v n-1 to v 0. The plane of the polygon is denoted π p : n p ·x + d p = 0.

12 Ray/Polygon Intersection We first compute the intersection between the ray and π p.  Replace x by the ray. If |n p ·d|< ε, ε is a very small number,  the ray is considered parallel to the polygon plane.  There is no intersection between them. Otherwise, the intersection point, p, of the ray and the polygon plane is computed.  p=o+td.

13 Ray/Polygon Intersection Thereafter, the problem of deciding whether p is inside the polygon is reduced from three to two dimensions.  This is done by projecting all vertices and p to one of the xy, xz, yz planes where the area of the projected polygon is maximized.  Example. Given a normal (0.6,-0.692,0.4), the y component has the largest magnitude, so all y coordinates are ignored.  This component information could be precomputed once and stored within the polygon for efficiency.

14 Ray/Polygon Intersection A two-dimensional bounding box for the polygon is also sometimes profitable.  First compute the intersection with the polygon plane.  Project to two dimensions  Test against the two-dimensional bounding box. If the point is outside the box, then reject and return. Otherwise, continue with the full polygon test.  Better approach than using a 3D bounding box.

15 Ray/Polygon Intersection The question left is whether the two-dimensional ray/plane intersection point p is contained in the two- dimensional polygon.  The Crossings Test The crossings test is based on the Jordan Curve Theorem.  A point is inside if a ray from this point in an arbitrary direction crosses an odd number of polygon edges.  Also known as the parity or the even-odd test.  This condition does not mean that all areas enclosed by the polygon are considered insided.

16 Ray/Polygon Intersection The crossings algorithm is the fastest test that does not use preprocessing. It works as follows:  Shoot a ray from the projection of the point p along the positive x-axis.  Compute the number of crossings between the polygon edges and the ray.  An odd number of crossings indicates that the point is inside the polygon.

17 Ray/Polygon Intersection The test point p can also be thought of as being at the origin and the edges may be tested against the positive x-axis.  If the y-coordinates of a polygon edge have the same sign, then that edge cannot cross the x-axis.  Otherwise, it can, and then the x-coordinates are checked. If both are positive, then the number of crossings is incremented. If they differ in sign, the x-coordinate of the intersection between the edge and the x-axis must be computed and if it is positive, the number of crossings is again incremented.

18 Ray/Polygon Intersection Problems might occur when the test ray intersects a vertex, since two crossings might be detected.  These problems are solved by setting the vertex infinitesimally above the ray.  It is done by interpreting the vertices with y >=0 as lying above the x-axis.

19 Ray/Polygon Intersection The advantages of the crossings test  It is relatively fast and robust.  It requires no additional information or preprocessing for the polygon. The disadvantage of this method  It does not yield anything beyond the indication of whether a point is inside or outside the polygon.

20 Plane/Box Intersection Detection One way to determine whether a box intersects a plane is to insert all the vertices of the box into the plane equation.  If both a positive and a negative result (or a zero) is obtained, then vertices are located on both sides of (or on) the plane. -> An intersection has been detected.  This is somehow a brute force method. The idea behind faster ways is that only two points need to be inserted into the plane equation.  These points are the ones that form a diagonal of the box, where the diagonal passes through the center of the box and is most aligned to the normal of the plane than are the other pairs of points that form diagonals.

21 Plane/Box Intersection Detection (AABB) Given an AABB, B, defined by b min and b max, four different diagonals can be constructed.  All these pass through the center of B and have endpoints at the vertices of B. For this AABB/plane intersection test, first find out which of the box diagonals is most aligned with the plane normal, n. After such a diagonal is found, its two AABB vertices, called v min and v max, are inserted into the plane equation.  This equation tests which side of the plane each endpoint is on.  If the signs of the results differ, or at least one of them is zero, then B intersects the plane.

22 Plane/Box Intersection Detection (AABB)

23 Plane/Box Intersection Detection (OBB) With a small change, the test for AABB can be used to test a plane against an OBB. The trick lies in knowing how to identify the two points, v min and v max.  When this has been done, the same test as for AABBs can be used. To identify such points, we transform the normal of the plane so that it lies in the coordinate system of the OBB.

24 Plane/Box Intersection Detection (OBB) We use the transformed normal n’ to find the points v min and v max  n’ = (b u ᆞ n, b v ᆞ n, b w ᆞ n) T Another way to test an OBB against a plane is to project the axes of the OBB onto the normal of the plane. If the absolute value of the distance from the center of the OBB to the plane is larger than r, then the plane and the OBB do not intersect. Otherwise, they do.

25 Triangle/Triangle Intersection Graphics hardware uses the triangle as its most important drawing primitive, it is natural to perform collision detection tests on this kind of data.  The deepest levels of a collision detection algorithm typically have a routine that determines whether or not two triangles intersect.  More often than not, we are concerned only about whether they intersect at all, not interested in an exact intersection.

26 Triangle/Triangle Intersection The problem is: Given two triangles, T 1 =Δu 0 u 1 u 2 and T 2 = Δv 0 v 1 v 2, determine whether or not they intersect. Two methods are explained.  The interval overlap method  The method in the ERIT package.

27 Triangle/Triangle Intersection (Interval Overlap Method) First, the plane equation п 2 : n 2 ᆞ x + d 2 =0 is computed.  n 2 =(v 1 -v 0 ) ⅹ (v 2 -v 0 ), d 2 = -n 2 ᆞ v 0 Then, the signed distances from the vertices of T 1 to п 2 are computed by simply inserting the vertices into the plane equation.  d ui = n 2 ᆞ u i + d 2, i=0,1,2 If all d ui ≠0, i=0,1, and 2, and all have the same sign, the T 1 lies on one side of п 2 and the overlap is rejected. The same test is done for T 2 and п 1. These two early rejection tests allow us to avoid many computations for some triangle pairs.

28 Triangle/Triangle Intersection (Interval Overlap Method) If all d ui =0, for i=0,1, and 2, then the triangles are co- planar. If not, the intersection of п 1 and п 2 is a line, l = o + td, where d = n 1 ⅹ n 2 is the direction of the line and o is some point on it.  These intersections form intervals on l, and if these intervals overlap the triangles overlap as well.

29 Triangle/Triangle Intersection (Interval Overlap Method) If all d ui =0, for i=0,1, and 2, then the triangles are co- planar. If not, the intersection of п 1 and п 2 is a line, l = o + td, where d = n 1 ⅹ n 2 is the direction of the line and o is some point on it.  These intersections form intervals on l, and if these intervals overlap, the triangles overlap as well.

30 Triangle/Triangle Intersection (Interval Overlap Method) To compute a scalar interval (on l) that represents the intersection between T 1 and l.  Ex. The triangle vertices u 0 and u 2 lie on the same side of п 2 and that u 1 lies on the other side.  To find scalar values that represent the intersection between the edges u 0 u 1 and u 1 u 2 and l, the vertices are first projected onto l: p ui = d ᆞ (u i -o)

31 Triangle/Triangle Intersection (Interval Overlap Method)

32 Triangle/Triangle Intersection (Interval Overlap Method) To compute a scalar interval (on l) that represents the intersection between T 1 and l.  Next we want to use the intersection point, called b, between the line l = o + td and the edge u 0 u 1. We call the t-value at the intersection point t 1.  If we let k i denote the projection of u i onto п 2, we see that the triangles Δu 0 bk 0 and Δu 1 bk 1 are similar. Using this, t 1 can be computed as follows:

33 Triangle/Triangle Intersection (Interval Overlap Method) Similar calculations are done to compute t 2, which represents the intersection between the line l and the edge u 1 u 2. Together, t 1 and t 2 represent an interval on the line l where the triangle T 1 intersects l. Using similar techniques, an interval can be computed for the other triangle, T 2, as well. If these intervals overlap, the triangles intersect.

34 Triangle/Triangle Intersection (Interval Overlap Method) If the triangles are co-planar, they are projected onto the axis-aligned plane where the area of the triangles are maximized. Then, a simple two-dimensional triangle-triangle overlap test is performed.  First, test all closed edges of T 1 for intersection with the closed edges of T 2.  If any intersection is found, then the triangles intersect.  Otherwise, we must test whether T 1 is totally contained in T 2 or vice versa. This can be done by performing a point-in-triangle test for one vertex of T 1 against T 2 and vice versa.

35 Triangle/Triangle Intersection (Interval Overlap Method) Optimizations  Since the interval can be translated without altering the result of the interval overlap test, the previous equation p ui = d ᆞ (u i -o) can be simplified into p ui = d ᆞ u i,i = 0,1,2. o does not need to be computed.  We can also scale the t-values without changing the result of the overlap test and therefore the divisions can be avoided by scaling all the t-values with appropriate factors.  Also, the result of the overlap test does not change if we project l onto the coordinate axis with which it is most closely aligned. Therefore we have