Game Physics – Part I Dan Fleck Coming up: Rigid Body Dynamics.

Slides:



Advertisements
Similar presentations
AP Physics C Mechanics Review.
Advertisements

Newton’s Laws of Motion
Newton’s 3 Laws of Motion
Rigid Body Dynamics Jim Van Verth
Newton’s First Law of Motion Newton’s First Law of Motion.
By Cade and Georgia.  Newton’s laws of motion, including an understanding of force, mass and weight, acceleration and inertia applied to sport and physical.
Distance The length an object actually travels. How far you go. Scalar Displacement The change in position of an object. Length between start and finish.
Game Physics – Part II Dan Fleck. Linear Dynamics Recap  Change in position (displacement) over time is velocity  Change in velocity over time is acceleration.
. They all fall at the same rate!  Air Resistance o Force in the opposite direction of the motion of an object through air o Also called drag o Can.
CS 4730 Physical Simulation CS 4730 – Computer Game Design.
Chapter 10 Forces. Force and Net Force Force is a push or a pull on an object. Net force is the total force on an object.
Unit 1-3 Review 1. Calculate acceleration, distance, velocity & time Read position-time, velocity time graphs Define velocity, speed and acceleration.
Newton’s Laws of Motion
Chapter 18 Section 3 Collisions. Mass Mass is the amount of matter in an object The mass of an object affects how easy it is to changes its motion.
Game Physics – Part IV Moving to 3D
AMY SHANTA BABOOLAL PHYSICS PROJECT: MECHANICS. ARISTOTLE’S ARGUMENTS One of his well known arguments is: to understand change, a distinction must be.
MOTION BY MARK AND ZYAN. Section 1vocab Frame of reference – Is a system of objects that are not moving with respect to one another. Relative motion –
ESS 303 – Biomechanics Linear Kinetics. Kinetics The study of the forces that act on or influence movement Force = Mass * Acceleration: F = M * a Force.
How do forces change the motion of objects? What are some contact forces and some noncontact forces? What is the law of universal gravitation? How does.
Motion Chapter 8.1 Speed Velocity Momentum Speed Distance traveled divided by the time during which motion occurred.
Forces and the Laws of Motion
Chapter 3 – Forces and Motion
THE LANGUAGE OF PHYSICS. ACCELERATION= a a= (v f -v i )/t v f - final velocity, v i - initial velocity UNITS ARE m/s 2 CONSTANT a NEGATIVE a POSITIVE.
Equations of Motion PSC1341 Chapter 2 2 Speed and velocity Speed is the distance traveled in a certain amount of timev = d/t Average speed is determined.
Resistance of an object to a change in its motion inertia.
Unit 7: Work and Energy.
Forces & Newton’s Laws Ch. 4. Forces What is a force? –Push or pull one body exerts on another –Units = Newton (N) –Examples: List all of the forces that.
Patterns of Motion. In a moving airplane, you feel forces in many directions when the plane changes its motion. You cannot help but notice the forces.
Equations for Projectile Motion
Forces & Motion. Describe Acceleration A change in velocity – which may be: –A change in speed Starting Stopping Speeding up Slowing down –A change in.
Equilibrium Forces and Unbalanced Forces. Topic Overview A force is a push or a pull applied to an object. A net Force (F net ) is the sum of all the.
References: Wikipedia PHYSICS + VECTORS.  Why physics?  Good for every game developer to know.  Physics formulae are often vector-based  A good chance.
Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan.
Newton’s Laws of Motion. Newton’s First Law  The Law of Inertia  Inertia- the tendency of an object to resist a change in motion.  An object at rest.
1 Acceleration Is the change in speed or velocity with time for motion in a straight line so that a = ∆v/t The units are usually m/sec 2 In the equation,
Newton’s Laws of Motion Sir Isaac Newton ( )
Newton’s Laws of Motion
NOTE: This presentation was not made for public use. Please do not use this presentation without my permission and the permission of each of the authors.
Chapter 11 Angular Momentum. Angular momentum plays a key role in rotational dynamics. There is a principle of conservation of angular momentum.  In.
Hosted by Mr. Gomez Force/ Momentum NewtonGravityFriction Final Jeopardy.
Rotational Motion. 6-1 Angular Position, Velocity, & Acceleration.
Newton’s Laws AP Physics C. Basic Definitions  Inertia  property of matter that resists changes in its motion.  Mass  measurement of inertia  Force.
Dynamics!.
Equilibrium Forces and Unbalanced Forces. Topic Overview A force is a push or a pull applied to an object. A net Force (F net ) is the sum of all the.
Rigid Body Dynamics CSE169: Computer Animation
Unit 2 Momentum and Impulse An Introduction to Momentum.
Impulse & Momentum Physics 11.
Sports Mechanics Principles Forces Centre of Gravity Newton’s Laws Impulse Reaction Momentum Acceleration Linear Motion.
Today's objective I can explain what a force is, how forces are measured, and how to calculate net force.
Graphs. Topic Overview The motion of an object can be represented by two types of graphs (x, v) 1) Displacement vs. Time graphs Tells you where the object.
Forces & Motion. What is a Force? Force: push or pull Unit: Newton (N)  Kg x m/s 2 Vector: has both magnitude & direction.
Chapter 2 - Sections 3 & 4 Newton’s Laws of Motion and Momentum.
Kinematics equations for motion with constant acceleration
Impulse & Momentum Physics 11. Momentum  The product of a particle’s mass and velocity is called the momentum of the particle:  Momentum is a vector,
Describing and Measuring Motion Are you in motion right now? Motion: an object is in motion if the distance from another object is changing.
Particle Kinematics Direction of velocity vector is parallel to path Magnitude of velocity vector is distance traveled / time Inertial frame – non accelerating,
In this chapter you will:  Use Newton’s laws to solve problems.  Determine the magnitude and direction of the net force that causes a change in an object’s.
Chapter 11 Section 2 Forces and Motion What are Forces? Force - is a push or pull that causes an object to move faster or slower, stop, change direction,
Newton’s Laws. Newton’s First Law: The Law of Inertia An object at rest will stay at rest unless acted upon by a force, and an object in motion will stay.
Motion Chapter 8.1 Speed Velocity Momentum Speed  Distance traveled divided by the time during which motion occurred.
Advanced Computer Graphics Rigid Body Simulation
Chapter 10 Forces.
Newton’s Laws of Motion
The concepts of forces and motion
Forces.
Momentum Chapter 1 Section 3.
Key Terms to use in assessment
Newton’s 3 laws of motion
Reviewing Main Ideas Forces A force is a push or pull.
Forces & Motion.
Presentation transcript:

Game Physics – Part I Dan Fleck Coming up: Rigid Body Dynamics

Rigid Body Dynamics  Kinematics is the study of movement over time  Dynamics is the study of force and masses interacting to cause movement over time (aka kinematic changes).  Example:  How far a ball travels in 10 seconds at 50mph is kinematics  How far the same ball travels when hit by a bat and under the force of gravity is dynamics  Additionally for simplification we’re going to model rigid bodies – ones that do not deform (not squishy)  We can model articulated rigid bodies – multiple limbs connected with a joint Coming up: Bring on calculus

Bring on calculus  Calculus was invented by Newton (and Leibniz) to handle these problems  Newton’s Laws  1. An object at rest stays at rest and an object in uniform motion stays in the same motions unless acted upon by outside forces (conservation of inertia)  2. Force = Mass * Acceleration  3. For every action there is an equal and opposite reaction Coming up: F=ma

F=ma  r=Position, v=Velocity, a=acceleration  Velocity is equal to the change in position over time.  Acceleration is equal to the change in velocity over time. Coming up: Intuitive Understanding

Intuitive Understanding  If every second my position changes by 5m, what is my velocity?  Acceleration is the change in velocity over time. If I am traveling at 5m/s at time t=1, and 6m/s at t=2, my acceleration is 1m/s^s Coming up: Integration

Integration  Integration takes you backwards  Integrating acceleration over time gives you velocity  Intuition:  If you are acceleration at 5m/s^s, then every second you increase velocity by 5. Integrating ‘sums’ up these changes, so your velocity is  What is “C”?  At time t=0, what is velocity? C… so C is initial velocity  So, if you are accelerating at 5m/s^s, starting at 7m/s what is your velocity at time t=3 seconds? Coming up: Integration

Integration  Similarly, integrating velocity over time gives you position  Example: If you’re accelerating at a constant 5m/s^s, then:  So, given you have traveled for 5 seconds starting from point 0, where are you?  Plug in the values:  So, given initial position, initial velocity, and acceleration you can find the new position, velocity.  We will do this every frame, using values from the previous frames. Coming up: Forces

Forces  But wait… how do we find the acceleration to begin with?  Linear momentum is denoted as p which is:  To change momentum, we need a force.Newton says:  So, given a force on a point mass, we can find the acceleration and then we can find position, velocity… whew, we’re done… but….. Coming up: Finding Momentum

Finding Momentum  On a rigid body, we have mass spread over an area  We compute momentum by treating each point on the object discretely and summing them up:  Lets try to simplify this by introducing the center of mass (CM). Define CM as (where M is the total mass of the body): Coming up: Center of Mass

Center of Mass  Using this equation, multiply both sides by M and take the derivative  Aha...now we have total momentum on the right, but what is on the left?  Because M is a constant it comes out of the derivative and then we have change in position over time of the center of mass… or velocity of CM! Coming up: Acceleration of CM

Acceleration of CM  Total linear momentum can be found just using the velocity of the CM (no summation needed!)  So, finally the acceleration of the entire body can be calculated by assuming the forces are all acting on the CM and computing the acceleration of CM Coming up: Partial Summary

Partial Summary  We now know, that given an object’s acceleration we can compute it’s velocity and position by integrating:  And to determine acceleration, we can sum forces acting on the center of mass (CM) and divide by total mass  Current challenge: Integrating symbolically the find v(t) and t(t) is very hard! Remember differential equations? Coming up: Differential Equations

Differential Equations  These equations occur when the dependent variable and it’s derivative both appear in the equation. Intuitively this occurs frequently because it means the rate of change of a value depends on the value.  Example: air friction.. the faster you are going, the more force it applies to slow you down:  f = -v = ma (solve for a) but a is the derivative of v, so  Solving this analytically is best left to you and your differential equations professor Coming up: Numerical Integration of Ordinary Differential Equations (ODEs)

Numerical Integration of Ordinary Differential Equations (ODEs)  Analytically solving these is hard, but solving them numerically is much simpler. Many methods exist, but we’ll use Euler’s method.  Integration is simply summing the area under the curve, and the derivative is the slope of the curve at any point. Euler says: t=3 t=5 Integrating from t=3 to 5 is summing the y values for that section. Coming up: Euler’s Approximation

Euler’s Approximation Euler numerical integration is an approximation (src: Wikipedia) Numerically integrating velocity and position we get these equations: Coming up: Final Summary of Equations

Final Summary of Equations  Sum up the forces acting on the body at the center of mass to get current acceleration  To get new velocity and position, use your current acceleration, velocity, position and numerical integration over some small time step (h) Coming up: Now we can code!

Now we can code! ForceRegistry: stores which forces are being applied to which objects ForceGenerator: virtual (abstract) class that all Forces implement Mainloop for each entry in Registry add force to accumulator in object for each object compute acceleration using resulting total force compute new velocity using acceleration compute new position using velocity reset force accumulator to zero Coming up: ForceRegistry

ForceRegistry √ Coming up: ForceGenerator

ForceGenerator Coming up: ImpulseForceGenerator

ImpulseForceGenerator Coming up: DragForce generator Warning: This code is actually changing the acceleration, it should just update the forces and the acceleration should be computed at the end of all forces

DragForce generator  In order to slow an object down, a drag force can be applied that works in the opposite direction of velocity.  typically a simplified drag equation used in games is:  k 1 and k 2 are constants specifying the drag force, and the direction is in the opposite direction of velocity. Coming up: DragForce Generator

DragForce Generator Coming up: Mainloop – Updating Physics Quantities Add force to current forces upon the player

Mainloop – Updating Physics Quantities Coming up: What’s next? After the forces have been updated, you must then apply the forces to create acceleration and update velocity and position. Inside mainloop

What’s next?  Other forces  Spring forces – push and pull  Bungee forces – pull only  Anchored springs/bungees  Rotational forces  forces instead of moving the force can also induce rotations on the object  Collisions  Conversion from 2D to 3D Coming up: References

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:  Additional references from:   Graham Morgan’s slides (unpublished) End of presentation