3 6 RESTING CONTACTS ANDFRICTION Exploration of resting

  • Slides: 26
Download presentation
3. 6. RESTING CONTACTS ANDFRICTION Exploration of resting contacts and friction

3. 6. RESTING CONTACTS ANDFRICTION Exploration of resting contacts and friction

RESTING CONTACTS Resolving a set of contacts

RESTING CONTACTS Resolving a set of contacts

A resting contact is a type of contact where the objects involved are moving

A resting contact is a type of contact where the objects involved are moving neither apart nor together. Resting Forces In this case they need to be kept apart while making sure each object behaves normally using Newton’s Third Law of Motion: “For every action there is an equal and opposite reaction. ” In other words, an object resting on the ground is subject to a gravitational force, pushing the object down, and an equal upwards reaction force from the ground preventing the object from moving down.

adding these into the overall mix of applied forces (using D’Alembert’s principle). This requires

adding these into the overall mix of applied forces (using D’Alembert’s principle). This requires a global approach for contact resolution and becomes considerably more complex as the number of resting contacts between bodies increases. Resting Forces Whilst the above approach is more accurate (and adopted within industry strength packages) a less complex (and less accurate) solution can also be used: resting contacts are treated in terms of a series of microcollisions.

update (i. e. the resting force is modelled as a series of impulses) Micro-collisions

update (i. e. the resting force is modelled as a series of impulses) Micro-collisions Modelling a resting contact as a series of impulses may be problematic as, depending on the restitution, resolving the downwards motion may produce upwards motion - resulting in mini-bounces, i. e. jitter. This problem can be (mostly) overcome by: • Removing any velocity built up from acceleration in the previous update. • Decrease the coefficient of restitution for collisions with very low speeds.

Removing velocity due to accelerative forces Micro-collisions: Removing Accelerative By tracking the acceleration at

Removing velocity due to accelerative forces Micro-collisions: Removing Accelerative By tracking the acceleration at each rigid body update (only linear Velocity acceleration need be stored as most reaction forces arise from gravity – which is a linear acceleration), it becomes possible to calculate the desired change in velocity for a contact (Stage 4 of the Velocity Resolution algorithm) by subtracting the acceleration-induced velocity in the direction of the contact normal, vacc, ie. (where vs is the separating velocity and c is the coefficient of restitution):

Micro-collisions: Lowering the Restitution A complementary approach to removing the effects of gravity acceleration

Micro-collisions: Lowering the Restitution A complementary approach to removing the effects of gravity acceleration is to also reduce the restitution of contacts involving very low closing velocities (thereby dampening all low speed contacts). This can be simply accomplished as: float applied. Restitution = contact. Velocity. magnitude() < velocity. Limit ? 0. 0 f : restitution;

FRICTION Introducing friction

FRICTION Introducing friction

Types of Friction is the force generated when one object moves or tries to

Types of Friction is the force generated when one object moves or tries to move in contact with another. There are two forms of friction: static and dynamic.

Static friction is a force that stops an object from moving when it is

Static friction is a force that stops an object from moving when it is stationary and depends on the materials in contact and the reaction force: Types of Friction: Static Friction where fstatic is the friction force generated, μstatic is the coefficient of static friction (an empirical material-pair property) and r is the reaction force in the direction of the contact normal (given by where d is the contact normal and f is the total force exerted). As more force is exerted, static friction pushes back until the limit of static friction (μstatic|r|) is reached. A force beyond this limit may result in object movement, a sudden drop in the opposing frictional force, and the introduction of dynamic friction.

Types of Friction: Dynamic Friction Dynamic (or kinetic) friction behaves like static friction but

Types of Friction: Dynamic Friction Dynamic (or kinetic) friction behaves like static friction but has a different coefficient of friction and can be defined as (where μ dynamic is the coefficient of dynamic friction, and vplanar is movement velocity along the plane). Rather than acting in the opposite direction to the planar force (as for static friction), dynamic friction acts in the opposite direction to the object velocity (thereby acting to slow down and stop the object even if the applied moving force is removed). Within game physics, both types of friction are generally combined into a single model, with a single coefficient of friction.

Types of Friction: Isotropic and Anisotropic Friction across a surface may be either isotropic

Types of Friction: Isotropic and Anisotropic Friction across a surface may be either isotropic or anisotropic. Isotropic friction has the same coefficient in all directions. Anisotropic friction can have different coefficients in different directions. Typically game engines are only concerned with modelling isotropic friction (or only support a simple anisotropic model of friction).

As an impulse-based approach using micro-collisions for resting contacts has been assumed, it will

As an impulse-based approach using micro-collisions for resting contacts has been assumed, it will be necessary to implement friction within this framework (an approximation as resting forces are not calculated) Within a force based physics engine, friction would be introduced into the mix as another type of force. Implementing Friction as Impulses Given a contact, the velocity of the object is adjusted in the direction of the contact normal. By extending this approach to include the remaining two contact directions (i. e. representing directions in the plane of the contact) we have a means of introducing static and dynamic friction, i. e. the change in velocity now includes: Vector 3 delta. Velocity. Vector( velocity. Change. Along. Collision. Normal, contact. Velocity. Along. YAxis, contact. Velocity. Along. ZAxis);

be removed (representing the limit of static friction) we use the relationship between velocity

be removed (representing the limit of static friction) we use the relationship between velocity and impulse (where g is the impulse and m the mass): Implementing Friction The normal reaction force can be approximately calculated from using the amount of velocity to be removed in the direction of the contact normal. Assuming Δv is the change in velocity the reaction force is approximated as: Hence, the maximum frictional impulse that should be applied is: Where Δgnormal is the impulse in the direction of the contact normal (i. e. the impulse which is currently calculated to resolve contact velocity)

Implementing Friction Dynamic friction can be handled by scaling the y and z (i.

Implementing Friction Dynamic friction can be handled by scaling the y and z (i. e. planar) components of the impulse so that their combined size is exactly μ times the size of the x impulse: Determine the impulse needed to Vector 3 impulse. Contact; remove all velocity components at the contact (including y and z planar velocities) – explored next. float planar. Impulse = Math. Sqrt(impulse. Contact. y*impulse. Contact. y + impulse. Contact. z*impulse. Contact. z); Determine if the impulse to be applied falls within the range of static friction if (planar. Impulse > impulse. Contact. x * friction) { Apply dynamic friction if impulse. Contact. y /= planar. Impulse; needed impulse. Contact. y *= friction * impulse. Contact. x; impulse. Contact. z /= planar. Impulse; impulse. Contact. z *= friction * impulse. Contact. x; }

Step 2: Determine the change in velocity (both linear and angular) at Reminde impulse

Step 2: Determine the change in velocity (both linear and angular) at Reminde impulse r: An the contact point for each object per unit of applied impulse. applied a Modifying Velocity Resolution long one direction may Step 2 must now determine the change in velocity per unitcimpulse ause rotationa given any combination of impulses in the three contact directions. l change a In long anothvector order to do this, a matrix converting an input contact impulse er axis. into a corresponding velocity change vector must be built. Step 3: Invert the velocities determined in step 2 The inverse of the matrix produced in step two must be generated (i. e. thereby transforming a desired change in velocity into a corresponding impulse)

Step 5. From the change in velocity we can calculate the impulse that must

Step 5. From the change in velocity we can calculate the impulse that must be generated. Modifying the Velocity Resolution Algorithm The inverted matrix must be used to determine the contact impulse vector. Additionally, the static/dynamic friction test (last slide) must be used to determine frictional planar velocity change.

Step 2 Modification Determine (angular) velocity per unit of impulse Vector 3 torque. Per.

Step 2 Modification Determine (angular) velocity per unit of impulse Vector 3 torque. Per. Unit. Impulse = Cross( relative. Contact. Position, contact. Normal ) Vector 3 rotation. Per. Unit. Impulse = The above approach must be extended to use all three components inverse. Inertia. Tensor. Transform(torque. Per. Unit. Impulse); Vector 3 = of the basis velocity. Per. Unit. Impulse matrix (and not just the contact normal). Cross( rotation. Per. Unit. Impulse, relative. Contact. Position _); Vector 3 velocity. Per. Unit. Impulse. Contact = In order to take the (equivalent) cross product of the relative contact. To. World. Transform. Transpose(velocity. Per. Unit. Impulse); contact position and the contact basis matrix (which can be thought about in terms of turning an impulse into a torque), a skew -symmetric matrix is used.

Step 2 Modification Determine (angular) velocity per unit of impulse the vector product is

Step 2 Modification Determine (angular) velocity per unit of impulse the vector product is equivalent to the following matrix-by-vector multiplication: Additionally, as we have

Step 2 Modification Determine (angular) velocity per unit of impulse Matrix 3 impulse. Torque

Step 2 Modification Determine (angular) velocity per unit of impulse Matrix 3 impulse. Torque Build a skew-symmetric matrix for the = Build. Skew. Symmetric(relative. Contact. Position); ‘cross’ product Determine the resultant torque per unit of applied impulse using the skew. Matrix 3 matrix torque. Per. Unit. Impulse = impulse. Torque * contact. To. World; symmetric Determine the resultant rotation per unit of applied impulse using matrix Matrix 3 rotation. Per. Unit. Impulse = multiplication inverse. Inertia. Tensor * torque. Per. Unit. Impulse; The inverse cross product is simply Matrix 3 velocity. Per. Unit. Impulse = equivalent to a -1 rotation. Per. Unit. Impulse * impulse. Torque; multiplication of the velocity. Per. Unit. Impulse *= -1; skew-symmetric As before, the result is expressed in terms of contact coordinates matrix Matrix 3 velocity. Per. Unit. Impulse. Contact = contact. To. World. Transpose() * velocity. Per. Unit. Impulse;

coordinates. Step 2 Modification Determine (angular) velocity per unit of impulse If the contact

coordinates. Step 2 Modification Determine (angular) velocity per unit of impulse If the contact is between two moveable rigid bodies, then the same process can be performed for each body and the results simply combined by using matrix addition to add both matrices together. Aside: See the recommend course text for an efficient means of accomplishing this.

In order to transform this vector-to-vector transform into a matrix form that can be

In order to transform this vector-to-vector transform into a matrix form that can be added to the angular matrix, the inverse mass is expressed in a matrix form, i. e. : multiplying a vector by a scalar quantity k is equivalent to transforming it by the matrix Step 2 Modification Determine (linear) velocity per unit of impulse Hence, in order to combine linear and angular motion, the angular matrix need only be modified by adding the inverse mass to diagonal elements (e. g. matrix. M 11 += inverse. Mass, etc. )

have built an iterative, impulse-based, rigid-body game physics engine. AThefinished engine next sectiongame exploresphysics

have built an iterative, impulse-based, rigid-body game physics engine. AThefinished engine next sectiongame exploresphysics performance enhancements within the engine.

ed ect r i g D din a e r DIRECTED READING Directed physics

ed ect r i g D din a e r DIRECTED READING Directed physics reading

Directed reading • Read Chapter 15 of Game Physics Engine Development (pp 351 -374)

Directed reading • Read Chapter 15 of Game Physics Engine Development (pp 351 -374) on collision resolution with frictional forces. ed ect r i g D din rea

Summary Today we explored: ü How to resolve contacts taking into account frictional forces

Summary Today we explored: ü How to resolve contacts taking into account frictional forces : o d o T cted e r i d e h t d a e üR reading. t h g i m u o y f i r üConside your p o l e v e d o t wish ine as g n e s c i s y h p own your project.