Game Physics – Part IV Moving to 3D

Slides:



Advertisements
Similar presentations
Rigid Body Dynamics Jim Van Verth
Advertisements

1 C02,C03 – ,27,29 Advanced Robotics for Autonomous Manipulation Department of Mechanical EngineeringME 696 – Advanced Topics in Mechanical Engineering.
John C. Hart CS 318 Interactive Computer Graphics
3.3. Introduction to Real-time Physics III
Chris Hall Aerospace and Ocean Engineering
Dynamics of Rotational Motion
Chapter 10 Angular momentum Angular momentum of a particle 1. Definition Consider a particle of mass m and linear momentum at a position relative.
Chapter 11 Angular Momentum.
Chapter 11 Angular Momentum.
Game Physics – Part II Dan Fleck. Linear Dynamics Recap  Change in position (displacement) over time is velocity  Change in velocity over time is acceleration.
1Notes  Demetri Terzopoulos talk: Thursday, 4pm Dempster 310.
3D Kinematics Eric Whitman 1/24/2010. Rigid Body State: 2D p.
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.
Department of Physics and Applied Physics , F2010, Lecture 20 Physics I LECTURE 20 11/21/10.
Euler Rotation. Angular Momentum  The angular momentum J is defined in terms of the inertia tensor and angular velocity. All rotations included  The.
Ch. 2: Rigid Body Motions and Homogeneous Transforms
3D Coordinate Systems and Transformations Revision 1
3-D Geometry.
Ch. 3: Forward and Inverse Kinematics
Manipulator Dynamics Amirkabir University of Technology Computer Engineering & Information Technology Department.
Physics 106: Mechanics Lecture 05 Wenda Cao NJIT Physics Department.
Introduction to ROBOTICS
Linear Algebra Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
3D Graphics Goal: To produce 2D images of a mathematically described 3D environment Issues: –Describing the environment: Modeling (mostly later) –Computing.
More details and examples on robot arms and kinematics
CS 450: COMPUTER GRAPHICS 3D TRANSFORMATIONS SPRING 2015 DR. MICHAEL J. REALE.
Velocities and Static Force
2IV60 Computer Graphics Basic Math for CG
Computer Vision Group Prof. Daniel Cremers Autonomous Navigation for Flying Robots Lecture 3.1: 3D Geometry Jürgen Sturm Technische Universität München.
ME/ECE Professor N. J. Ferrier Forward Kinematics Professor Nicola Ferrier ME Room 2246,
1 Kinematics ( 運動學 ) Primer Jyun-Ming Chen Fall 2009.
Rotation and angular momentum
Mathematical Fundamentals
Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
February 21, 2000Robotics 1 Copyright Martin P. Aalund, Ph.D. Computational Considerations.
Graphics CSE 581 – Interactive Computer Graphics Mathematics for Computer Graphics CSE 581 – Roger Crawfis (slides developed from Korea University slides)
6.837 Linear Algebra Review Patrick Nichols Thursday, September 18, 2003.
Patrick Nichols Thursday, September 18, Linear Algebra Review.
Chapter 11 Angular Momentum. The Vector Product There are instances where the product of two vectors is another vector Earlier we saw where the product.
Game Physics – Part I Dan Fleck Coming up: Rigid Body Dynamics.
6.837 Linear Algebra Review Patrick Nichols Thursday, September 18, 2003.
Spring Rigid Body Simulation. Spring Contents Unconstrained Collision Contact Resting Contact.
6.837 Linear Algebra Review Rob Jagnow Monday, September 20, 2004.
AP Physics C: Mechanics Chapter 11
Chapter 10 Rotation.
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.
What is Kinematics. Kinematics studies the motion of bodies.
Chapter 11 Angular Momentum. Angular momentum plays a key role in rotational dynamics. There is a principle of conservation of angular momentum.  In.
Spring Rigid Body Simulation. Spring Contents Unconstrained Collision Contact Resting Contact.
Kinematics. The function of a robot is to manipulate objects in its workspace. To manipulate objects means to cause them to move in a desired way (as.
Chapter 2: Description of position and orientation Faculty of Engineering - Mechanical Engineering Department ROBOTICS Outline: Introduction. Descriptions:
CS274 Spring 01 Lecture 7 Copyright © Mark Meyer Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
Affine Geometry.
Rick Parent - CIS682 Rigid Body Dynamics simulate basic physics of an object subject to forces Keyframing can be tedious - especially to get ‘realism’
Euler Angles This means, that we can represent an orientation with 3 numbers Assuming we limit ourselves to 3 rotations without successive rotations about.
Linear Algebra Review Tuesday, September 7, 2010.
Honours Graphics 2008 Session 9. Today’s focus Physics in graphics Understanding:
1 Angular Momentum Chapter 11 © 2012, 2016 A. Dzyubenko © 2004, 2012 Brooks/Cole © 2004, 2012 Brooks/Cole Phys 221
Advanced Computer Graphics Rigid Body Simulation
CS 445 / 645 Introduction to Computer Graphics
Manipulator Dynamics 1 Instructor: Jacob Rosen
PHYS 1443 – Section 003 Lecture #18
Lecture Rigid Body Dynamics.
Rotational Kinematics
Manipulator Dynamics 2 Instructor: Jacob Rosen
Math review - scalars, vectors, and matrices
Game Programming Algorithms and Techniques
Presentation transcript:

Game Physics – Part IV Moving to 3D Dan Fleck

Moving to 3D To move into 3D we need to determine equivalent equations for our 2D quantities position velocity orientation angular velocity

Linear Kinematics This is the easy part – in 3D, the linear kinematics equations are the same, just with one extra dimension. Position vectors now are = X,Y,Z NewPositionxyz = OldPositionxyz + h*Velocityxyz NewVelocity = OldVelocity + h*AccelerationCM Onward to orientation… aka the hard part!

Orientation in 3D In 2D orientation was simply a single scalar = angle In 3D it is much more complicated In 3D there are 3 angular DoF (+3 positional DoF = 6 DoF you commonly see) So we need at least 3 numbers to represent an orientation in 3D It’s been proven that 3 numbers (minimal parameterization) mathematically sucks! Lets see why… The problem

Euler Angles Roll, Pitch, Yaw – This is what DarkGDK implements (as X,Y,Z rotations) To define a location, the angle order matters. X=20, Y=5, Z=15 if applied XYZ is different than YZX, etc… In DarkGDK you can set ZYX rotation using dbSetObjectRotationZYX

Euler Rotations Using Euler angles to interpolate changes between two orientations Suffer from Gimbal Lock If two of the axis are aligned, you lose a degree of freedom. From this configuration you can only rotate in two DoF. And discontinuities When interpolating between two orientations, discontinuous angles (“jumps”) can result

Rotation Matrix Rotation matrices represent orientations by a 3x3 Matrix. 3x3 leads to 9 DoF, but we know that reality is 3 DoF… thus we need other constraints To be a rotation matrix, A, must be special – not a reflection (not changing a left-handed coordinate system to a right-handed one) orthogonal - means A*AT = 1 These constraints mean rows are unit length (3 constraints) rows are all right angles (orthogonal) to each other (3 constraints) Total DoF = 9 – 6 = 3 

Rotation Matrices Any matrix that is special orthogonal is a rotation matrix To rotate a vector: A*V = V’ To combine rotations A*B=N rotating first by A then B is the same as just multiplying by N Not commutative! A*B ≠ B*A

Axis – Angle Representation Any vector rotation can be defined as a single rotation around an arbitrary unit vector axis In picture 2: Angle is θ, axis is unit vector n (pointing into the page) Picking a specific axis will allow rotation between any two configurations

Angular Velocity To compute the angular velocity of the a point “r”. We can treat r as rotating in 2D because it’s in a single plain. Thus, the speed of rotation is: The direction of the velocity must be perpendicular to both r and n (n is the axis pointing into the screen) What gives something perpendicular to two vectors? cross product!

Angular Velocity So in 2D the angular velocity was given by the dot product In 3D the angular velocity is given by the cross product of Note: this equation is an instantaneous equation. It assumes r is constant which is only true for an instant because the axis of rotation changes This equation shows the angular velocity (ω) differentiating a vector (r) to get the slope (or small change) in r

Angular Velocity So, to “differentiate” the orientation matrix to find the change in orientation we need to differentiate the columns of the matrix (which are the orthogonal unit vectors of the axis in the oriented frame) How? cross product of the angular velocity with every column Similarly, to figure out change in orientation (A): we can just use

Angular Velocity This will differentiate each column of the orientation matrix to get the instantaneous change in orientation Procedure Using forces and torques to compute angular velocity (ω). Apply tilde operator to get skew-symmetric matrix Compute new orientation: Note: you need to recompute every frame, because angular velocity is instantaneous (valid only once).

Angular momentum of a point In 2D this was done by a scalar from the perp-dot- product In 3D we use an axis to describe the plane of rotation. If A is the CM and B is the point on the body pB=linear momentum of the point B LAB is a vector that is the “normal” to the plane of rotation. The magnitude of LAB measures the amount of momentum perpendicular to rAB

Total Angular Momentum The derivative of momentum is the torque (just as in 2D) . Without proof (just trust me): Total angular momentum is thus:

Total Angular Momentum Substitute and pull m out  Flip order (changes sign) Use tilde operator to change cross product to multiplication Because ω is constant over the body. IA is the inertia of the body. In 3D though, the inertia IA is a matrix, thus called the inertia tensor.

Total Angular Momentum The inertia tensor though depends on r which are positions in the world space (thus they change as the body moves). Meaning IA is not a constant we can calculate once and be done! Assuming we know IA, we can solve for angular velocity ω as

The Inertia Tensor Our problem is that IA changes as the body rotates because it uses world-space vectors (r). This is because we computed it using world space vectors. We can compute it instead using vectors relative to the body. Where “bar” means body-space coordinates. The body space inertia tensor is constant, thus can be precomputed. Additionally, it’s inverse can also be precomputed.

The Inertia Tensor However, to use this equation, we still need it in “world coordinates”. We need a matrix I that acts on world-space vectors, like matrix I-bar acts on body space vectors. A similarity transform can do this. Given a rotation matrix A A transform like this can transform from one coordinate space (body) to another (world). So applying the body tensor to a vector in body-space is the same as applying the world tensor to a vector in world-space

Inertia Tensors Compute by integrating the mass over a 3D shape to get the inertia of the body. However, for any non-trivial shape this is hard. For this course you can use tables of tensors for common shapes. For a box and sphere: Box sides 2a, 2b, 2c: X = (b2 + c2) / 3 Y = (a2 + c2) / 3 Z = (a2 + b2) / 3 Sphere with radius r: X = Y = Z = 2 * r2 / 5

Putting it all together

Due to numerical errors in integration, A will drift from a correct rotation matrix.

Using the values Finally, using the simulation values update your object. Applying A as orientation is just multipling all the vertices by the A. Vertices (V) are the vertices of your object Vn = A*V0 (note: you always start with the original orientation)

Collisions Collision detection is a challenging problem we’re not going over here You still need location of collision, and velocities of the colliding objects. Given those, the magnitude of the collision impulse (J) is given as:

Re-orthogonalizing a matrix X = col1(A) Y = col2(A) Z = col3(A) X.normalize(); // magnitude to one Z = Cross(X,Y).normalize(); Y = Cross(Z,X).normalize(); // Reform matrix A = [X, Y,Z];

Summary While we have gone through a lot of information, there is still much more to creating fast, efficient, production engines. You should understand the general concepts of derivatives: position  velocity  acceleration integration: acceleration  velocity  position In 2D how Forces are used to derive linear quantities acceleration, velocity, position In 2D how Torque is used to derive angular quantities momentum, angular velocity, rotation In 3D how rotation can be represented as a matrix, and how that matrix is used

References These slides are mainly based on Chris Hecker’s articles in Game Developer’s Magazine (1997). The specific PDFs (part 1-4) are available at: http://chrishecker.com/Rigid_Body_Dynamics Additional references from: http://en.wikipedia.org/wiki/Euler_method Graham Morgan’s slides (unpublished) en.wikipedia.org/wiki/Aircraft_principal_axes http://www.gamedev.net/community/forums/topic.asp?topic_id =57001 http://www.anticz.com/images/SiteImages/gimbal.gif