More on Particles Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, March 24, 2004.

Slides:



Advertisements
Similar presentations
Section 2: Newton’s Law of Gravitation
Advertisements

Formal Computational Skills
Real-Time Game Physics
Review: Newton’s 1 st & 2 nd Laws 1 st law (Galileo’s principle of inertia)- no force is needed to keep an object moving with constant velocity 2 nd law.
Chapter 9: Impulse, Momentum, and Collisions  Up to now we have considered forces which have a constant value (except the spring) throughout the motion.
Linear Momentum and Collisions
1 Computer Graphics Physical simulation for animation Case study: The jello cube The Jello Cube Mass-Spring System Collision Detection Integrators.
Ordinary Differential Equations
Week 14 - Monday.  What did we talk about last time?  Bounding volume/bounding volume intersections.
1Notes  Textbook: matchmove 6.7.2, B.9. 2 Match Move  For combining CG effects with real footage, need to match synthetic camera to real camera: “matchmove”
MAT 594CM S10Fundamentals of Spatial ComputingAngus Forbes Week 2 : Dynamics & Numerical Methods Goal : To write a simple physics simulation Topics: Intro.
Particle Systems 1 Adapted from: E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012.
Computational Biology, Part 17 Biochemical Kinetics I Robert F. Murphy Copyright  1996, All rights reserved.
UNC Chapel Hill S. Redon - M. C. Lin Rigid body dynamics II Solving the dynamics problems.
1cs426-winter-2008 Notes  Course project: Will be due at the end of the term You can do it in pairs Create an animation that combines an algorithm for.
Department of Physics and Applied Physics , F2010, Lecture 19 Physics I LECTURE 19 11/17/10.
1cs533d-term Notes  Typo in test.rib --- fixed on the web now (PointsPolygon --> PointsPolygons)
Physics 1901 (Advanced) A/Prof Geraint F. Lewis Rm 557, A29
Linear Momentum Lecturer: Professor Stephen T. Thornton
AP Physics Impulse and Momentum. Which do you think has more momentum?
Law of Conservation of Momentum. If the resultant external force on a system is zero, then the vector sum of the momentums of the objects will remain.
Particle Systems Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University.
Department of Physics and Applied Physics , F2010, Lecture 16 Physics I LECTURE 16 11/03/10.
Physics 151: Principles of Physics: Mechanics & Heat (Honors) Prof. Stan Zygmunt Neils
Gravity, Projectiles, and Satellites Physics Click HERE if the web page above does not open. In this lesson, we will discuss the following: Newton’s Law.
Linear Momentum and Collisions
CS 4730 Physical Simulation CS 4730 – Computer Game Design.
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Physically Based Animation.
Erin Catto Blizzard Entertainment Numerical Integration.
Momentum, Impulse, And Collisions
Force and Momentum Chapter 1. Reminders from GCSE Momentum is a measure of how easy or difficult it is to change the motion of a body –The greater the.
Computational Biology, Part 15 Biochemical Kinetics I Robert F. Murphy Copyright  1996, 1999, 2000, All rights reserved.
Shadows via Projection Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, November 5, 2003.
Mechanics Topic 2.3 Work, Energy and Power. Work A simple definition of work is the force multiplied by the distance moved However this does not take.
Linear Momentum The linear momentum p of an object of mass m with a velocity of v is It is a vector and points in the same direction as the velocity.
Equation of Motion for a Particle Sect nd Law (time independent mass): F = (dp/dt) = [d(mv)/dt] = m(dv/dt) = ma = m(d 2 r/dt 2 ) = m r (1) A 2.
Chapter 7 Linear Momentum. MFMcGraw-PHY 1401Chap07b- Linear Momentum: Revised 6/28/ Linear Momentum Definition of Momentum Impulse Conservation.
Lecture Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions.
Maths & Technologies for Games Linear Dynamics Particle Based Physics CO3303 Week
Introduction to Procedural Methods, Particles Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, March.
Potential Energy ~March 1, 2006.
Energy. Analyzing the motion of an object can often get to be very complicated and tedious – requiring detailed knowledge of the path, frictional forces,
Intro. to Advanced Lighting, Basic Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, April.
More on Environment Mapping Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, December 10, 2003.
Wednesday, Nov. 19, 2003PHYS , Fall 2003 Dr. Jaehoon Yu 1 PHYS 1443 – Section 003 Lecture #21 Wednesday, Nov. 19, 2003 Dr. Mystery Lecturer 1.Fluid.
University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell Particle Systems.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Physics for Games Spring 2012.
Introduction to Particle Simulations Daniel Playne.
More on GLUT Programming Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, September 15, 2003.
Linear Momentum. Units of Momentum Momentum and Its Relation to Force Conservation of Momentum Collisions and Impulse Conservation of Energy and Momentum.
Let’s Bounce! or Physics of Collisions Part 1 Games Fundamentals © by Jarek Francik Kingston University, London
Linear Momentum The linear momentum p of an object of mass m with a velocity of v is It is a vector and points in the same direction as the velocity.
Ch 8 : Conservation of Linear Momentum 1.Linear momentum and conservation 2.Kinetic Energy 3.Collision 1 dim inelastic and elastic nut for 2 dim only inellastic.
Particle Systems. Applications Particle systems are broadly defined for: Explosion Cloth Fluid And more… It is integrated into many animation software,
Particles and their home in Geometry Shaders Paul Taylor 2010.
Game Technology Animation V Generate motion of objects using numerical simulation methods Physically Based Animation.
ICNS 132 : Linear Momentum, Impulse and Collision Weerachai Siripunvaraporn Department of Physics, Faculty of Science Mahidol University &msn :
Linear Momentum and Collisions
Spring 2002 Lecture #18 Dr. Jaehoon Yu 1.Simple Harmonic Motion 2.Energy of the Simple Harmonic Oscillator 3.The Pendulum Today’s Homework Assignment.
© 2005 Pearson Prentice Hall This work is protected by United States copyright laws and is provided solely for the use of instructors in teaching their.
Sect. 9.2: Impulse & Momentum
Lecture 7 Chapter 9 Systems of Particles Wednesday Warm-up problem Puzzle Question: Cite two possible reasons why it appears that some basket ball.
Conservation of Momentum. The Equation What Causes a Change Momentum?
Particle Systems Ed Angel Professor Emeritus of Computer Science
Momentum Conservation: Review
Motion in Real and Virtual Worlds
Particle Systems Ed Angel
Conservation Laws Conservation of Momentum I
GPAT – Chapter 7 Physics.
Presentation transcript:

More on Particles Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, March 24, 2004

24 Mar 2004CS 481/6812 Procedural Methods: Introduction [1/2] We have considered various ways to represent a scene and objects within a scene. Sometimes objects are complex enough (in appearance or behavior) that we think primarily about the algorithm that generates the object, rather than any static representation. Such algorithms are generally known as procedural methods. Perlin’s noise-based texture generation technique (from CS 381, fall 2003) is a good example of a procedural method.

24 Mar 2004CS 481/6813 Review: Procedural Methods We will consider two main categories of procedural methods: Particle systems Independently moving particles, obeying some set of laws. Used for: Smoke. Sparks (from welding or whatever). Explosions (not too different from sparks). Semi-rigid solids (particles connected by stiff springs). Cloth (particles connected by things that act like fibers). Crowd scenes (each particle is a person). Flocks of birds & schools of fish. Etc. Fractals Definitions later … Used for: Clouds. Terrain. Tree bark. Pretty pictures.

24 Mar 2004CS 481/6814 Review: Particles [1/4] A particle is an object that has a time-dependent position. That’s essentially all it has. So it can be somewhere, and it can move. In CG, particles are used in many types of modeling. Particles may interact with each other in complex ways. We can render a particle however we want. Particles are most interesting when they form groups in which each particle moves (somewhat) independently. This is called a particle system.

24 Mar 2004CS 481/6815 Review: Particles [2/4] Code for a particle, with no force acting on it, might look like this: Global: Particle p; In the idle function: static double previous_time = get_the_time(); double current_time = get_the_time(); double elapsed_time = current_time – previous_time; p.position += p.velocity * elapsed_time; glutPostRedisplay(); previous_time = current_time; In the display function: render(p);

24 Mar 2004CS 481/6816 Review: Particles [3/4] Suppose the force on a particle is small. Then its velocity will not change much between two frames. And we can approximate its changing velocity by its current velocity. vec force = compute_force(p.position); p.position += p.velocity * elapsed_time; p.velocity += force / p.mass * elapsed_time; This is based on a simple method for solving differential equations, called Euler’s Method. This method has two problems: Accuracy The velocity is not constant, after all. Stability Small initial errors in position can quickly turn into large errors.

24 Mar 2004CS 481/6817 Review: Particles [4/4] We can do better if, instead of using the current velocity of the particle to update its position, we use the average of its current velocity and its next velocity. Except we do not necessarily know what the latter is.  So, we approximate it, the same way we have been: vec force = compute_force(p.position); vec next_velocity = p.velocity + force / p.mass * elapsed_time; p.position += (p.velocity + next_velocity) / 2. * elapsed_time; p.velocity = next_velocity; This is based on a method for solving differential equations, called the Order 2 Runge-Kutta Method. It has both better accuracy and stability. When the acceleration is constant (e.g., gravity), it is exactly right. I mean mathematically, of course. Floating-point computations are always wrong. When the acceleration is not constant, we should do better than the above code.

24 Mar 2004CS 481/6818 Particles — Better Solutions: Varying Acceleration Our use of the 2 nd -order Runge-Kutta method was for constant acceleration (like human-scale gravity). For changing acceleration, we can use the same trick we used on the position to compute the velocity. What We Did Instead of updating the position using only the current velocity, use the average of the current and next velocities. Except we do not know the next velocity, so approximate it using what we know now. What We Can Do Instead of updating the velocity using only the current acceleration, use the average of the current and next accelerations. Except we do not know the next acceleration, so approximate it using what we know now. Next, some code.

24 Mar 2004CS 481/6819 Particles — Better Solutions: Some Code I handle acceleration a bit differently. Assume we have a function that computes the acceleration on a particle, given its state (position, velocity, mass). This allows for acceleration that depends on velocity, as would happen with air resistance, for example. vec current_accel = compute_accel(p.position, p.velocity, p.mass); pos next_position_guess = p.position + p.velocity * elapsed_time; vec next_velocity_guess = p.velocity + current_accel * elapsed_time; vec next_accel_guess = compute_accel(next_position_guess, next_velocity_guess, p.mass); p.position += (p.velocity + next_velocity_guess)/2. * elapsed_time; p.velocity += (current_accel + next_accel_guess)/2. * elapsed_time; Notes This is the full implementation of the 2 nd -order Runge-Kutta method for a moving particle. (With constant mass! Under what circumstances would the mass be nonconstant?). We update p.velocity after using its value. This matters! We could just pass a Particle to compute_accel. However, this would make it trickier to compute next_accel_guess. (How would you do this using OO design?)

24 Mar 2004CS 481/68110 Particles — Better Solutions: Notes on Error Numerical solution techniques always have some error. The error is usually proportional to a power of the step size (here, elapsed_time ). Step sizes are usually small, so higher powers mean better accuracy. E.g., for step size h, Euler’s Method has error O(h 2 ), while the 2 nd -order R- K method has error O(h 3 ). Thus, for better solution methods, using a smaller step size can greatly improve the results. (How can this be done?) The error is also usually proportion to some higher-order derivative of the state variables. So accuracy is reduced in places where the force changes rapidly. E.g., in planetary motion simulation, accuracy is lower near the sun. Error can be reduced using better techniques (as we have done). However, these techniques generally take more time. E.g., in the full version of 2 nd -order R-K, we call compute_accel twice. Reducing the step size also slows things down, of course. Time-accuracy trade-offs like this are very common in computing. Of course, we need to consider this is the light of the time taken to render a frame, which is often much greater than computation time.

24 Mar 2004CS 481/68111 Particles — Implementation: Example Program We looked at particles.cpp, which is on the web page.

24 Mar 2004CS 481/68112 Particles — Collisions: Introduction The rules for particle behavior that we have been discussing are known as soft constraints. A constraint is soft if it does not need to be satisfied exactly. Other rules, like “particles cannot pass through each other”, are generally considered to be hard constraints. A small error in satisfying such a constraint is unacceptable. Now, consider a particle bouncing off something (a wall, another particle). This involves both hard constraints and rapid changes in force. Thus, the simulation methods we have discussed are often inappropriate for handling collisions.

24 Mar 2004CS 481/68113 Particles — Collisions: Detection & Handling When we deal with collisions, there are two problems: Is there a collision? We discussed this briefly last semester. We will not say much about it now. This is generally the more computationally intensive part of dealing with collisions. How to handle the collision, if there is one. First find out where the collision occurred. Then alter positions and velocities accordingly.

24 Mar 2004CS 481/68114 Particles — Collisions: Elastic vs. Inelastic An elastic collision is one in which no energy is lost. Think of hard rubber objects bouncing. In an elastic collision with a fixed object, the moving object will rebound with the same speed. In an inelastic collision, energy is lost. Think of squishy objects colliding. In practice, kinetic energy is converted to heat. We look at elastic collisions now.

24 Mar 2004CS 481/68115 Particles — Collisions: Object & Wall The most common sort of collision to model is elastic collision of a moving object with a fixed object, often a plane (a wall?). Think “bouncing ball”. Where does the collision occur? Assume constant-velocity motion (?) Lirp to find intersection. How to handle the collision. At the point of collision, the velocity vector of the moving object changes. Its component in the direction of the normal to the wall is reversed. p.velocity -= 2.*p.velocity.component(wall_normal);