assignment 2
play

Assignment # 2 So You Want to Write a Physically Based Motion Which - PDF document

Assignment # 2 So You Want to Write a Physically Based Motion Which is something you may wish to do System since it is Assignment # 2 Assignment # 2 Assignment # 2 Write a system that will simulate a Program may be: single shot of a


  1. Assignment # 2 So You Want to Write a Physically Based Motion � Which is something you may wish to do System since it is Assignment # 2 Assignment # 2 Assignment # 2 � Write a system that will simulate a � Program may be: single shot of a billiards game. � Interactive – show the animation in window on the screen � Batch – create an app that will produce a set of input files for a renderer. Assignment # 2 Assignment # 2 � In the file, you will be given � Simplifying assumptions � Position of the balls (3 of them + cue) � All balls have the same mass � Impulse forces of striking the cue � Balls will always remain in contact with the � Given as initial momentums applied to the cue ball � Friction & Coefficient of restitution table � Other givens (suggestions) � Ignore vertical motion of balls � Size of table � The table has no pockets � 4’ x 8’ (1.298m x 2.438m) � Cushion height = 0.10m � Collisions between balls will be totally � Masses elastic � Mass of ball = 0.5kg � All momentum is conserve � Sizes � Radius of balls = 0.08m 1

  2. Assignment # 2 Assignment # 2 � Collision detection between spheres � Collision response between spheres � Find distance between the 2 centers. � Collisions between balls will be totally elastic � They collide if this distance is less than the � All momentum is conserved sum of their two radii. + = + ( m v m v ) ( m v m v ) 1 1 2 2 before 1 1 2 2 after Assignment # 2 Assignment # 2 � Collision between ball and cushion Normal is force along the line of action Assignment # 2 Assignment # 2 � Collision between ball and cushion � Cushions are immovable � Assume large mass = ( m v ) e ( m v ) 1 1 before 1 1 after � But in opposite direction 2

  3. Assignment # 2 Assignment # 2 � Inertia of a sphere � Let’s talk friction ⎡ ⎤ I 0 0 xx ⎢ ⎥ 2 = 2 I mr 0 I 0 ⎢ ⎥ body yy 5 ⎢ ⎥ ⎣ ⎦ 0 0 I zz � Simple scaling in each direction F s = u s F N =u s mg Assignment # 2 Sliding friction. � Friction results in both a linear and � Angular force causes ball to roll. rotational force � Eventually velocity of the point contacting the table equals the velocity of the center of mass. � At that point the ball stops sliding and starts rolling. � This happens when: v = r ω � Or when ∆ t = 2 v 7 µ s g Rolling friction Applying Runge-Kutta Step 1 � � When ball starts to roll, the rolling Calculate Forces, F(t), τ (t) – only friction here! � friction kicks in. Step 2 � Integrate position/rotation � � Force applied that stops the roll. s(t + ∆ t) = s(t) + v(t) ∆ t � q(t + ∆ t) = q(t) + 0.5 ( ω (t)q(t)) ∆ t /* normalize to avoid problems * / � � Same idea as sliding friction R(t + ∆ t) = quatToRot (q(t + ∆ t) ) � � r(t + ∆ t) = s(t + ∆ t) + r body R(t + ∆ t) � Different friction constant Update Momentum (integrate forces) � M(t + ∆ t) = M(t) + F(t) ∆ t F r = u r F N =u s mg � L(t + ∆ t) = L(t) + τ (t) ∆ t � 3

  4. Applying Runge-Kutta Assignment # 2 � Infile – Describes position of balls and initial � Step 2.5 forces � Collision detection / determination / response. � Step 3 � Very simple formatted text file � Just a suggestion -- can use your own format. � Calculate velocities (for next step) � v(t + ∆ t) = M(t + ∆ t)/m + impulse velocity � All values will be given in metric units. � I -1 (t + ∆ t) = R(t + ∆ t)I -1 body R(t + ∆ t) T � First 4 lines – ball positions � ω (t + ∆ t) = I -1 (t + ∆ t)L(t + ∆ t) + impulse velocity � R G B x y z � (R, G, B) is color of the ball � Go to step 1 � (x,y,z) is position of ball � 1 st ball is assumed to be the cue ball (the ball to which force is to be applied) � Questions? Assignment # 2 Assignment # 2 � Infile – Describes position of balls and � Infile – Describes position of balls and initial forces initial forces � Very simple formatted text file � Very simple formatted text file � Line 5 � Line 6 � X Y Z x y z � u s e � (X, Y, Z) = linear momentum to apply to cue � u s = friction constant � (x,y,z) = initial rotational momentum � e = Coefficient of restitution (for cushion collisions) = vector gives axis of rotation � = magnitude gives angle � Questions? Assignments � Grading � Each assignment is worth 25 points: � 5 points – for something that compiles � 15 points – for something that runs incorrectly � 25 points – for something that runs correctly � Bonus points for extras 4

  5. Bells and Whistles Reference � For 25 points � Gamasutra Article � Only consider linear motion w/friction � Will place link on Web � Euler integration � Extras (max 10 points / assignment) Add pockets (5 points) � Consider rotational motion (10 points) � Basic rotation (5 points) � Account for rotation resultant from friction (5 points) � Implement Runge-Kutta Integration � 2 nd order / midpoint (5 points) � 4 th order (5 points) Due dates Questions? � 2 nd Assignment Due � Next time: � Wednesday, January 25 th � Particle Systems. � Submission � Via mycourses � Please include documentation on � Questions? � how to run your app � How to build your app � Renderer used if batch � Platform (sun vs. Windows vs Mac) � Please include sample input file. 5

Recommend


More recommend