Concepts for Programming a Rigid Body Physics Engine Part 1 Presented by Scott Hawkins.

Slides:



Advertisements
Similar presentations
John C. Hart CS 318 Interactive Computer Graphics
Advertisements

Manipulator Dynamics Amirkabir University of Technology Computer Engineering & Information Technology Department.
3.3. Introduction to Real-time Physics III
CS B659: Principles of Intelligent Robot Motion Rigid Transformations.
Chris Hall Aerospace and Ocean Engineering
Color Problem Have a black-box function that returns a bright color in 24-bit RGB Want a paler version of the output What to do?
Animation Keyframe Inverse Kinematic Parametric Scripted
1Notes  Demetri Terzopoulos talk: Thursday, 4pm Dempster 310.
ME Robotics Dynamics of Robot Manipulators Purpose: This chapter introduces the dynamics of mechanisms. A robot can be treated as a set of linked.
Test 3 today, at 7 pm and 8:15 pm, in Heldenfels 109 Chapters
Computer Graphics Recitation 2. 2 The plan today Learn about rotations in 2D and 3D. Representing rotations by quaternions.
Scenegraph. Scenegraph Nodes - all implement a run function Leaf/Geo Nodes - typedefs of sgNode superclass –Poly Mesh A geo node that stores a list of.
Ch. 7: Dynamics.
Game Physics Chris Miles. The Goal To learn how to create game objects with realistic physics models To learn how to simulate aspects of reality in order.
1cs533d-winter-2005 Notes  Assignment 2 going okay? Make sure you understand what needs to be done before the weekend  Read Guendelman et al, “Nonconvex.
Euler Rotation. Angular Momentum  The angular momentum J is defined in terms of the inertia tensor and angular velocity. All rotations included  The.
Chapter 11 Rolling, Torque, and Angular Momentum In this chapter we will cover the following topics: -Rolling of circular objects and its relationship.
Manipulator Dynamics Amirkabir University of Technology Computer Engineering & Information Technology Department.
UNC Chapel Hill M. C. Lin Reading Assignment & References D. Baraff and A. Witkin, “Physically Based Modeling: Principles and Practice,” Course Notes,
Introduction to ROBOTICS
Orientations Goal: –Convenient representation of orientation of objects & characters in a scene Applications to: – inverse kinematics –rigid body simulation.
FE/Graduate Seminar Review Notes
Computer graphics & visualization Rigid Body Simulation.
CS I400/B659: Intelligent Robotics Rigid Transformations.
3.7. O THER G AME P HYSICS A PPROACHES Overview of other game engine physics approaches.
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Physically Based Animation.
Rotations and Translations
Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
Game Physics – Part IV Moving to 3D
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Dynamics.  relationship between the joint actuator torques and the motion of the structure  Derivation of dynamic model of a manipulator  Simulation.
Spring Rigid Body Simulation. Spring Contents Unconstrained Collision Contact Resting Contact.
Ken Youssefi Mechanical Engineering dept. 1 Mass Properties Mass property calculation was one of the first features implemented in CAD/CAM systems. Curve.
Sect 5.4: Eigenvalues of I & Principal Axis Transformation
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Collisions & Contact.
Lecture Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions.
Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan.
Joint Reaction Forces Muscle Moments Joint Power
Gary Snethen Crystal Dynamics
Introduction to Particle Simulations Daniel Playne.
Spring Rigid Body Simulation. Spring Contents Unconstrained Collision Contact Resting Contact.
The Spinning Top Chloe Elliott. Rigid Bodies Six degrees of freedom:  3 cartesian coordinates specifying position of centre of mass  3 angles specifying.
Robotics II Copyright Martin P. Aalund, Ph.D.
1 Rotation of a Rigid Body Readings: Chapter How can we characterize the acceleration during rotation? - translational acceleration and - angular.
CS274 Spring 01 Lecture 7 Copyright © Mark Meyer Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
Rick Parent - CIS682 Rigid Body Dynamics simulate basic physics of an object subject to forces Keyframing can be tedious - especially to get ‘realism’
Dynamics. Motion with Regard to Mass Particle Dynamics Mass concentrated in point Newton’s Equation Governs Motion f = M x.
Honours Graphics 2008 Session 9. Today’s focus Physics in graphics Understanding:
Concepts for Programming a Rigid Body Physics Engine Part 2 Presented by Scott Hawkins.
UNIT 6 Rotational Motion & Angular Momentum Rotational Dynamics, Inertia and Newton’s 2 nd Law for Rotation.
Advanced Computer Graphics Rigid Body Simulation
Physically Based Simulations For Games
Constrained Body Dynamics
2D Simulation of Rigid Bodies
Manipulator Dynamics 1 Instructor: Jacob Rosen
Introduction To Robotics
Lecture Rigid Body Dynamics.
Lecture 16 Newton Mechanics Inertial properties,Generalized Coordinates Ruzena Bajcsy EE
3.7. Other Game Physics Approaches
Manipulator Dynamics 2 Instructor: Jacob Rosen
Chapter 11 Rolling, Torque, and Angular Momentum
Rigid Body Dynamics (unconstrained)
Rigid Body Dynamics ~ f = p h g
Motion in Real and Virtual Worlds
A definition we will encounter: Groups
Computer Animation Algorithms and Techniques
Chapter 2. Geometrical Methods
Physics 319 Classical Mechanics
GPAT – Chapter 7 Physics.
Presentation transcript:

Concepts for Programming a Rigid Body Physics Engine Part 1 Presented by Scott Hawkins

Game Physics Engine Development by Ian Millington source:

Topics Mathematical Data Types Rigid Body Data Algorithm for Updating the Physics –Finding the timestep –Applying forces and torques –Integration –Collision Detection –Collision Resolution

Mathematical Data Types real –time, t Vector –position, p Quaternion –orientation, θ 3x3 Matrix –inertial tensor, I 4x4 Matrix

Quaternions q represented using four reals, w, x, y, z : q = w + xi + yj + zk relationship between i, j, and k : ij = -ji = k jk = -kj = i ki = -ik = j ii = jj = kk = ijk = -1

Quaternion Operations q 1 + q 2 = (w 1 + w 2 ) + (x 1 + x 2 )i + (y 1 + y 2 )j + (z 1 + z 2 )k q 1 * q 2 = w 1 w 2 - x 1 x 2 - y 1 y 2 - z 1 z 2 + (w 1 x 2 + x 1 w 2 + y 1 z 2 - z 1 y 2 )i + (w 1 y 2 - x 1 z 2 + y 1 w 2 + z 1 x 2 )j + (w 1 z 2 + x 1 y 2 - y 1 x 2 + z 1 w 2 )k

Rigid Body Data mass, m (real) inertia tensor, I (3x3 Matrix) position, p (Vector) velocity, p’ (Vector) acceleration, p” (Vector) orientation, θ (Quaternion) angular velocity, θ’ (Vector) angular acceleration, θ” (Vector)

Rigid Body Data force accumulator, f (Vector) torque accumulator, τ (Vector) inverse mass, m -1 (real) inverse inertia tensor, I -1 (3x3 Matrix) I -1 in world coordinates(3x3 Matrix) transform matrix(4x4 Matrix)

Computing the Inertia Tensor, I I =[ I x -I xy -I xz ] [-I xy I y -I yz ] [-I xz -I yz I z ] I x = Σm i (y i 2 + z i 2 ) I y = Σm i (x i 2 + z i 2 ) I z = Σm i (x i 2 + y i 2 ) I xy = Σm i x i y i I yz = Σm i y i z i I xz = Σm i x i z i

Meaning of Orientation, θ θ is of the form: θ = cos(θ / 2) + n x sin(θ / 2)i + n y sin(θ / 2)j + n z sin(θ / 2)k θ represents a rotation by angle θ about a vector axis n. If θ is zero, the object is not rotated, and θ = 1 + 0i + 0j + 0k

Meaning of Angular Velocity, θ’ θ’ is of the form: θ’ = n x ωi + n y ωj + n z ωk This is called “axis-angle” form. θ’ represents an angular rate of ω about a vector axis n. Angular acceleration is also in axis-angle form.

Computing the Transform Matrix M = [2θ x 2 +2θ w θ x θ y +2θ z θ w 2θ x θ z -2θ y θ w p x ] [2θ x θ y -2θ z θ w 2θ y 2 +2θ w θ y θ z +2θ x θ w p y ] [2θ x θ z +2θ y θ w 2θ y θ z -2θ x θ w 2θ z 2 +2θ w 2 -1 p z ] [ ] Useful for transforming geometry from local coordinates into world coordinates

Updating the Physics Find the timestep Δt Apply forces and torques Integrate Collision detection Collision resolution

Computing Δt Remember the clock value for the previous frame Δt = t current - t previous

Adding Forces and Torques Force and Torque Generators –in C++, use classes with virtual methods –in Java, use interfaces –user implements updateForce() or updateTorque() method All force and torque generators should be registered before the frame begins

Adding Forces and Torques p” = m -1 f θ” = I -1 τ = I -1 [(p point - p) x f]

Adding Forces and Torques Call the updateForce() or updateTorque() method for every registered force or torque generator These add to the force and torque accumulators in the rigid bodies f = Σf i τ = Στ i

Integration p” = m -1 f θ” = I -1 τ p next = p + p’Δt p’ next = p’ + p”Δt θ next = θ + (Δt/2)ωθ ω = 0 + θ’ x i + θ’ y j + θ’ z k θ’ next = θ’ + θ”Δt

Integration Use Newton’s second law to get p” and θ” f = mp” p” = f / m p” = m -1 f τ = Iθ” θ” = I -1 τ

Integration Use the explicit version of Euler’s method to integrate position and velocity p next = p + p’Δt p’ next = p’ + p”Δt

Integration Also use explicit Euler’s method for orientation and angular velocity θ next = θ + (Δt/2)ωθ ω = 0 + θ’ x i + θ’ y j + θ’ z k why it works: magic? θ’ next = θ’ + θ”Δt

Collision Detection Return a list of contacts Each contact consists of –references to the two rigid bodies –contact point in world coordinates, q (Vector) –contact normal in world coordinates, n (Vector) –penetration depth, d (real) –coefficient of restituion, c (real) –coefficient of friction, μ (real)

Collision Detection Implementation is very complicated Two phases: –Coarse Collision Detection –Fine Collision Detection

Collision Detection Use spatial data structures to perform coarse collision detection Examples of spatial data structures: –bounding volume hierarchy –binary space partitioning tree –quad-tree –oct-tree –grids Coarse collision detection eliminates pairs of objects that could not possibly be in contact

Collision Detection Run fine collision detection on the remaining pairs of objects Fine collision detection generates the list of contacts For polygon meshes, two types of contacts must be checked: –point-face contacts –edge-edge contacts