56
Constraints and Collisions Steve Rotenberg CSE291: Physics Simulation UCSD Spring 2019

Constraints and Collisions

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Constraints and Collisions

Steve Rotenberg CSE291: Physics Simulation

UCSD Spring 2019

Rotational Inertia

โ€ข The rotational inertia tensor ๐ˆ is a 3x3 symmetric matrix that is essentially the rotational equivalent of mass

โ€ข It relates the angular momentum ๐‹ of a rigid body to its angular velocity ๐›š by the equation

๐‹ = ๐ˆ โ‹… ๐›š

โ€ข This is similar to how mass relates linear momentum to

linear velocity with ๐ฉ = ๐‘š๐ฏ, but adds additional complexity because ๐ˆ is not only a matrix instead of a scalar, but it also changes over time as the object rotates

Principal Axes & Inertias

โ€ข If we diagonalize the ๐ˆ matrix, we get an orientation matrix ๐€ and a constant diagonal matrix ๐ˆ0

๐ˆ = ๐€ โ‹… ๐ˆ0 โ‹… ๐€๐‘‡

โ€ข The matrix ๐€ rotates the object from an orientation where the principal axes line up with the x, y, and z axes

โ€ข The three diagonal values in ๐ˆ0, (namely ๐ผ๐‘ฅ, ๐ผ๐‘ฆ, and ๐ผ๐‘ง) are the principal inertias. They represent the resistance to torque around the corresponding principal axis (in a similar way that mass represents the resistance to force)

Rigid Body Dynamics

โ€ข The center of mass of a rigid body behaves like a particle: โ€“ Position: ๐ฑ

โ€“ Velocity: ๐ฏ =๐‘‘๐ฑ

๐‘‘๐‘ก

โ€“ Acceleration: ๐š =๐‘‘๐ฏ

๐‘‘๐‘ก=

๐‘‘2๐ฑ

๐‘‘๐‘ก2

โ€“ Mass: ๐‘š

โ€“ Momentum: ๐ฉ = ๐‘š๐ฏ

โ€“ Force: ๐Ÿ =๐‘‘๐ฉ

๐‘‘๐‘ก= ๐‘š๐š

Rigid Body Dynamics

โ€ข Rigid bodies have additional properties for rotation: โ€“ Orientation: ๐€

โ€“ Angular velocity: ๐›š

โ€“ Angular acceleration: ๐›š =๐‘‘๐›š

๐‘‘๐‘ก

โ€“ Rotational inertia: ๐ˆ = ๐€ โ‹… ๐ˆ0 โ‹… ๐€๐‘‡

โ€“ Angular momentum: ๐‹ = ๐ˆ โ‹… ๐›š

โ€“ Torque: ๐›• =๐‘‘๐‹

๐‘‘๐‘ก= ๐›šร— ๐ˆ โ‹… ๐›š + ๐ˆ โ‹… ๐›š

Applied Forces

โ€ข When we apply a force to a rigid body at some position ๐ฑ๐‘Ÿ, this is equivalent to applying the same force on the center of mass as well as a torque equal to ๐ซ ร— ๐Ÿ, where ๐ซ = ๐ฑ๐‘Ÿ โˆ’ ๐ฑ and ๐ฑ is the position of the center of mass of the rigid body

โ€ข Various forces can apply to a rigid body and they are just summed up as a single total force and torque:

๐Ÿ๐‘ก๐‘œ๐‘ก๐‘Ž๐‘™ = ๐Ÿ๐‘–

๐›•๐‘ก๐‘œ๐‘ก๐‘Ž๐‘™ = ๐ซ๐‘– ร— ๐Ÿ๐‘–

Newton-Euler Equations

โ€ข The Newton-Euler equations describe the motion of a rigid body under applied force and torque:

๐Ÿ = ๐‘š๐š ๐›• = ๐›š ร— ๐ˆ โ‹… ๐›š + ๐ˆ โ‹… ๐›š โ€ข Solved for acceleration: ๐š = ๐Ÿ ๐‘š ๐›š = ๐ˆโˆ’1 ๐›• โˆ’ ๐›š ร— ๐ˆ โ‹… ๐›š

Kinematics of an Offset Point

โ€ข Kinematic equations for an offset point on a rigid body:

๐ฑ๐‘Ÿ = ๐ฑ + ๐ซ

๐ฏ๐‘Ÿ = ๐ฏ +๐›š ร— ๐ซ

๐š๐‘Ÿ = ๐š +๐›š ร— ๐ซ +๐›š ร— ๐›šร— ๐ซ

๐ฑ ๐ซ

๐ฑ๐‘Ÿ = ๐ฑ + ๐ซ

Offset Forces

โ€ข If we apply a force ๐Ÿ to a rigid body at offset ๐ซ1, what is the resulting acceleration ๐š at offset ๐ซ2?

๐Ÿ

๐š =?

๐ซ๐Ÿ

๐ซ๐Ÿ

Inverse Mass Matrix

๐š =1

๐‘š๐Ÿ โˆ’ ๐ซ2 โ‹… ๐ˆโˆ’1 โ‹… ๐ซ1 โ‹… ๐Ÿ

๐š =1 ๐‘š 0 00 1 ๐‘š 00 0 1 ๐‘š

โˆ’ ๐ซ2 โ‹… ๐ˆโˆ’1 โ‹… ๐ซ1 โ‹… ๐Ÿ

๐š = ๐Œโˆ’1 โ‹… ๐Ÿ

๐Œโˆ’1 =1 ๐‘š 0 00 1 ๐‘š 00 0 1 ๐‘š

โˆ’ ๐ซ2 โ‹… ๐ˆโˆ’1 โ‹… ๐ซ1

Rigid Pendulum

Rigid Pendulum

โ€ข Consider a rigid body pendulum constrained at point ๐ฑ๐‘Ÿ with a ball-and-socket joint (3-DOF rotation)

โ€ข We assume that various known forces ๐Ÿ๐‘˜๐‘›๐‘œ๐‘ค๐‘› are acting on the rigid body, such as gravity

โ€ข The joint is able to apply whatever force ๐Ÿ๐‘—๐‘œ๐‘–๐‘›๐‘ก that is necessary to keep the offset point of the rigid body stationary

โ€ข We need to solve for the unknown constraint force ๐Ÿ๐‘—๐‘œ๐‘–๐‘›๐‘ก

๐ฑ๐‘Ÿ

๐ซ

๐ฑ

๐Ÿ๐‘˜๐‘›๐‘œ๐‘ค๐‘›

๐Ÿ๐‘—๐‘œ๐‘–๐‘›๐‘ก

Rigid Pendulum

โ€ข To evaluate all forces at a particular instant:

โ€“ We first evaluate all known forces on the rigid body (gravity, air friction, joint friction, etc.)

โ€“ Next, we can determine what the acceleration ๐š๐‘Ÿ of the offset point ๐ฑ๐‘Ÿ would be with no constraint

โ€“ Then, we can use the inverse mass matrix to solve for the joint force needed to counteract the acceleration and hold the joint together

Offset Acceleration

โ€ข Assuming a known total force ๐Ÿ๐‘˜๐‘›๐‘œ๐‘ค๐‘› and torque ๐›•๐‘˜๐‘›๐‘œ๐‘ค๐‘› are acting on the rigid body, we can calculate the acceleration ๐š๐‘Ÿ at relative offset ๐ซ as:

๐š = ๐Ÿ๐‘˜๐‘›๐‘œ๐‘ค๐‘› ๐‘š

๐›š = ๐ˆโˆ’1 ๐›•๐‘˜๐‘›๐‘œ๐‘ค๐‘› โˆ’๐›šร— ๐ˆ โ‹… ๐›š

๐š๐‘Ÿ = ๐š +๐›š ร— ๐ซ +๐›š ร— ๐›šร— ๐ซ

Joint Force

โ€ข We need a joint force that will be applied at relative offset ๐ซ and must cancel out the acceleration ๐š๐‘Ÿ (at the same place)

โ€ข We can construct an inverse mass matrix ๐Œโˆ’1 using ๐ซ for both offsets

๐Œโˆ’1 =1 ๐‘š 0 00 1 ๐‘š 00 0 1 ๐‘š

โˆ’ ๐ซ โ‹… ๐ˆโˆ’1 โ‹… ๐ซ

โ€ข We then invert it to get the mass matrix ๐Œ โ€ข We can then solve for the joint force needed to cancel out the

acceleration ๐š๐‘Ÿ

๐Ÿ๐‘—๐‘œ๐‘–๐‘›๐‘ก = โˆ’๐Œ โ‹… ๐š๐‘Ÿ

Joint Force

โ€ข Once we have the joint force, we apply it to the rigid body just as any other force, thus finishing the summation of the total force and torque

โ€ข We can then use the total force and torque to integrate the motion forward

Rigid Pendulum Force Computation 1. Apply known forces

๐Ÿ๐‘˜๐‘›๐‘œ๐‘ค๐‘› = ๐Ÿ๐‘–

๐›•๐‘˜๐‘›๐‘œ๐‘ค๐‘› = ๐ซ๐‘– ร— ๐Ÿ๐‘–

2. Compute separation acceleration at joint

๐š = ๐Ÿ๐‘˜๐‘›๐‘œ๐‘ค๐‘› ๐‘š

๐›š = ๐ˆโˆ’1 ๐›•๐‘˜๐‘›๐‘œ๐‘ค๐‘› โˆ’๐›šร— ๐ˆ โ‹… ๐›š

๐š๐‘Ÿ = ๐š +๐›š ร— ๐ซ + ๐›šร— ๐›šร— ๐ซ

3. Build inverse mass matrix

๐Œโˆ’1 =1 ๐‘š 0 00 1 ๐‘š 00 0 1 ๐‘š

โˆ’ ๐ซ โ‹… ๐ˆโˆ’1 โ‹… ๐ซ

4. Solve joint constraint force

๐Œ = ๐Œโˆ’1 โˆ’1

๐Ÿ๐‘—๐‘œ๐‘–๐‘›๐‘ก = โˆ’๐Œ โ‹… ๐š๐‘Ÿ

5. Compute total force & torque

๐Ÿ๐‘ก๐‘œ๐‘ก๐‘Ž๐‘™ = ๐Ÿ๐‘˜๐‘›๐‘œ๐‘ค๐‘› + ๐Ÿ๐‘—๐‘œ๐‘–๐‘›๐‘ก

๐›•๐‘ก๐‘œ๐‘ก๐‘Ž๐‘™ = ๐›•๐‘˜๐‘›๐‘œ๐‘ค๐‘› + ๐ซ ร— ๐Ÿ๐‘—๐‘œ๐‘–๐‘›๐‘ก

๐ซ

๐Ÿ๐‘˜๐‘›๐‘œ๐‘ค๐‘›

๐Ÿ๐‘—๐‘œ๐‘–๐‘›๐‘ก

๐Ÿ๐‘ก๐‘œ๐‘ก๐‘Ž๐‘™

Joint Error

โ€ข Unfortunately, thereโ€™s a catchโ€ฆ

โ€ข The problem is that the joint forces are changing continuously, and so the finite time integration will accumulate a small error on every step

โ€ข An error in the integration of the second derivative means that the first derivative (velocity) and the zeroth derivative (position) will accumulate error

โ€ข This error shows up as a non-zero velocity at the joint and as a gap in position as well

Joint Error

โ€ข There are several options for correcting the error:

โ€“ Penalty forces

โ€“ Impulse to correct velocity

โ€“ โ€˜Pushโ€™ to correct position

โ€“ Construct as kinematic hierarchy

Articulated Bodies

Double Pendulum

โ€ข Consider the double pendulum

โ€ข Known force ๐Ÿ๐‘˜1 acts on body 1 and known force ๐Ÿ๐‘˜2 acts on body 2

โ€ข We need to simultaneously solve for joint forces ๐Ÿ๐‘—1 and ๐Ÿ๐‘—2

that hold both joints together ๐Ÿ๐‘˜1

๐Ÿ๐‘—1

๐Ÿ๐‘˜2

๐Ÿ๐‘—2

โˆ’๐Ÿ๐‘—2

๐‘๐‘œ๐‘‘๐‘ฆ 1

๐‘๐‘œ๐‘‘๐‘ฆ 2

๐‘—๐‘œ๐‘–๐‘›๐‘ก 2

๐‘—๐‘œ๐‘–๐‘›๐‘ก 1

Notation

โ€ข We define ๐ซ๐‘Ž๐‘ as the offset from the center of mass of body ๐‘Ž to joint ๐‘

โ€ข We will define ๐Œ๐‘Ž๐‘๐‘โˆ’1 to be

the inverse mass matrix computed for body ๐‘Ž, that relates the force applied at joint ๐‘ to the acceleration at joint ๐‘

๐‘๐‘œ๐‘‘๐‘ฆ 1

๐‘๐‘œ๐‘‘๐‘ฆ 2

๐‘—๐‘œ๐‘–๐‘›๐‘ก 2

๐‘—๐‘œ๐‘–๐‘›๐‘ก 1

๐ซ11

๐ซ12

๐ซ22

Known Accelerations

โ€ข The accelerations of the first body due to known force and torque are:

๐š1 = ๐Ÿ๐‘˜1 ๐‘š1

๐›š 1 = ๐ˆ1โˆ’1 ๐›•๐‘˜1 โˆ’๐›š1 ร— ๐ˆ1 โ‹… ๐›š1

๐š๐‘Ÿ11 = ๐š1 +๐›š 1 ร— ๐ซ11 +๐›š1 ร— ๐›š1 ร— ๐ซ11 ๐š๐‘Ÿ12 = ๐š1 +๐›š 1 ร— ๐ซ12 +๐›š1 ร— ๐›š1 ร— ๐ซ12

โ€ข And for the second body: ๐š2 = ๐Ÿ๐‘˜2 ๐‘š2

๐›š 2 = ๐ˆ2โˆ’1 ๐›•๐‘˜2 โˆ’๐›š2 ร— ๐ˆ2 โ‹… ๐›š2

๐š๐‘Ÿ22 = ๐š2 +๐›š 2 ร— ๐ซ22 +๐›š2 ร— ๐›š2 ร— ๐ซ22

Separation Acceleration

โ€ข For a particular joint, weโ€™re actually interested in the acceleration that the two bodies are potentially separating

โ€ข In other words, we want the difference between the offset accelerations of the two connected bodies at the joint

โ€ข By definition, we will choose the sign such that we subtract the lower numbered bodyโ€™s offset acceleration from the higher numbered bodyโ€™s

โ€ข Also, for weโ€™ll assign body 0 as the fixed coordinate system โ€ข Therefore, we get the two joint separation accelerations:

๐š๐‘—1 = ๐š๐‘Ÿ11 ๐š๐‘—2 = ๐š๐‘Ÿ22 โˆ’ ๐š๐‘Ÿ12

Joint Forces

โ€ข The separation acceleration at joint 1 resulting from joint forces will be the sum of accelerations due to ๐Ÿ๐‘—1 and โˆ’๐Ÿ๐‘—2

โ€ข The acceleration at joint 1 due to joint forces will be:

๐š๐‘—1โ€ฒ = ๐Œ111

โˆ’1 โ‹… ๐Ÿ๐‘—1 +๐Œ121โˆ’1 โ‹… โˆ’๐Ÿ๐‘—2

๐š๐‘—1โ€ฒ = ๐Œ111

โˆ’1 โ‹… ๐Ÿ๐‘—1 โˆ’๐Œ121โˆ’1 โ‹… ๐Ÿ๐‘—2

โ€ข The separation acceleration at joint 2 will be the difference of the accelerations of the offset point on body 2 and the offset point on body 1

๐š๐‘—2โ€ฒ = ๐Œ222

โˆ’1 โ‹… ๐Ÿ๐‘—2 โˆ’ ๐Œ112โˆ’1 โ‹… ๐Ÿ๐‘—1 +๐Œ122

โˆ’1 โ‹… โˆ’๐Ÿ๐‘—2

๐š๐‘—2โ€ฒ = โˆ’๐Œ112

โˆ’1 โ‹… ๐Ÿ๐‘—1 + ๐Œ122โˆ’1 +๐Œ222

โˆ’1 โ‹… ๐Ÿ๐‘—2 ๐Ÿ๐‘˜1

๐Ÿ๐‘—1

๐Ÿ๐‘˜2

๐Ÿ๐‘—2

โˆ’๐Ÿ๐‘—2

๐‘๐‘œ๐‘‘๐‘ฆ 1

๐‘๐‘œ๐‘‘๐‘ฆ 2

๐‘—๐‘œ๐‘–๐‘›๐‘ก 2

๐‘—๐‘œ๐‘–๐‘›๐‘ก 1

Joint Forces

๐š๐‘—1โ€ฒ = ๐Œ111

โˆ’1 โ‹… ๐Ÿ๐‘—1 โˆ’๐Œ121โˆ’1 โ‹… ๐Ÿ๐‘—2

๐š๐‘—2โ€ฒ = โˆ’๐Œ112

โˆ’1 โ‹… ๐Ÿ๐‘—1 + ๐Œ122โˆ’1 +๐Œ222

โˆ’1 โ‹… ๐Ÿ๐‘—2

๐š๐‘—1โ€ฒ

๐š๐‘—2โ€ฒ =

๐Œ111โˆ’1 โˆ’๐Œ121

โˆ’1

โˆ’๐Œ112โˆ’1 ๐Œ122

โˆ’1 +๐Œ222โˆ’1 โ‹…

๐Ÿ๐‘—1๐Ÿ๐‘—2

๐š๐‘—โ€ฒ = ๐Œโˆ’1 โ‹… ๐Ÿ๐‘—

Double Pendulum

๐Œโˆ’1 =๐Œ111

โˆ’1 โˆ’๐Œ121โˆ’1

โˆ’๐Œ112โˆ’1 ๐Œ122

โˆ’1 +๐Œ222โˆ’1

๐Ÿ๐‘— = โˆ’๐Œ โ‹… ๐š๐‘— โ€ข To compute the joint forces for the double pendulum:

โ€“ Apply known forces โ€“ Compute separation acceleration for each joint โ€“ Build 6x6 system inverse mass matrix

โ€“ Invert mass matrix to solve joint forces with ๐Ÿ๐‘— = โˆ’๐Œ โ‹… ๐š๐‘— โ€“ Add joint forces to compute total forces and torques

Articulated Bodies

โ€ข We can extend this method to large systems of constrained rigid bodies

โ€ข We end up producing a large system mass matrix that relates the vector of all joint forces to the vector of all joint accelerations

โ€ข If we assume ๐‘› 3-DOF ball joints, we would end up with a 3๐‘› ร— 3๐‘› mass matrix describing the relationship between joint forces and joint separation accelerations

Constraint Types

โ€ข Weโ€™ve looked at 3-DOF ball-and-socket joints โ€ข These are nice because they require solving a

straightforward 3D force โ€ข However, other joint types are also possible such

as 1-DOF hinges, 2-DOF universal joints, 1-DOF translational โ€˜prismaticโ€™ joints, and more

โ€ข These other joint types can apply a constraint force as well as torques

โ€ข A 1-DOF hinge joint, for example, applied 5 constraints: 3 forces, and 2 torques, leaving 1 DOF free to rotate

Constraint Types

โ€ข To handle different constraint types, we need to compute the individual mass matrices differently

โ€ข We can generalize the force-acceleration relationship to include torques and angular accelerations

โ€ข A 1-DOF rotational joint would require a 5x5 inverse mass matrix that relates 3 forces and 2 torques to 3 accelerations and 2 angular accelerations

โ€ข The overall process is similar to how we derived the inverse mass matrix in the last lecture

System Mass Matrix

โ€ข For a system of articulated rigid bodies, we end up with an ๐‘š ร—๐‘š mass matrix that relates constraint forces to accelerations, where ๐‘š is the total number of constrained degrees of freedom

โ€ข We see that a large system of constraints results in a large matrix that must be inverted

โ€ข The matrix will be more sparse for loosely coupled systems and less sparse for tightly coupled systems

โ€ข The matrix will also be positive definite โ€ข There are several approaches to solving this system:

โ€“ Direct matrix solution โ€“ Pairwise solution โ€“ Recursive solution (Featherstoneโ€™s algorithm) โ€“ Lagrangian formulation

Direct Solution

โ€ข If we have a dense mass matrix, we can directly invert with standard matrix inversion or solvers

โ€ข Larger matrices tend to be more sparse, and so can benefit from special purpose sparse solvers

โ€ข There are a variety of special purpose solvers that can take advantage of properties of the system (sparseness, positive-definitenessโ€ฆ)

Pairwise Algorithms

โ€ข One can also use pairwise algorithms to solve large systems of constraints

โ€ข With this method, we group all constraints into a queue, ordered by the magnitude of the separation accelerations

โ€ข We then iteratively solve for the constraint at the top of the queue, and then add it to the known forces, recomputing separation accelerations of connected joints and re-ordering the queue as needed

โ€ข Basically, this method continues to fix the constraint with the largest separation and repeats until it converges and all separations approach zero

Featherstoneโ€™s Algorithm

โ€ข Featherstoneโ€™s algorithm is a recursive method for solving the dynamics of tree structures without kinematic loops

โ€ข It can evaluate systems in linear O(n) time โ€ข It traverses from the fixed base (or an unfixed root) to the

leaf nodes computing joint separation accelerations and accumulating a mass matrix connecting from the base to each leaf

โ€ข Then, it solves the joint forces from the leaves progressing back to the root

โ€ข There are some adaptations to handle kinematic loops, but they compromise the linear time behavior

โ€ข โ€œRobot Dynamics Algorithmsโ€, Featherstone, 1987

Lagrangian Dynamics

โ€ข We can also reformulate the equations into the Lagrangian form โ€ข This is fairly different from how weโ€™ve done things so far โ€ข Lagrangian methods define the state of the system using

generalized coordinates, only using coordinates for actual DOFs in the system

โ€ข In this approach, the constraints never actually need to be solved, but we do have to solve for the motion of the degrees of freedom

โ€ข If the number of unconstrained DOFs is less than the number of constrained DOFs, then these methods can be faster than the Newtonian methods described so far

โ€ข However, the method can be tricky to work with and doesnโ€™t handle collisions or energy damping easily

Kinematic Loops

โ€ข We often distinguish between articulated bodies with open tree-like structures from bodies with closed kinematic loops

โ€ข Closed loops can add challenges to some of the solution methods, as they may result in over-constrained systems and non-invertible mass matrices

โ€ข Some methods require special handling for these, while other methods (like pairwise solvers) donโ€™t require anything special

Collisions

Detection and Response

โ€ข Collision handling requires two different technologies: โ€“ Collision detection (geometry) โ€“ Collision response (physics)

โ€ข The collision detection problem is a complex application of 3D geometry and spatial data structures, and will be discussed in more detail in the next lecture

โ€ข Collision response is the physics problem of determining the forces (or impulses) resulting from the collisions

Impact vs. Contact

โ€ข It is useful to distinguish between momentary (instantaneous) impacts and finite time contacts

โ€ข With impacts, the closing velocity is positive before the collision, and with contacts, the closing velocity is zero (or very close)

โ€ข Some rigid body methods handle impacts differently from contacts, while other methods donโ€™t distinguish between the two

Impulse

โ€ข Force is the derivative of momentum, and changes in momentum require forces acting over time

โ€ข An impulse ๐ฃ is a large force applied over a short time, such that it can be treated as an instantaneous change in momentum, rather than a rate of change over time

๐ฃ = ๐Ÿ๐‘‘๐‘ก

โ€ข Impulses operate in a very similar fashion as forces, except they affect the velocity

instead of the acceleration โ€ข As with forces, impulses obey Newtonโ€™s Third Law (action/reaction) โ€ข An impulse can be applied to a rigid body at relative offset ๐ซ resulting in an

instantaneous change in momentum ๐ฉ and angular momentum ๐‹ of the body

โˆ†๐ฉ = ๐ฃ โˆ†๐‹ = ๐ซ ร— ๐ฃ

Collision Impulses

โ€ข Most rigid body methods resolve instantaneous impacts with impulses

โ€ข Persistent contacts can be simulated with forces or impulses, but many modern methods use impulses

โ€ข In fact, constraints can be handled through forces or impulses as well, and by using impulses, one can handle impacts, contacts, and constraints through a single process

Single Body Impact

โ€ข We define ๐ฑ๐‘Ÿ as the impact point, ๐ง as the normal of the impact surface, ๐ฏ๐‘Ÿ as the offset velocity before the collision, ๐ฏ๐‘Ÿโ€ฒ as the offset velocity after, and ๐ฃ is the impulse

๐ฏ๐‘Ÿ

๐ฏ๐‘Ÿโ€ฒ ๐ง

๐ฑ๐‘Ÿ

๐ฃ

Collision Restitution

โ€ข In terms of collisions, restitution refers to the amount of kinetic energy that is conserved, and thus the amount of bounce

โ€ข We can measure it with a coefficient of restitution ๐œ€ that will range from 0 (perfectly inelastic) to 1 (perfectly elastic)

โ€ข For simplicity, we can assume that we have a constant restitution for a rigid body. If two rigid bodies of different restitution collide, it is a reasonable heuristic to use the lower of the two for the impulse computation

โ€ข Note: there are different ways to define the exact meaning of this constant, and it is ultimately just an approximation to a far more complex process that is dependent on the material properties and shape of the object

โ€ข Note: sometimes called coefficient of elasticity

Collision Impulse

โ€ข We need a collision impulse that will be applied at relative offset ๐ซ and must cancel out the velocity ๐ฏ๐‘Ÿ (at the same place)

โ€ข We can construct an inverse mass matrix ๐Œโˆ’1 using ๐ซ for both offsets

๐Œโˆ’1 =1 ๐‘š 0 00 1 ๐‘š 00 0 1 ๐‘š

โˆ’ ๐ซ โ‹… ๐ˆโˆ’1 โ‹… ๐ซ

โ€ข We then invert it to get the mass matrix ๐Œ โ€ข We can then solve for the impulse needed to cancel out the velocity

๐ฏ๐‘Ÿ

๐ฃ๐‘–๐‘š๐‘๐‘Ž๐‘๐‘ก = โˆ’ 1 + ๐œ€ ๐Œ โ‹… ๐ฏ๐‘Ÿ

*Frictionless Impact

โ€ข [insert slide here]

Friction

Coulomb Friction

โ€ข The simple but effective Coulomb friction model says:

๐‘“๐‘ ๐‘ก๐‘Ž๐‘ก โ‰ค ๐œ‡๐‘ ๐‘“๐‘›๐‘œ๐‘Ÿ๐‘š ๐‘“๐‘‘๐‘ฆ๐‘› = ๐œ‡๐‘‘๐‘“๐‘›๐‘œ๐‘Ÿ๐‘š

โ€ข Where ๐‘“๐‘ ๐‘ก๐‘Ž๐‘ก is the force due to static friction, ๐‘“๐‘‘๐‘ฆ๐‘› is the force due to dynamic friction, ๐‘“๐‘›๐‘œ๐‘Ÿ๐‘š is the normal force, and ๐œ‡๐‘  and ๐œ‡๐‘‘ are the coefficients of static and dynamic friction

โ€ข The direction of the force will be opposite of the tangential velocity at the contact point

โ€ข The coefficients range from 0 (perfectly frictionless) to around 1.5 or so, but there really isnโ€™t a strict maximum, as materials could conceivably have adhesive (sticky) properties

โ€ข ๐œ‡๐‘  is typically a bit larger than ๐œ‡๐‘‘

Friction Cone

โ€ข Consider a block sliding on a flat surface

โ€ข The ground applies a normal force and a friction force

โ€ข According to the Coulomb friction model, the two forces must add up to a vector that lies within the friction cone

โ€ข The same can be said about impulses resulting from impacts

๐ฃ

๐œ‡

1

Tangential Velocity

โ€ข We need to find the tangential velocity of the impact in order to determine the direction the friction will act

โ€ข We start by taking the difference of the two object velocities offset at the collision point

๐ฏ = ๐ฏ1 โˆ’ ๐ฏ2 โ€ข If ๐ง is the surface normal if the contact point, we can decompose

the velocity into normal and tangential components:

๐ฏ๐‘›๐‘œ๐‘Ÿ๐‘š = ๐ฏ โ‹… ๐ง ๐ง ๐ฏ๐‘ก๐‘Ž๐‘› = ๐ฏ โˆ’ ๐ฏ๐‘›๐‘œ๐‘Ÿ๐‘š

Rolling & Spinning Friction

โ€ข One can also add rolling and spinning friction effects to collisions and contacts

โ€ข We must first find the angular velocity difference at the collision point โ€ข From there, we can decompose it into rolling and spinning components

based on the contact normal ๐ง

๐›š๐‘ ๐‘๐‘–๐‘› = ๐›š โ‹… ๐ง ๐ง

๐›š๐‘Ÿ๐‘œ๐‘™๐‘™ = ๐›šโˆ’๐›š๐‘ ๐‘๐‘–๐‘› โ€ข We can then apply friction torques proportional to each of those based on

separate constants

๐›•๐‘“๐‘Ÿ๐‘–๐‘ = โˆ’ ๐Ÿ๐‘›๐‘œ๐‘Ÿ๐‘š ๐œ‡๐‘ ๐‘๐‘–๐‘›๐›š๐‘ ๐‘๐‘–๐‘› + ๐œ‡๐‘Ÿ๐‘œ๐‘™๐‘™๐›š๐‘Ÿ๐‘œ๐‘™๐‘™

Joint Friction

โ€ข We can also add friction on articulated joints โ€ข Usually, these would be based on the angular velocity of the joint, which is

the difference of the angular velocities of the two connected bodies โ€ข For rotational joints, the joint friction will be in the form of a torque

applied equal and opposite to the two connected bodies

๐›•๐‘“๐‘Ÿ๐‘–๐‘ = โˆ’๐œ‡๐‘—๐‘œ๐‘–๐‘›๐‘ก๐›š๐‘—๐‘œ๐‘–๐‘›๐‘ก

โ€ข Where ๐›•๐‘“๐‘Ÿ๐‘–๐‘ is the friction torque, ๐œ‡๐‘—๐‘œ๐‘–๐‘›๐‘ก is the joint friction, and ๐›š๐‘—๐‘œ๐‘–๐‘›๐‘ก is the joint angular velocity

โ€ข Static friction can also be modeled for joints. To do this, one must first assume a 6-DOF constraint and solve for the required constraint force. If this is within the static friction limit, it is used, otherwise, it is solved as a regular joint and dynamic friction is added

Collision Impulse with Friction

โ€ข We wish to find a collision impulse ๐ฃ that accounts for the elasticity and friction โ€ข We can compute the velocity of the colliding point at offset ๐ซ as:

๐ฏ๐‘Ÿ = ๐ฏ + ๐›š ร— ๐ซ

๐ฏ๐‘›๐‘œ๐‘Ÿ๐‘š = ๐ฏ๐‘Ÿ โ‹… ๐ง ๐ง ๐ฏ๐‘ก๐‘Ž๐‘› = ๐ฏ๐‘Ÿ โˆ’ ๐ฏ๐‘›๐‘œ๐‘Ÿ๐‘š

โ€ข We also build the inverse mass matrix ๐Œโˆ’1 for the body using ๐ซ for both offsets โ€ข We start by assuming perfect static friction and solving for the impulse that would result in an

elastic bounce and the tangential velocity going to zero after the collision:

๐ฏ๐‘›๐‘œ๐‘Ÿ๐‘šโ€ฒ = โˆ’๐œ€๐ฏ๐‘›๐‘œ๐‘Ÿ๐‘š

๐ฃ0 = ๐Œ โ‹… ๐ฏ๐‘›๐‘œ๐‘Ÿ๐‘šโ€ฒ โˆ’ ๐ฏ๐‘›๐‘œ๐‘Ÿ๐‘š

โ€ข This allows us to solve the impulse that produces this result โ€ข If this lies within the friction cone, then weโ€™re done โ€ข Otherwise, we assume sliding (dynamic) friction โ€ข For more details, see section 7 of โ€œNonconvex Rigid Bodies with Stackingโ€, Guendelman, Bridson,

Fedkiw, 2003

Multibody Collisions

Multiple Body Collisions

โ€ข We can solve for multiple collisions in the same basic way that we solved for multiple constraint forces

โ€ข We set up a large linear system that includes all of the collision constraints

โ€ข There are two main differences from the articulated body solution: โ€“ For collisions, we work with impulses rather than

forces โ€“ For collisions, we are solving an inequality problem

rather than an equality problem

Linear Complementarity

โ€ข Collisions result in inequality constraints because they will only act to prevent objects from moving towards each other and have no effect on objects moving apart

โ€ข A large system of inequalities can be formed into a linear complementarity problem (LCP) which is a well studied class of problems

โ€ข Various solution methods have been proposed to address these, and some are discussed in the overview paper on the web page

Pairwise Solvers

โ€ข Pairwise solvers iteratively solve one collision at a time until the entire system is satisfied

โ€ข These have proven to be pretty effective in handling of multiple collisions and constraints, as each one can be treated with its own rules and special cases

โ€ข Some other methods may be faster, but pairwise solvers tend to be very general purpose and easy to implement