+ All Categories
Home > Documents > Collision handling: detection response

Collision handling: detection response

Date post: 22-Mar-2022
Category:
Upload: others
View: 12 times
Download: 0 times
Share this document with a friend
62
Collision handling: detection and response
Transcript
Page 1: Collision handling: detection response

Collision handling:detection and response

Page 2: Collision handling: detection response

Collision handling overview

Discrete  collision detectionConvex polygon intersection testGeneral polygon intersection test

DetectionContinuous collision detection

Vertex‐triangle testEdge‐edge test

Kinematic responseR

Penalty methodResponse

Page 3: Collision handling: detection response

Discrete Collision Handlingg

• Run the simulation from t to t+1 withoutRun the simulation from t to t+1, without considering collision

• Check if any intersection happens at t+1• Check if any intersection happens at t+1• If so, remove it

Page 4: Collision handling: detection response

Geometric Modeling Primitivesg

• PointPoint

• Line segment

• Polygon

Page 5: Collision handling: detection response

Terminology – convex and concave lpolygons

Page 6: Collision handling: detection response

Edge Test Decides convex/concave

Always on one side Not always on one sideAlways on one side Not always on one side

Works same for convex/concave polyhedra (always on on side of the polygonal face?)(always on on side of the polygonal face?)

Page 7: Collision handling: detection response

An important property of Convex l !polygons!

Initial Pair

You can always find the closest vertex pair by gradually moving one vertex at each time!

Page 8: Collision handling: detection response

An important property of Convex l !polygons!

You can always find the closest vertex pair by gradually moving one vertex at each time!

Page 9: Collision handling: detection response

An important property of Convex l !polygons!

You can always find the closest vertex pair by gradually moving one vertex at each time!

Page 10: Collision handling: detection response

An important property of Convex l !polygons!

You can always find the closest vertex pair by gradually moving one vertex at each time!

Page 11: Collision handling: detection response

An important property of Convex l !polygons!

You can always find the closest vertex pair by gradually moving one vertex at each time!

Page 12: Collision handling: detection response

An important property of Convex l !polygons!

You can always find the closest vertex pair by gradually moving one vertex at each time!

Page 13: Collision handling: detection response

An important property of Convex l !polygons!

No more improvement, done!

You can always find the closest vertex pair by gradually moving one vertex at each time!

Page 14: Collision handling: detection response

An important property of Convex l !polygons!

• The computational cost depends on the initial pair– Worst case O(N)B t O(1)!– Best case O(1)!

• In animation, since we can keep the pair over time and the object movement within a time step isand the object movement within a time step is small, the initial pair is often good!– O(1)O(1)

• Problem: not everything is convex– Solution: decompose them into convex componentsp p– Doesn’t always work

Page 15: Collision handling: detection response

General Polygon Intersection Tests

• To test whether two polygons intersect, we canTo test whether two polygons intersect, we can test whether any vertex is inside of another 

Page 16: Collision handling: detection response

Inside/Outside Test

• To test whether a point is within a polygon/polyhedron shoot a ray and count thepolygon/polyhedron, shoot a ray and count the intersections!

• Odd => inside; even =>outside• Odd => inside; even =>outside

d3 intersections ‐> inside

Page 17: Collision handling: detection response

Inside/Outside Test

• To test whether a point is within a polygon/polyhedron shoot a ray and count thepolygon/polyhedron, shoot a ray and count the intersections!

• Odd => inside; even =>outside1 intersection ‐> inside

• Odd => inside; even =>outside

Page 18: Collision handling: detection response

Inside/Outside Test

• To test whether a point is within a polygon/polyhedron shoot a ray and count thepolygon/polyhedron, shoot a ray and count the intersections!

• Odd => inside; even =>outside• Odd => inside; even =>outside

4 intersection > outside4 intersection ‐> outside

Page 19: Collision handling: detection response

Inside/Outside Test

• To test whether a point is within a polygon/polyhedron shoot a ray and count thepolygon/polyhedron, shoot a ray and count the intersections!

• Odd => inside; even =>outside• Odd => inside; even =>outside

0 intersection ‐> outside

Page 20: Collision handling: detection response

Inside/Outside Test• Doesn’t always work…• 2 intersections but still inside?intersections but still inside?• This is called a degenerate case. • Solutions? Try some other directionsSolutions? Try some other directions

2 intersections???

Page 21: Collision handling: detection response

Problem 1 (in 3D)?( )

Collision can happen even there is no vertex inside of ppthe other polyhedron. Called edge‐edge colllision

The solution requires complex intersection tests. We skip it here…

Page 22: Collision handling: detection response

Discrete Collision Handlingg

• Run the simulation from t to t+1 withoutRun the simulation from t to t+1, without considering collision

• Check if any intersection happens at t+1• Check if any intersection happens at t+1• If so, remove it

Page 23: Collision handling: detection response

Problem 2?• Discrete collision handling has a tunneling artifact.• No intersection at t or t+1, but intersection happens in‐No intersection at t or t , but intersection happens inbetween.

Time t Time t+1Time t Time t+1

Page 24: Collision handling: detection response

Problem 3?

• To do inside/outside test, the object must be closed.• In other words, it has an area (or volume).• How do I know if two curves/surfaces are intersecting?

– Knowing the location of the intersection is not sufficient! 

Page 25: Collision handling: detection response

Solution• We don’t just check whether intersection happens at t or t+1.

• We check if any intersection happens between t and t+1.• This is called continuous collision detection (opposing to ( pp gdiscrete collision detection).

Page 26: Collision handling: detection response

For example: Vertex‐Triangle TestFor example: Vertex Triangle Test• Four points

– P0(t)=P0+tV0; P1(t)=P1+tV1; P2(t)=P2+tV2; P3(t)=P3+tV3

• Intersection happens when they are co‐planarpp y p– (P1(t)‐P0(t))(P2(t)‐P0(t))×(P3(t)‐P0(t))=0

• Once you find t, verify if P0(t) is within the triangle.y , y 0( ) g

P1P2

P0

P1

P3

Page 27: Collision handling: detection response

For example: Edge‐EdgeTestFor example: Edge EdgeTest• Four points

– P0(t)=P0+tV0; P1(t)=P1+tV1; P2(t)=P2+tV2; P3(t)=P3+tV3

• Intersection happens when they are co‐planar– (P1(t)‐P0(t))(P2(t)‐P0(t))×(P3(t)‐P0(t))=0

• Once you find t, verify if they do intersect!Once you find t, verify if they do intersect!

P2

P0

P1

PP0 P3

Page 28: Collision handling: detection response

Polygon and polyhedra complexityPolygon and polyhedra complexity

How many edges? How many points?

Page 29: Collision handling: detection response

Bounding objectsBounding objects

• SphereSphere

• Axis aligned bounding box• Axis aligned bounding box

• Oriented bounding box

Page 30: Collision handling: detection response

Bounding volume constructionBounding volume construction

• Given a set of points as input can weGiven a set of points as input, can we automatically create bounding volumes

– Axis aligned bounding box

– Sphere

– Convex hull

Page 31: Collision handling: detection response

Axis aligned bounding boxAxis aligned bounding box

Page 32: Collision handling: detection response

Axis aligned bounding box (AABB)Axis aligned bounding box (AABB)

Page 33: Collision handling: detection response

Bounding sphereBounding sphere

Page 34: Collision handling: detection response

Bounding sphereBounding sphere

Page 35: Collision handling: detection response

Bounding sphereBounding sphere

Page 36: Collision handling: detection response

Bounding sphereBounding sphere

Page 37: Collision handling: detection response

Convex HullConvex HullBest fit convex polyhedron to concave polyhedron but takes some (one-time)polyhedron but takes some (one time) computation

1. Find highest vertex, V12. Find remaining vertex that minimizes angle

Cwith horizontal plane through point. Call edge L

3. Form plane with this edge and horizontal line perpendicular to L at V1line perpendicular to L at V1

4. Find remaining vertex that for triangle that minimizes angle with this plane. Add this triangle to convex hull, mark edges as

t h dunmatched5. For each unmatched edge, find remaining

vertex that minimizes angle with the plane of the edge’s triangleg g

6. 3D convex hull is more complex…

Page 38: Collision handling: detection response

Convex hullConvex hull

Page 39: Collision handling: detection response

Convex hullConvex hull

Page 40: Collision handling: detection response

Convex hullConvex hull

Page 41: Collision handling: detection response

Convex hullConvex hull

Page 42: Collision handling: detection response

Convex hullConvex hull

Page 43: Collision handling: detection response

Convex hullConvex hull

Page 44: Collision handling: detection response

Convex hullConvex hull

Page 45: Collision handling: detection response

Bounding SlabsFor better fit bounding polyhedron: use arbitrary (user-specified) collection of bounding plane-

ipairsIs a vertex between each pair?

12 dPNd 12

Page 46: Collision handling: detection response

Sphere vs. SphereSphere vs. Sphere

Compare distance (p1,p2) to r1+r2distance(p1,p2)2 to (r1 + r2)2

Page 47: Collision handling: detection response

AABB vs. AABBAABB vs. AABB

Page 48: Collision handling: detection response

AABB vs. AABBAABB vs. AABB

Page 49: Collision handling: detection response

Oriented bounding boxes and arbitrary lpolygons

• Separating axis theoremSeparating axis theorem– http://gamedev.tutsplus.com/tutorials/implementation/collision‐detection‐with‐the‐separating‐axis‐ation/collision detection with the separating axistheorem/

– http://www.sevenson.com.au/actionscript/sat/http://www.sevenson.com.au/actionscript/sat/– http://www.metanetsoftware.com/technique/tutorialA.html

Page 50: Collision handling: detection response

Hierarchical bounding volumesHierarchical bounding volumes

Approximating polyhedra with spheres for time‐critical collision detection, by Philip M. Hubbard

Page 51: Collision handling: detection response

HBV exampleHBV example

Page 52: Collision handling: detection response

HBV exampleHBV example

Page 53: Collision handling: detection response

HBV exampleHBV example

Page 54: Collision handling: detection response

Spatial subdivision – grid ( d d )(quadtrees and octrees)

Page 55: Collision handling: detection response

Spatial subdivision – binary space i i ipartitioning

Page 56: Collision handling: detection response

Collision responseCollision response

Page 57: Collision handling: detection response

Collisions: physics reviewCollisions: physics review

• Momentum mvp Momentum• In a closed system, momentum is conserved

mvp

''vmmvp

• After a collision, the sum of all momentums is the same as the sum of all momentum before the collision

Page 58: Collision handling: detection response

Collision typesCollision typesElastic collisions – no loss of kinetic energy (e g deformations heat)

Inelastic collisions – loss of kinetic energyenergy (e.g. deformations, heat) kinetic energy

1 2

21 mvE Kinetic energy

Page 59: Collision handling: detection response

Elastic collision with stationary object: h i l d i l ll / lhorizontal and vertical walls/planes

• For vertical wall/boundaryo e ca a /bou da y– Negate x component of 

velocityP f– Preserve y component of velocity

• Ex: v0 = (3,‐3) ; v = (‐3,‐3)  0 ( , ) ; ( , )• For horizontal 

walls/boundaries– Preserve x– Negate y

Page 60: Collision handling: detection response

Elastic collision with stationary object: l d ll / langled walls/planes

• Still split velocity vector into components– Now with respect to the normal 

(n) of the wall• u = (v * n / n * n) n

– Note: * is dot product– Vector/direction is parallel to nVector/direction is parallel to n– Scalar/magnitude is in opposite 

direction of n; (v * n) < 0• w = v – uw   v  u• Reflected velocity:

v’ = w – u

Page 61: Collision handling: detection response

Inelastic Collisions

Coefficient of restitution ratio of velocities before andratio of velocities before and after collision (dampen the resulting

l it ) Objects stick together,momentum is conserved

velocity)

Page 62: Collision handling: detection response

Collision response – penalty method


Recommended