CS229 Programming Assignment 3: Dynamics

Similar documents
EXPERIMENT 7: ANGULAR KINEMATICS AND TORQUE (V_3)

Chapter 9. Linear Momentum and Collisions This chapter is about interaction between TWO objects

Notes Momentum. Momentum and Impulse. - The product (multiplication) of an objects mass and velocity is called momentum.

Review for 3 rd Midterm

PSE Game Physics. Session (6) Angular momentum, microcollisions, damping. Oliver Meister, Roland Wittmann

Northwestern Connecticut Community College Course Syllabus

Lab Partner(s) TA Initials (on completion) EXPERIMENT 7: ANGULAR KINEMATICS AND TORQUE

Assignment 4: Rigid Body Dynamics

PHYSICS I RESOURCE SHEET

Chapter 6. Preview. Section 1 Gravity and Motion. Section 2 Newton s Laws of Motion. Section 3 Momentum. Forces and Motion.

PHYS 154 Practice Test 3 Spring 2018

Chapter 9- Static Equilibrium

Northwestern CT Community College Course Syllabus. Course Title: CALCULUS-BASED PHYSICS I with Lab Course #: PHY 221

z F 3 = = = m 1 F 1 m 2 F 2 m 3 - Linear Momentum dp dt F net = d P net = d p 1 dt d p n dt - Conservation of Linear Momentum Δ P = 0

Lab 4: Gauss Gun Conservation of Energy

STUDY GUIDE 4: Equilibrium, Angular Kinematics, and Dynamics

Physics 1A. Lecture 1B

Chapter 8: Momentum, Impulse, & Collisions. Newton s second law in terms of momentum:

Rigid Body Dynamics and Beyond

Exam II. Spring 2004 Serway & Jewett, Chapters Fill in the bubble for the correct answer on the answer sheet. next to the number.

Physics 2A Chapter 10 - Rotational Motion Fall 2018

Physics 1A Lecture 10B

PHYSICS. Chapter 11 Lecture FOR SCIENTISTS AND ENGINEERS A STRATEGIC APPROACH 4/E RANDALL D. KNIGHT Pearson Education, Inc.

4.4 Energy in multiple dimensions, dot product

PHYSICS 111 SPRING EXAM 2: March 7, 2017; 8:15-9:45 pm

Lecture 2 - Force Analysis

A) 4.0 m/s B) 5.0 m/s C) 0 m/s D) 3.0 m/s E) 2.0 m/s. Ans: Q2.

PHYSICS 221 SPRING EXAM 2: March 30, 2017; 8:15pm 10:15pm

Conservation of Momentum. Last modified: 08/05/2018

particle p = m v F ext = d P = M d v cm dt

2007 Problem Topic Comment 1 Kinematics Position-time equation Kinematics 7 2 Kinematics Velocity-time graph Dynamics 6 3 Kinematics Average velocity

Most people said that they understand force and acceleration. GOOD!

8.012 Physics I: Classical Mechanics Fall 2008

Handling robot collisions in the state estimator module of the MI20 robotsoccer system

Problem Set 9: Momentum and Collision Theory. Nov 1 Hour One: Conservation Laws: Momentum and Collision Theory. Reading: YF

Mechanics. In the Science Program, Mechanics contributes to the following program goals described in the Exit Profile:

End-of-Chapter Exercises

Physics 351, Spring 2017, Homework #12. Due at start of class, Friday, April 14, 2017

Welcome back to Physics 211

Kinematics (special case) Dynamics gravity, tension, elastic, normal, friction. Energy: kinetic, potential gravity, spring + work (friction)

Physics 351, Spring 2018, Homework #9. Due at start of class, Friday, March 30, 2018

Unit 6: Linear Momentum

Delve AP Physics C Practice Exam #1 Multiple Choice Section

Lecture 9 - Rotational Dynamics

Physics for Scientists and Engineers 4th Edition, 2017

EXAM 3 MECHANICS 40% of the final grade

PHYSICS 221 SPRING 2014

What is the initial velocity (magnitude and direction) of the CM? Ans: v CM (0) = ( 7 /2) v 0 ; tan 1 ( 3 /2) 41 above horizontal.

Projects. Assignments. Plan. Motivational Films. Motivational Film 1/6/09. Dynamics II. Forces, Collisions and Impulse

Exam II Difficult Problems

Learning Goals The particle model for a complex object: use the center of mass! located at the center of mass

July 19 - Work and Energy 1. Name Date Partners

PHYSICS 221 Fall 2013 EXAM 2: November 6, :15pm 10:15pm. Name (printed): Recitation Instructor: Section #:

PHYSICS 221 SPRING 2015

Physics 218 Lecture 23

ME 230: Kinematics and Dynamics Spring 2014 Section AD. Final Exam Review: Rigid Body Dynamics Practice Problem

CS-184: Computer Graphics

r CM = ir im i i m i m i v i (2) P = i

Tutorial 4. Figure 1: Rod and spindle. Dog. Figure 2: I have no idea what I m doing. Dog

Gravity Pre-Lab 1. Why do you need an inclined plane to measure the effects due to gravity?

Physics 8 Monday, September 21, 2015

Rigid Body Dynamics. Professor Sanjay Sarma. October 21, 2007

Your Second Physics Simulation: A Mass on a Spring

Chapter 9. 9 Momentum. Momentum. PowerPoint Lectures for College Physics: A Strategic Approach, Second Edition Pearson Education, Inc.

Momentum and Collisions

PHYS 121: Work, Energy, Momentum, and Conservation Laws, Systems, and Center of Mass Review Sheet

Welcome back to Physics 211

SYLLABUS FORM WESTCHESTER COMMUNITY COLLEGE Valhalla, NY lo595. l. Course #: PHYSC NAME OF ORIGINATOR /REVISOR: ALENA O CONNOR

Phys 270 Final Exam. Figure 1: Question 1

Newton s First Law and IRFs

Extra Credit 1: Problems

PHYSICS 221 SPRING 2013

Extra credit assignment #4 It can be handed in up until one class before Test 4 (check your course outline). It will NOT be accepted after that.

PLANAR KINETIC EQUATIONS OF MOTION (Section 17.2)

Physics 2101, Final Exam, Spring 2007

Physics 11 (Fall 2012) Chapter 9: Momentum. Problem Solving

PHYSICS 111 SPRING EXAM 2: March 8, 2016; 8:15-9:45 pm

One Dimensional Collisions 1 Fall 2018

Chapter 9. Momentum. PowerPoint Lectures for College Physics: A Strategic Approach, Second Edition Pearson Education, Inc.

3. How long must a 100 N net force act to produce a change in momentum of 200 kg m/s? (A) 0.25 s (B) 0.50 s (C) 1.0 s (D) 2.0 s (E) 4.

Conservation of Momentum

16. Rotational Dynamics

AP PHYSICS 1 Learning Objectives Arranged Topically

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Physics Department. Physics 8.01L IAP Experiment 3: Momentum and Collisions

DO NOT TURN PAGE TO START UNTIL TOLD TO DO SO.

Lecture Outline Chapter 11. Physics, 4 th Edition James S. Walker. Copyright 2010 Pearson Education, Inc.

Physics 8 Friday, September 11, 2015

Energy problems look like this: Momentum conservation problems. Example 8-1. Momentum is a VECTOR Example 8-2

Written Homework problems. Spring (taken from Giancoli, 4 th edition)

Momentum is a property of moving matter. Momentum describes the tendency of objects to keep going in the same direction with the same speed.

Chapter 8- Rotational Motion

Physics C: Mechanics

Quantitative Skills and Advanced Calculus Topics in AP Physics C: Mechanics

t = g = 10 m/s 2 = 2 s T = 2π g

6-1. Conservation law of mechanical energy

LAB 6: WORK AND ENERGY

PHYSICS 221 Fall 2016 EXAM 2: November 02, :15pm 10:15pm. Name (printed): Recitation Instructor: Section #:

Momentum and Impulse Concept Tests

What is momentum? Inertia in Motion.

Physical Simulation. October 19, 2005

Transcription:

: Assignment Out: Wednesday, Oct. 12, 1999 Assignment Due: Fri Oct 22, 1999 (11:59 pm) 1 Introduction Physically based modeling has been an extremely active area of research in computer graphics for over a decade. Fueled by parallel research in computational physics, the field is moving towards modeling physical phenomena in a more realistic way. Physically based modeling has developed as an alternative way of modeling some forms of motion that were previously quite tedious using traditional keyframe/interpolation animation. The purpose of this assignment is to give you the chance to implement a physically-based modeling system based upon methods discussed in class and some new ones presented here. Some material may be familiar as a simplification of parts of the Baraff notes available off the home page (which describes a somewhat different design for a 3D simulation using quaternions). As before, some of you may use the skills you acquire in this assignment when the time comes to implement your final project. In this assignment, you create a 2D room in which particles and boxes both fall and bounce off of the walls. To be a bit more precise, your executable should support the following objects and interactions (we ll go through each in detail later in the handout): Falling particle masses Spring forces on objects Collision with the room for particles Free falling rigid bodies (a rectangle) Wall collision for rigid bodies We will be giving you some support code for the 2D room, written in C++ and using the poorly documented but open source GUI library GTK. We will also be giving you code to implement all but the last two features. This means less code for you to write, but, as in the last assignment, more code for you to understand. Some of the extra credit options in this assignment may warrant your editing the support code and/or potentially throwing it out the window and doing your own thing completely (in the case of a full 3D with articulated figures dynamic simulation). Note: this handout, very similar to the one used in cs224 3 or 4 years ago (when this was a miniproject), just covers the theory. I don t think it s fair to not explain the support code at all, so

I m writing a supplement (henceforth referred to as supplementary handout ). Look for a link on the web page when it s done. 2 Theory: Point Bodies 2.1 Point Bodies: Forces As you know from high school physics, force equals mass times acceleration. Given the forces acting on a body and its initial position and velocity, this fact allows you to determine the body s motion. Another fun fact about force is that it can be decomposed into its x and y components. In fact, given a force and an arbitrary direction, the force can be represented as an amount of force along the given direction and the amount of force perpendicular to it. This will become especially important when determining collisions with the boundaries of your room. 2.2 Point Bodies: Spring Forces In addition to gravity, you will allow the user to exert spring forces on any object in your system. A spring force is exerted along the axis of the spring and depends on how far the spring has been stretched from its rest length. The formula for force generated by a spring with axis d is as follows: f = k(l l rest )d Where f is a unit vector and k is a spring constant which affects the force that the spring generates. Note that if a spring is compacted to a length shorter than its rest length, it exerts a force to expand itself. In the support code, when the user clicks the mouse, the system creates a spring with a rest length of twenty pixels between the mouse and the closest particle (or object vertex). When the cursor or object moves, it changes the spring length. You can change those constants or the general method of interaction at your leisure. 2.3 Point Bodies: Particles in a Room The room consists of four immobile walls. Each wall is be represented by a unit normal and a point p on the wall. The normal points into the room. This makes it simple to check if a particle at point q (whose position is described as vector q from the origin of the world frame {0}) isinside of the room. Note that n is a unit normal. See Figure (1). If the dot product (q p) n is negative (e.g. the angle between the vectors is greater than π 2 ), then the particle is on the wrong side of the wall. 2.4 Point Bodies: Particles Colliding in a Room In this simulation, with the exception of collisions, everything which affects the motion of the particles is time dependent. Forces affect a particle over a given time step by specifying a net

00 0 11 1 00 11 p n 00 11 00 11 q Figure 1: q in the room acceleration. Acceleration is integrated with respect to time to update velocity, which is again integrated to update position. You should integrate using the Runge-Kutta routines provided by the TAs. See the supplementary handout for the lowdown on the integration routines. Collisions are computed by an entirely different process and do not involve integration at all. In your simulation, after you finish computing the state of your particles for a given time step, you should then check for collisions, compute collision responses if necessary, and redraw the scene. When a particle collides with a wall in this system, the effect is to change the particle s velocity perpendicular to the wall; we assume that the wall is immobile and does not move as a result of a collision. Since there is no friction in the system, there is no change in the particle s velocity parallel to the wall. The change in normal velocity depends on the elasticity of the particle. This varies from totally elastic collisions (like a super ball) to totally inelastic collisions (like mashed potatoes). The formula for change in velocity of a particle due to an impulse is as follows: v =( 1 e)(v n)n Where v is the current velocity vector, n is the normal to the surface, and e is a coefficient of elasticity (0 <e<1). 2.5 Point Bodies: The General Algorithm as Implemented Calculate time varying forces and update positions and velocities of all the particles in the room using Runge-Kutta integration. Then, for each particle: Check whether it is on the wrong side of any wall as outlined above. If the particle lies on the wrong side of a wall, and is moving in the wrong direction, displace it along the wall s normal so that it lies exactly on the wall (note: this is a cheap hack, but it works.)

Update the velocity according to the formula for impulses (described in the auxiliary code-specific handout). Repeat until the particle lies entirely within the room. Draw the room. 3 Theory: Rigid Bodies In the formulas given in this section, we use the following notation: P is a point to which an impulse is applied. In your program, P will either be a particle body or a vertex of a rigid body I z is the moment of inertia f P is an force applied to a point P τ is the torque (a scalar since in 2D we only rotate around one axis, a zp ) m is the mass r is the vector from the center of mass to a vertex n is a unit vector normal to a wall e is the coefficient of elasticity of the rigid body v P is the velocity of a vertex P v center is the velocity of the center of mass (and therefore equal to the linear component of the velocity) v vertex is the component of the velocity along the normal of the wall θ is the angle between the a [xy]p axis of the object and the a [xy]0 axis of the world (i.e. its x and y components are 0) ω is the angular velocity ω is the angular acceleration J is the impulse applied at a point P

3.1 Rigid Bodies: Moment of Inertia Although technically the world is made entirely of particles, they tend to stick together and form objects or rigid bodies. These differ from particles in that you can apply force to any one of the particles in a rigid body and it affects the motion of the others. Thus, in addition to translating, rigid bodies also rotate about their center of mass. Translation of rigid bodies is no different than translation of particles. You calculate acceleration from the accumulated forces and then integrate to get linear velocity and position. Rigid bodies also have a moment of inertia I, which essentially describes how the mass of the body is distributed throughout the body and affects how it rotates. In 3D, I is a tensor. In 2D, we can treat it as a scalar, denoted by I z. For a 2D rectangular rigid body we have: I z = m(x2 + y 2 ) 12 where x is the length and y the width of the body. You may have derived this result in a Physics class, or you might just recognize it as a 2D simplification of the derivation of the inertia of a block in section 5.1 of the Baraff papers. 3.2 Rigid Bodies: Angular Velocity, Angular Acceleration, Torque In addition to translational motion, you need to keep track of rotation. More precisely, rotation is the angle between the vector defining the x or y axis of the object and the x or y axis (respectively) of the world. (We say x or y because it doesn t matter which one; the angle is measuring a rotation of the rigid body about its z axis.) We ll use θ to represent this angle and ω to represent its derivative, angular velocity. So the next question is, given a force at a point P,howdoyoucalculateω and θ? Todothis, we make use of the vector, r, between P and the center of mass. P f r Figure 2: Calculating the torque τ To calculate the angular velocity ω (for 2D only): Calculate the torque: τ = r f Calculate the angular acceleration: ω = I τ z (see the translational analogue: v = m f ) Integrate the angular accleration ω to find the angular velocity ω. Integrate the angular velocity ω to find the angle θ.

3.3 Rigid Bodies: Impulses When a rigid body collides with the wall of the room, the body changes its velocity instantly. This is caused by an impulse J applied at the the point of collision (see Section 8 of the Baraff papers). Impulses are applied at a given point on the body, negating the component of the velocity of that point along a given direction. In our case, the direction will be normal to the wall with which the body collides. r P J Figure 3: An impulse J 3.3.1 Rigid Bodies: Finding the Change in Linear Velocity The velocity v of a given point has a linear and an angular component: v = v center of mass + ω r Note that the linear component of the velocity of a vertex P isthesameasthevelocityofthe body s center of mass, and the angular component of the velocity in 3D equals ω r, which has a magnitude of ωr. The impulse J is defined: So to find the change in linear velocity: J = m( v center ) v center = J m 3.4 Rigid Bodies: Finding the Change in Angular Velocity From the formulas for torque τ = r f and angular acceleration ω = τ I z,weget

ω = r f I z From this we can derive a formula for the change in angular velocity of a point P : ω t = r J t I z ω = r J I z 3.5 Rigid Bodies: Finding the Impulse To find J: The component of velocity along the vector n is where, as before, J = Jn v vertex = v n v = v center of mass + ω r We can use the previous formula for the change in velocity of a particle due to an impulse and eventually get the following: J = (1 + e)v vertex n 1 m + n 1 I z (r n) r The derivation for this is worth understanding. I am going to attempt to translate Nancy s notes on said derivation and add it to the supplementary handout. 3.6 Implementation Notes Implement your RigidBody class as a subclass of your particle class. See the notes in the support code for more details. 3.7 Extra Credit You may notice that the demo for this assignment looks kind of dumb in several respects. For one thing, all collisions are frictionless, which detracts from the realism. For another, the rigid bodies (and particles) pass through each other collisions occur only between bodies and walls. Lastly, when a rigid body stops bouncing around and comes to rest on the floor, it frequently continues

to jerk and jump as though it has little ants crawling under it. That s because only collision impulses are computed by the demo, not contact forces which arise when a body is resting quietly against a wall. So corners of the resting body keep colliding with the floor, causing the corner to jerk back, which causes another corner to collide, and so on ad infinitum. Ideally, we should distinguish between the case when the body is colliding with the wall and when it is simply resting against the wall. Computing contact forces is in general a difficult problem (see Fast Contact Force Computation for Nonpenetrating Rigid Bodies by Baraff in Siggraph 94). The problem is not as difficult if you deal just with the case when a body is resting on the floor. (The demo makes a quick pass at dealing with this case, with little success). You are invited to address any of these issues for extra credit. Additionally, you are encouraged to attempt to add articulated objects to the system. Nancy s forward dynamics handout describes all you need to know to do this in 2 dimensions. 3 dimensions wouldbeevencooler,andifyoucouldhurlaroundobjectswithjointsin3dyouwouldgetmore extra credit than you could ever want plus the adoration of your peers. I d love to see a few people tackle these extensions. 3.8 Handing in tar up your code and handin with: /cs/bin/handin -c cs229 dynamics [filename] A README and vaguely commented code would be again excellent.