Loading...

PPT – Efficient and Accurate Collision Detection Hierarchies with Collision Response PowerPoint presentation | free to download - id: 14bf51-YWY3M

The Adobe Flash plugin is needed to view this content

Efficient and Accurate Collision Detection

Hierarchies with Collision Response

- CSE530/CSE631 Final Demo
- Evan Closson

Past Work Collision Detection

- Many efficient bounding volume hierarchies have

been created. - Spheres Approximating Polyhedra with Spheres

for Time-Critical Collision Detection, Philip M.

Hubbard. ACM Transactions on Graphics, Vol. 15,

No 3, July 1996, Pages 179-210. - AABBs Efficient Collision Detection of

Deformable Models using AABB Trees, Gino van den

Bergen, Journal of Graphics Tools, 2(4)1-14,

1997. - k-dops also known as discrete orientation

polytopes Efficient Collision Detection Using

Bounding Volume Hierarchies of k-DOPs'', J.T.

Klosowski, M. Held, J.S.B. Mitchell, H. Sowizral,

- K. Zikan, IEEE Trans. Visualizat. Comput. Graph.

4(1)21-36, Jan 1998. - OBB OBB-Tree A Hierarchical Structure for

Rapid Interference Detection, S. Gottschalk, M.

Lin, and D. Manocha. Proc. ACM SIGGRAPH, 1996.

Evan Closson

Spring 2003

Past Work Collision Response

- D. Baraff. Analytical methods for dynamic

simulation of non-penetrating rigid bodies.

Computer Graphics 23(3) 223-232, 1989. - D. Baraff. Coping with friction for

non-penetrating rigid body simulation. Computer

Graphics 25(4) 31-40, 1991. - D. Baraff and A. Witkin. Dynamic simulation of

non-penetrating flexible bodies. Computer

Graphics 26(2) 303-308, 1992.

Evan Closson

Spring 2003

Collision Detection

- Well researched.
- Very fundamental to many areas specifically

simulated environments. - Determine if a collision occurs.
- Determine the points of impact.

Evan Closson

Spring 2003

Bounding Volume Hierarchies

- Often models are very geometrically complex.
- Need efficient queries of the kind do these two

bodies A and B collide and at what point? - Bounding Volume Hierarchies can approximate a

model to a arbitrary level of detail depending

upon the depth of the tree.

Evan Closson

Spring 2003

Sphere Trees

- Difficult to tightly fit to objects, need many

spheres. - Very efficient collision checks

Evan Closson

Spring 2003

Octree Creation

- Very simple creation method, not very great

fitting to objects. - Build octree from bounding box of model.
- Traverse octree and at each node create a sphere

if needed that contains all the geometry in

that node. - Different sampling methods can be used to

increase the accuracy of the sphere creation.

Evan Closson

Spring 2003

Medial Axis Creation

- The medial axis or skeleton of a structure can

be used to more smartly place bounding spheres

for an arbitrarily shaped geometry. - Medial axis is the Voronoi diagram of the edges

interior to the polygon. In 3D it is the

surfaces.

Evan Closson

Spring 2003

Medial Axis Creation

- Complex algorithm, but briefly . . .
- Approximate Medial Axis with Voronoi diagram of

the vertices. - Create lowest level of spheres in structure from

the medial axis. - Create the bounding root sphere.
- Knowing the number of children to use, merge

neighboring spheres found from Voronoi info

to create each level of the tree structure.

Evan Closson

Spring 2003

Sphere Sphere Collision

- If the length between the two spheres center is

less then the radii summed then a collision has

occurred.

Evan Closson

Spring 2003

Sphere Sphere Collision

// bool SphereSphere(Model m1, Model m2,

SPHERE a, SPHERE b) float rs a.r

b.r Vector apos m1.Trans(a.loc) Vector bpos

m2.Trans(b.loc) Vector dist apos

bpos return dist.MagSq() lt rsrs

Evan Closson

Spring 2003

Collision Time

- We are not working with continuous time
- Time is a sampled domain.
- Each iteration steps through time by one time

step. - Sampling error can occur.
- The exact collision time can be between time

steps.

Evan Closson

Spring 2003

Collision Time

Evan Closson

Spring 2003

Collision Time

- Can use a higher sampling rate smaller time

step. - Can use a binary search or bisector method.
- If at simulation time ti 1 a collision is

detected we move the simulation time back to ti

.5 and test again. - If a collision is again detected try between ti

and ti .5 else try between ti .5 and ti 1. - Repeat this until accuracy desired is reached.
- Other methods are also used that try and predict

the time of collision.

Evan Closson

Spring 2003

Collision Point

- Detecting the collision point is important for

the collision response depends on this

information. - The points of collision on the two bodies in

colliding contact are known, these are the leafs

in the collision tree that were colliding.

Evan Closson

Spring 2003

Collision Point

- Response system depends on one point of contact

between two colliding bodies. - Or else the order in which we submit the

collision points will make a difference to the

impulse based response. - To achieve this all the points in contact are

averaged. - This gives decent results.

Evan Closson

Spring 2003

Collision Point

- Also need to find the line of action of the

collision. - This can be estimated by simply taking distance

vector connecting the two collision points in

world space. Normalize this so we have the line

of action. - The tangent to this can also be taken and can be

used to estimate the friction.

Evan Closson

Spring 2003

Collision Point

- Finally the relative velocity between the two

colliding points must be found. This is the

difference between the local/body space velocity

of each of the two colliding points. - This information is then sent onto the collision

response system.

Evan Closson

Spring 2003

Collision Response

- What happens when two bodies collide?
- Impulse Based
- Penalty Methods

Evan Closson

Spring 2003

Mass Properties

- Needed in the calculations for motion.
- They define the resistance of a body to motion.

For example a F/m - Mass, Center of Mass, Moment of Inertia

Evan Closson

Spring 2003

Mass

M ? ?dV

M ? mi

- The volume integral over a continuous body to

find the total mass. Density ?. - Truly found by summing up the mass of every

element in a body. - We estimate these with mass-points, often just a

mass value at a vertex.

Evan Closson

Spring 2003

Center of Mass

COM ? xyz dm

COM (? pimi)/M

- Formulation for calculating the center of mass

over a continuous body. - Calculating the COM from mass-points. Each

mass-point is weighted by its position in object

space.

Evan Closson

Spring 2003

Moment of Inertia

I ? r2 dm

- Mass is a resistance to linear motion while

moment of inertia is a resistance to rotational

motion. - The moment of inertia is defined with respect to

the axis of rotation of the object where r is the

distance to the axis of rotation. - This is actually very difficult to compute for

arbitrary shapes, the axis of rotation changes

and can take into account any of the degrees of

freedom that the object has. - In 3D we can represent this with an Inertia

Tensor defined with respect to local/body space.

Evan Closson

Spring 2003

Inertia Tensor

- First to compute the inertia tensor a body must

be broken up into mass-points. - Define a local moment of inertia for each mass

point. - Simple symmetric shapes are more easily defined.
- If a mass-point is assumed to be a simple shape

such as a sphere this can be done with the simple

formula I (2/5)mR2 - Here I is a vector and defines the inertia with

respect to the x, y, and z axis, since a sphere

is symmetric this is all that is needed.

Evan Closson

Spring 2003

Inertia Tensor

I ? M(i) e1 e4 e7

M(i) e2 e5 e8 e3 e6 e9

e1 Ixi mi (yi2 zi2) e2

e4 -(mi xi yi) e3 e7 -(mi

xi zi) e5 Iyi mi (xi2 zi2)

e6 e8 -(mi yi zi) e9 Izi

mi (xi2 yi2)

Here each i subscript denotes a mass-points

value and Ix,y,z denotes the local inertial

value for each mass point.

Evan Closson

Spring 2003

Motion

- Linear Motion, really the bodies center of mass

displacement which may not be linear. - Angular Motion (the movement of a body about its

center of mass)

Evan Closson

Spring 2003

Linear Motion

a F/m v ds/dt s ? v dt ?v a?t (if a is

constant - linear) s v0 1/2at2 (if linear)

- The formulas for acceleration, velocity, and

displacement. - In simulations these are broken down into minute

linear steps so we can make use of linear

equations for motion.

Evan Closson

Spring 2003

Angular Motion

a I-1t ? dO/dt O ? ? dt ? ? a ?t O

?0 1/2at2

- Same approach as for linear motion. The

equations relate directly. Instead of force we

are working with torque, and instead of mass we

are using the moment of inertia. - This is also done with minute steps.

Evan Closson

Spring 2003

Integrating Motion

- Estimating the equations of motion with minute

linear steps causes errors. - Larger time steps cause more error, while smaller

ones cause less. - Smaller time steps are not always feasible

because of time constraints. - There are different methods to estimate the

equations of motion the most common methods rely

upon the Taylor series.

Evan Closson

Spring 2003

Taylor Series Methods

f(x) ?(fn(a)/n!)(x a)n

- The Taylor series can be used to approximate

these functions of motion. - The higher the order summed to in the Taylor

series the more accurate the approximation. - Here n is the order of the infinite series, for a

summation from 0 to 8. - We can stop this at any n, the more accurate the

approximation the larger n. - The error in the approximation is the amount of

the series left over.

Evan Closson

Spring 2003

Taylor Series Expanded

v(ti dt) v(ti) dt v(ti) (dt2/2!)v(ti)

(dt3/3!)v(ti) (dtn/n!)vn(ti)

- The series expanded to order n for velocity as a

function of time. - The more accurate the more we have to expand.
- It is hard to know the derivatives for motion

past order 1 well but they can often be

approximated. - The most basic and well known method for this

type of integration is Eulers Method. In this

case the expansion is order one.

Evan Closson

Spring 2003

Eulers Methods

v(ti dt) v(ti) dt v(ti) vi vi-1 adt

- The Taylor series of order one, Eulers method

for integration. We know the first derivative

the acceleration. - Easy but also the most error prone.

Evan Closson

Spring 2003

Other Methods

- Difficulty in computing the higher order

derivatives. - Runge-Kutta methods can be used to approximate

higher order Taylor series using linear

combinations to approximate their derivatives. - One of the most common Runge-Kutta methods is the

fourth order method which approximates the Taylor

series to order 4.

Evan Closson

Spring 2003

Integrating Motion Euler Code

- // linear motion
- m_Acceleration m_Force/m_Mass
- m_Velocity m_Acceleration dt
- m_Location m_Velocity dt
- // angular motion
- m_AngularAcceleration m_InertiaInverse

m_Torque - m_AngularVelocity m_AngularAcceleration dt
- m_Orientation (m_Orientationm_AngularVelocity)

(0.5f dt) - m_Orientation.Normalize()

Impulse

p mv J ?p Favg ?t

- Impulse is the change in momentum.
- Applying an impulsive force to a body will change

the velocity. - Using the information provided by the collision

detection we can calculate an impulse based upon

the current state of a two bodies A and B.

Evan Closson

Spring 2003

Implementing Linear Impulse

vi vi-1 J/m

- Although linear impulse is not enough to

represent angular motion as well it is a good

first place to look to understand how

implementing the impulse is done. - The above formula show how to calculate a new

velocity vi from the old velocity and the impulse.

Evan Closson

Spring 2003

Solving for J

J jn

- J can be broken up into both its magnitude and

direction, which is the normal of the collision. - We know n from the results of the collision

detection. - Now the magnitude j must be computed.

Evan Closson

Spring 2003

Solving for j (magnitude)

vreli -evreli-1 vreli n (vai vbi)

- The top equations solves the relative velocity of

the colliding points for two objects A and B

after the impulse is applied. - -e is the coefficient of restitution and can be

used to estimate the softness of an object. - e ranges from 0 to 1, 1 is a mean no deformation

of the objects at collision so no energy loss, 0

means complete energy loss. - The second equation shows the definition of the

relative velocity where vai and vbi is the

velocity of object a and b and time i.

Evan Closson

Spring 2003

Solving for j (magnitude)

vi vi-1 J/m J jn vi vi-1 jn /m vreli

n (vai vbi) vreli n (vai-1 jn /ma

vbi-1 jn /mb)

- Using some substitutions.

Evan Closson

Spring 2003

Solving for j (magnitude)

vreli -evreli-1 -evreli-1 n(vai-1 jn/ma)

(vbi-1 - jn/mb) -evreli-1 n(vai-1 - vbi-1)

j(n/ma n/mb) -evreli-1 vreli-1 j(n/ma

n/mb) -evreli-1 - vreli-1 j(n/ma n/mb) -(e

1)vreli-1 j(n/ma n/mb) j -(e 1)vreli-1/

(nn (1/ma 1/mb))

- Solving for j.
- Now we know J jn and can use the formula vi

vi-1 J/m can to apply the impulse to change the

velocity. - Object A get J and object B get J.

Evan Closson

Spring 2003

Implementing Angular Impulse

?? timp I-1 ?i ?i-1 timp I-1 timp r

x J

- These are the formulas for change in angular

velocity and impulsive torque, where r is the

distance from the point of contact to the axis of

rotation. - Calculating the impulse J that can be used for a

collision response with rotations must take into

considerations the rotational velocity of the

colliding points as well as the linear velocity.

Evan Closson

Spring 2003

Implementing Angular Impulse

vreli n (pai pbi) p v ? x r

- We can break down J the exact same way as before

the difference is that here vreli is not defined

just by the linear velocity of the body but also

by the rotational velocity of the colliding

points.

Evan Closson

Spring 2003

Implementing Angular Impulse

vi vi-1 jn/m ?i ?i-1 r x (jn/m)

I-1 pi vi ?i x r vreli -evreli-1 vreli n

(pai pbi)

- Showing the equations used in substitution.
- Now we can have pai and pbi defined by their

previous linear and angular velocity. - We substitute these back into the relative

velocity equation the same way we did for linear

motion and solve for j.

Evan Closson

Spring 2003

Implementing Angular Impulse

- And we get . . .

t1 1/ma 1/mb t2 n (Ia-1 (ra x n)) x

ra t3 n (Ib-1 (rb x n)) x rb j -(e

1)vreli-1/ (t1 t2 t3)

Find J and then we can find the new linear and

angular velocity.

Evan Closson

Spring 2003

Results

Evan Closson

Spring 2003

References

- HECHT96 Physics Calculus, Eugene Hecht.

Brooks/Cole Publishing Company, 1996. - BOURG02 Physics for Game Developers, David

M. Bourg. OReilly Associates, Inc, 2002. - HUBBARD96 Approximating Polyhedra with

Spheres for Time-Critical Collision Detection,

Philip M. Hubbard. ACM Transactions on Graphics,

Vol. 15, No 3, July 1996, Pages 179-210. - BERG00 Computational Geometry Algorithms and

Applications, Mark de Berg, Marc van Kreveld,

Mark Overmars, Otfried Schwarzkopf.

Springer-Verlag, 2nd rev. ed. 2000. - OROURKE98 Computational Geometry in C (2nd

Ed.), Joseph O'Rourke. Cambridge University

Press, September 1998. - LANDER00 Collision Response Bouncy, Trouncy,

Fun, Jeff Lander. Gamasutra, 2000. - BOBIC00 Advanced Collision Detection

Techniques, Nick Bobic. Gamasutra, 2000. - KLOSOWSKI98 Efficient Collision Detection

Using Bounding Volume Hierarchies of k-DOPs'',

J.T. Klosowski, M. Held, J.S.B. Mitchell, H.

Sowizral, - K. Zikan, IEEE Trans. Visualizat. Comput. Graph.

4(1)21-36, Jan 1998. - BARAFF89 Analytical Methods for Dynamic

Simulation of Non-Penetrating Rigid Bodies,

David Baraff. Computer Graphics, Volume 23

Number 3, July 1989, SIGGRAPH 1989.

Evan Closson

Spring 2003

References

- BARAFF97 Physically Based Modeling

Principles and Practice, Andrew Witkin and

David Baraff. Online Course Notes for SIGRAPH 97,

http//www-2.cs.cmu.edu/baraff/ sigcourse/

index.html. - BRADSHAW03 Sphere-Tree Construction Toolkit,

Gareth Bradshaw http//isg.cs.tcd.ie/spheretree/,

2003. - BRADSHAW02 Sphere-Tree Construction Using

Dynamic Medial Axis Approximation, Bradshaw, G.

and O'Sullivan, C. ACM SIGGRAPH Symposium on

Computer Animation SCA 2002. - VAN DEN BERGEN97 Efficient Collision

Detection of Deformable Models using AABB Trees,

Gino van den Bergen, Journal of Graphics Tools,

2(4)1-14, 1997. - GOTTSCHALK96 OBB-Tree A Hierarchical

Structure for Rapid Interference Detection, S.

Gottschalk, M. Lin, and D. Manocha. Proc. ACM

SIGGRAPH, 1996. - KAISER00 3D Collision Detection, Kevin

Kaiser. Game Programming Gems, Charles River

Media, 2000. Pgs 391-402. - OLSEN00 Interpolation Methods, John Olsen.

Game Programming Gems, Charles River Media, 2000.

Pgs 141-149. - GOMEZ00a Integrating the Equations of Rigid

Body Motion, Miguel Gomez. Game Programming

Gems, Charles River Media, 2000. Pgs 150-160. - GOMEZ00b Using Implicit Euler Integration for

Numerical Stability, Miguel Gomez. Game

Programming Gems, Charles River Media, 2000. Pgs

177-181.

Evan Closson

Spring 2003