Applying constant acceleration frame by frame

Click For Summary
SUMMARY

The discussion focuses on implementing a camera system in Flash with an ease in/out effect using constant acceleration. The user initially misapplies the equations of motion, leading to discrepancies in calculated distance. The correct approach involves using the formula s = ut + 1/2at^2 to account for the gradual increase in velocity over time. The solution emphasizes updating velocity before and after movement to accurately reflect the physics of motion.

PREREQUISITES
  • Understanding of basic physics concepts, particularly kinematics.
  • Familiarity with Flash programming and frame-based animation.
  • Knowledge of the equations of motion, specifically s = ut + 1/2at^2.
  • Ability to implement mathematical calculations in programming.
NEXT STEPS
  • Research the implementation of kinematic equations in Flash ActionScript.
  • Learn about frame-based animation techniques and their impact on motion.
  • Explore advanced easing functions for smoother animations.
  • Investigate real-time physics engines compatible with Flash for enhanced motion simulation.
USEFUL FOR

Flash developers, animators, and anyone interested in creating realistic motion effects in animation or game development.

CBridgman
Messages
2
Reaction score
0

Homework Statement



Hi, I am working on a camera system in flash, and am trying to implement an ease in/out effect where the camera moves between two points, with positive acceleration up to the midpoint, and then negative accelaration up to the end point.

I've had a look through the equations of motion article on wikipedia, and understand how to use the various formulas, but my understanding of how to apply acceleration is not matching what the formulas tell me, and I need to understand why in order to apply the acceleration per frame.

Homework Equations



Consider the following:

Given
u (initial velocity) = 0
v (end velocity) = ?
a (acceleration) = 2
t (time interval) = 5
s (distance) = ?

Calculate end velocity
v = u + at (where: v = ?, u = 0, a = 2, t = 5)
v = 0 + 2 * 5
v = 10

Calculate distance
s = 1/2(u + v)t
s = 1/2(0 + 10)5
s = 5 * 5
s = 25

Right, so fair enough, except that I don't understand how you can end up moving a distance of 25 (an odd number) if you're adding an even acceleration number (2) to the velocity per frame. I.e:
Frame 1. Velocity = 2, Distance = 2
Frame 2. Velocity = 4, Distance = 6
Frame 3. Velocity = 6, Distance = 12
Frame 4. Velocity = 8, Distance = 20
Frame 5. Velocity = 10, Distance = 30
(Per frame, I go: velocity = velocity + acceleration)

Since the camera is moved in discrete time intervals (for the simplicity's sake, let's say it's running at one frame per second), I must add the acceleration constant to the velocity in the manner shown above, which produces a distance value that doesn't equal what the equations are telling me.

The Attempt at a Solution



Well, after filling a few pages with calculations, I decided I'd try ask here. ;)

Could anyone please tell me where I'm going wrong?
 
Last edited:
Physics news on Phys.org
The universe doesn't operate in discrete steps :wink: For example, in frame 1, you wrote velocity = 2 and distance = 2. Well, in reality, the velocity is indeed 2, but it hasn't been 2 in the entire time between "frame 0" and frame 1. It starts out at 0 and steadily increases up to 2. So the actual distance traveled will be less than 2 - in fact, it will be 1. That's just what you get out of the equation [itex]s = \frac{1}{2}(u + v)t[/itex].

Try using the equation [itex]s = ut + \frac{1}{2}at^2[/itex], it might be more useful for you.
 
Ahaa, thanks diazona. (Slaps self for being silly, etc) It's not so much that I thought the universe operates in discrete steps, but that the formulae could be used in discrete steps, and indeed they can, if applied correctly.

So, instead of doing this:
velocity = velocity + acceleration
x = x + velocity

I'll do this:
velocity = velocity + (acceleration / 2)
x = x + veloicty
velocity = velocity + (acceleration / 2)

Since only half of the distance for the acceleration is applied over a particular time period, the velocity must be updated both before and after movement is applied.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 38 ·
2
Replies
38
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
6
Views
2K
  • · Replies 6 ·
Replies
6
Views
1K
  • · Replies 10 ·
Replies
10
Views
1K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 17 ·
Replies
17
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K