Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology."— Presentation transcript:

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

2 2 Shaft/Box and Shaft/Sphere Intersection Sometimes it is important to find what is in between two AABBs.  Useful for occlusion culling, for dynamic intersection testing, or for light transport algorithms such as radiosity. The volume between two AABBs, including the AABBs themselves, is called a shaft. The intersection operation is called shaft culling.

3 3 Shaft/Box and Shaft/Sphere Intersection A shaft is actually defined by a single large AABB and set of planes.  Each plane trims off some amount of volume from the AABB and the volume inside the AABB and all the planes is the shaft. The shaft’s AABB can be thought of as a set of six planes, thereby defining the shaft as only a set of planes.  It is important that six of the planes that make a shaft be axis- aligned.  This property ensures that no false hits are generated when testing against another AABB.

4 4 Shaft/Box and Shaft/Sphere Intersection (Shaft Formation) The shaft is defined by two initial AABBs, e.g. the bounding boxes for the two objects forming the shaft.  The shaft’s AABB is simply the minimal AABB surrounding these two initial AABBs. The next task is computing the set of planes connecting the two initial AABBs.  Each plane is associated with and parallel to one of the twelve edges of the shaft’s AABB.  Each plane generated attaches on e of the twelve edges of one of the initial AABBs to the corresponding edge of the other initial AABB.

5 5 Shaft/Box and Shaft/Sphere Intersection To determine which edges form planes for the shaft, first, for each of the six faces of the shaft’s AABB, find which initial AABB it touches. Now examine each edge of the shaft’s AABB  If the two faces bordering this edge touch different initial AABBs, then a plane joining the corresponding edges of these initial AABBs is formed and added to the shaft definition.  Up to edit different planes can be added to the shaft in this way. At this point, shaft formation is done.

6 6 Shaft/Box and Shaft/Sphere Intersection To test a shaft against another AABB or a sphere  The shaft’s AABB and then each plane in turn is tested against the primitive. If the primitive is fully outside the AABB or any plane, then testing is done and the shaft does not intersect the primitive. If the primitive is fully inside all planes, then the primitive is inside the shaft. Otherwise the primitive overlaps the shaft. Testing against a shaft is simply a series of plane/AABB or plane/sphere tests.

7 7 Line/Line Intersection Tests (Two Dimensions) First Method  Consider two lines, r 1 (s) = o 1 + sd 1 and r 2 (t) = o 2 + td 2 with a ᆞ a ⊥ = 0.

8 8 Line/Line Intersection Tests (Two Dimensions) Second Method  The first line segment from p 1 to p 2 : r 1 (s) = p 1 + s(p 2 - p 1 )  The second line segment from q 1 to q 2 : r 2 (t) = q 1 + t(q 2 -q 1 )  From r 1 (s) = r 2 (t) a = q 2 -q 1, b=p 2 -p 1, c=p 1 -q 1, d = c ᆞ a ⊥, e = c ᆞ b ⊥, f = a ᆞ b ⊥.

9 9 Line/Line Intersection Tests (Three Dimensions) Consider two lines, r 1 (s) = o 1 + sd 1 and r 2 (t) = o 2 + td 2.

10 10 Intersection Between Three Planes Given three planes, each described by a normalized normal vector n i, and an arbitrary point on the plane, p i, i = 1,2,3, the unique point, p, of the intersection between them is given by

11 11 Intersection Between Three Planes If the planes are given in implicit form, n i ᆞ x + d i = 0.

12 12 Dynamic Intersection Testing Static intersection testing is not always a realistic scenario especially we render frames at discrete times.  Discrete testing means that a ball that is on one side of a closed door at time t might move to the other side at t+Δt, without any collision being noticed by a static intersection test.  This is sometimes called quantum tunneling.  One solution is to make several tests uniformly spaced between t and t+Δt. This would increase the computational load and still the intersection could be missed. Therefore, we need a different approach, called a dynamic intersection test.

13 13 Dynamic Intersection Testing One principle that can be applied to all dynamic intersection testing situations is the fact that motion is relative.  Given two objects moving at v A and v B, we only consider object A moving at v B -v A relative to the object B or vice versa.

14 14 Dynamic Intersection Testing (Sphere/Plane) Assume a sphere has its center at c and a radius r. The sphere also has a velocity v during the entire frame time Δt.  In the next frame, the sphere will be located at e = c + Δt v. The question is: has the sphere collided with a plane π: n·x + d = 0 during the time from 0 to Δt?

15 15 Dynamic Intersection Testing (Sphere/Plane) The signed distance, s c, from the sphere’s center to the plane is obtained by plugging the sphere center into the plane equation. Subtracting the sphere radius from this distance gives how far the sphere can move before reaching the plane. A similar distance, s e, is computed for the end point e. Now if the sphere centers are on the same side of the plane (s c s e > 0), and if |s c | > r and |s e | > r, then an intersection cannot occur.  The sphere can safely be moved to e.

16 16 Dynamic Intersection Testing (Sphere/Plane)

17 17 Dynamic Intersection Testing (Sphere/Plane) Otherwise, the sphere position and the exact time when the intersection occurs is obtained as follows:  The time when the sphere first touches the plane is t = (s c -r)/(s c -s e )  The sphere center is then located at c + tv. The simple collision response at this point would be to reflect the velocity vector v around the plane normal, and move the sphere using this vector: (1-t)r, where 1-t is the remaining time to the next frame from the collision and r is the reflection vector.

18 18 Dynamic Intersection Testing (Sphere/Sphere) Testing two moving spheres A and B for intersection turns out to be equivalent to testing a ray against a static sphere.  First, use the principle of relative motion described above to make sphere B become static.  Then a technique is borrowed from the frustum/sphere intersection test. In that test, the sphere was moved along the surface of the frustum to create a larger frustum. By extending the frustum outwards by the radius of the sphere, the sphere itself could be shrunk to a point. Here, moving one sphere over the surface of another sphere results in a new sphere that is the sum of the radii of the two original spheres.

19 19 Dynamic Intersection Testing (Sphere/Sphere) So the radius of sphere A is added to the radius of B to give B a new radius.  Now we have the situation where sphere B is static and is larger, and sphere A is a point moving along a straight line, i.e. a ray.  The main difference of this test and the ray/sphere test is that the ray direction is not normalized in this test.

20 20 Dynamic Intersection Testing (Sphere/Polygon) Intersecting a moving sphere with a polygon is somewhat more involved than sphere/plane intersection. If the sphere never overlaps the plane, then no further testing is done. The sphere/plane test finds when the sphere first intersects the plane.  This intersection point can then be used in performing a point in polygon test.  If this point is inside the polygon, the sphere first hits the polygon there and testing is done.

21 21 Dynamic Intersection Testing (Sphere/Polygon) However, this hit point can be outside the polygon but the sphere’s body can still hit a polygon edge or point while moving further along its path. If a sphere collides with the infinite line formed by the edge, the first point of contact p on the sphere will be radius r away from the center.  (c t – p) ᆞ (c t – p) = r 2 where c t = c + tv. (c: initial position, v: velocity)  The vector from the sphere’s center to this point will be perpendicular to the edge:  (c t – p) ᆞ (p 1 – p 0 ) = 0. p 0 and p 1 are the vertices of the polygon edge.

22 22 Dynamic Intersection Testing (Sphere/Polygon) The hit point’s location p on the edge’s line is defined by the parametric equation:  p = p 0 + d(p 1 -p 0 ), d: a relative distance from p 0 and d ∈ [0,1] for points on the edge. The variables to compute are the time t (t ∈ [0,1]) of the first intersection with the edge’s line and the distance d along the edge. The hit point must be on the edge itself, not beyond the edge’s endpoints.

23 23 Dynamic Intersection Testing (Sphere/Polygon)

24 24 Dynamic Intersection Testing (Sphere/Polygon) The equations give a, b, and c, which are the variables of the quadratic equation: at 2 + bt + c = 0.  [t 0,t 1 ] This test is done for each edge of the polygon and if the range [t 0,t 1 ] overlaps the range [0,1], then the edge’s line is intersected by the sphere in this frame at the smallest value in the intersection of these ranges. The sphere’s center c t at first intersection time t is computed and yields a distance: This needs to be in the range [0,1].

25 25 Dynamic Intersection Testing (Sphere/Polygon) If d is not in this range, the edge is considered missed. Using this d gives the point where the sphere first intersects the edge.  p = p 0 + d(p 1 -p 0 ) If the point of first intersection is needed, then all three edges must be tested against the sphere, as the sphere could hit more than one edge.

26 26 Dynamic Intersection Testing (Sphere/Polygon) This test is computationally complex. One optimization for this test is to put an AABB around the sphere’s path for the frame and test the edge as a ray against this box before doing this full test.  If the line segment does not overlap the AABB, then the edge cannot intersect the sphere. If no edge is the first point of intersection for the sphere, further testing is needed.  The sphere is being tested against the first point of contact with the polygon.  A sphere eventually hit the interior or an edge of a polygon but the tests above check only for first intersection.

27 27 Dynamic Intersection Testing (Sphere/Polygon) The third possibility is that the first point of contact is a polygon vertex.  Each vertex in turn is tested against the sphere.  Using the concept of relative motion, testing a moving sphere against a static point is exactly equivalent to testing a sphere against a moving point, i.e. a ray. In truth, this sphere/polygon test is equivalent to testing a ray (represented by the center of the sphere moving along a line) against a “puffy” polygon,  one in which the vertices have been turned into spheres of radius r,  the edges into cylinder of radius r  the polygon itself raised and lowered by r to seal off the object.

28 28 Dynamic Intersection Testing (Sphere/Polygon)

29 29 Dynamic Intersection Testing (Sphere/Polygon) So, the algorithm can be thought of as testing a ray against this puffy polygon’s parts:  First, the polygon facing the ray is tested.  Then the edge cylinders are tested against the ray  Finally, the vertex spheres are tested. For polygons with concavities, a vertex at any concave location does not have to be tested against the moving sphere.  The sphere formed at such a vertex is not visible from the outside.

30 30 Dynamic Intersection Testing (Dynamic Separating Axis Method) The SAT method tests a set of axes to see whether the projections of the two objects onto these axes overlap. If all projections on all axes overlap, then the objects overlap as well. The key to solving the problem dynamically is to move the projected interval of the moving object with a speed of (v ᆞ a)/(a ᆞ a) on the axis a. If there is overlap on all tested axes, then the dynamic objects overlap. Otherwise they do not.


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

Similar presentations


Ads by Google