Motion of Objects in 2D and 3D - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Motion of Objects in 2D and 3D

Description:

Speed is a scalar measuring rate of change in distance. ... GASP! Motion in 1, 2 and 3 Dimensions. 1D = displacement along a line ... – PowerPoint PPT presentation

Number of Views:46
Avg rating:3.0/5.0
Slides: 19
Provided by: kath380
Category:
Tags: gasp | motion | objects

less

Transcript and Presenter's Notes

Title: Motion of Objects in 2D and 3D


1
Motion of Objectsin 2D and 3D
  • Topics in Computer Science
  • Math Physics of Games
  • Fall 2009

Some elements of this presentation are from
Stahlerr, some from Wikipedia, and some others
from MSDN
2
Some Vocabulary
  • Speed is a scalar measuring rate of change in
    distance.
  • Velocity is a vector measuring both speed and
    direction.
  • Displacement is the distance traveled in a
    certain direction.
  • Acceleration is the rate of change in velocity.
  • Deceleration is a negative acceleration.

3
Displacement
  • Distance
  • D RxT
  • Distance equals rate times time.
  • Displacement
  • D vt
  • Displacement equals velocity times time.
  • Which is measured in the following games
  • Pole Position
  • GTA
  • Super Mario

4
Displacement in XNA
  • Displacement with constant velocity
  • Consider a game vehicle with constant velocity of
    150 px/s
  • How far has the vehicle moved after 1 sec, 2
    sec, 3 sec, etc.
  • D vt
  • Displacements 150 px, 300 px, 450 px
  • Some questions
  • How do you represent this on screen?
  • What moves? Vehicle or background?
  • How far in each gameTime in XNA (60 cycles per
    sec) ?
  • 150 px/sec / 60 sec 2.5 px
  • What are the ramifications of 2.5 px per gameTime?

5
Average Velocity
  • Calculate the difference in the displacement over
    time.
  • Find the initial x-coordinate and subtract it
    from the final x-coordinate
  • Divide by the time elapsed.
  • V ?x xf xi t t
  • Example
  • Find average velocity in miles per hour
  • ?x ¼ mile time 15 seconds
  • V ¼ mi./ 15sec 0.25 /15 0.0167 mi/s
  • Convert to mph
  • 0.0167 mi/s 60 s/min 60 min/hr 60 mph

6
Average Velocity Between Frames
  • Suppose you set up the velocity of a UFO object
    to be
  • ufo.position new Vector2(2.0f, 0.0f)
  • What is the average velocity between two frames?
  • ?x 2 px time 1/60 seconds
  • V 2px/1/60 120 px per sec.
  • Some questions
  • Do you want your object to traverse 120 pixels
    each second?
  • How long before it is off the screen?
  • Would this simple calculation save you some time
    experimenting with velocities?
  • If you were the designer, could you make this
    calculation without programming?

7
Acceleration
  • Acceleration rate of change of velocity
  • May be constant, may vary.
  • To calculate the acceleration, we are interested
    in the velocity as compared to time.
  • a ? v vf vi ? t tf ti
  • Example UFO travelling 1500 mph. After 5
    seconds, 3200 mph. What is the acceleration?
  • A 3200 1500 340 mph. 5

8
Deceleration
  • 2006 Bugatti Veyron 16.4 is clocked at 0 to 60 in
    2.65 s
  • I was not so interested in a car that could go
    from 0 to 60 in 2.65 seconds, as one that
    could go from 60 to 30 in 0 seconds.
  • Deceleration is negative acceleration.
  • i.e. initial velocity is greater than the final
    velocity.

9
Equations of Motion
  • Final Velocity initial velocity acceleration
    time
  • vf vi at
  • Average velocity (initial velocity final
    velocity) / 2
  • v (vi vf ) / 2
  • Displacement ½ (initial velocity final
    velocity) time
  • ?x ½ (vi vf )t
  • Displacement initial velocity time ½
    acceleration time2
  • ?x vit ½ at2
  • Final velocity initial velocity2
    2accelerationdisplacement
  • vf2 vi2 2a?x

10
Gravity
  • Acceleration due to gravity is 32 f/s2 or 9.8
    m/s2
  • Drop a rock 50 m. How long till it hits the
    ground?
  • vi 0
  • vf we want
  • a 9.8m/s2
  • ?x -50m
  • Which equation helps us here?

11
Gravity
  • Acceleration due to gravity is 32 f/s2 or 9.8
    m/s2
  • Drop a rock 50 m. How long till it hits the
    ground?
  • vi 0
  • vf we want
  • a 9.8m/s2
  • ?x 50m
  • Which equation helps us here?
  • 4 has all the elements in it. We can rearrange
    it to find time.
  • ?x vit ½ at2
  • 50 m 0t ½(9.8m/s2)t2
  • 50 4.9t2
  • t2 50/4.9 10.20s2
  • t 3.19s

12
BREAK! GASP!
13
Motion in 1, 2 and 3 Dimensions
  • 1D displacement along a line
  • 2D displacement across a plane
  • 3D displacement through space

14
Displacement in 2D
  • ?r rf ri for position vectors ri (initial)
    and rf (final).
  • Object moves from point P (50, 400) to P
    (550, 100)
  • Express as vectors
  • P 50 400
  • P 550 100
  • Solve geometrically
  • Draw both vectors from the origin. Draw P P
  • Solve algebraically
  • Subtract the two vectors P P to find resultant
    vector ?r
  • P P 550 100 - 50 400 500 -300
  • Displacement is 500 pixels left and 300 pixels
    down
  • Similarly in 3D

15
Average Velocity in 3D
  • Object moves from P(150, 0, 250) to P(400, 250,
    -300) in 5 seconds.
  • Calculate displacement
  • PP 150 0 250 400 250 -300 -250 -250
    550
  • Calculate average velocity
  • V ?r -250 -250 550 50 50 -110 t
    5

16
Equation of Motion for 2D 3D
  • For vectors a, vi, vf, and ?r and scalar t
  • Final Velocity initial velocity acceleration
    time
  • vf vi at
  • Displacement ½ (initial velocity final
    velocity) time
  • ?r ½ (vi vf )t
  • Displacement initial velocity time ½
    acceleration time2
  • ?r vit ½ at2

17
Projectiles
  • Objects set in motion affected by gravity move in
    parabolic path due to the acceleration due to
    gravity.
  • a vt ½ gt2
  • NOTE Horizontal motion is independent of
    Vertical motion.
  • So we calculate the coordinates separately
  • Objects set in motion at a given angle
  • Initial velocity (d cos ? , d sin ? )
  • Acceleration and air friction due to gravity
    affects vertical vectors
  • Air friction affects horizontal vectors

18
Independent Study
  • Work through examples of projectile motion in
    Chapter 10, pp.296-310
  • Some questions to ask yourself repeatedly
  • Where did equation come from?
  • Are we looking at horizontal or vertical motion?
Write a Comment
User Comments (0)
About PowerShow.com