I want to move an object on the screen a fixed distance in a fixed tim

  • Context: Undergrad 
  • Thread starter Thread starter cubud
  • Start date Start date
  • Tags Tags
    Screen
Click For Summary

Discussion Overview

The discussion revolves around the problem of moving an object on a screen a fixed distance in a fixed time while implementing a deceleration to a smooth stop. Participants explore the physics of motion, specifically focusing on initial velocity and acceleration calculations for both acceleration and deceleration phases.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • One participant describes the need to move an object 64m over 2 seconds, starting from rest and then decelerating to a stop, prompting a discussion on how to calculate initial velocity and acceleration.
  • Another participant suggests splitting the motion into two phases: acceleration and deceleration, and provides the equation s = ut + 0.5 at² to derive the necessary acceleration for the first half of the distance.
  • A different participant shares an example of needing to calculate initial velocity given a negative acceleration, distance, and time, illustrating the desired outcome with specific values.
  • One participant rearranges the equation to solve for initial velocity and provides a calculation that results in an initial velocity of 6.5 pixels/second.
  • A later post shares a source code function that implements the discussed calculations for easing motion in programming, indicating practical application of the theoretical concepts discussed.

Areas of Agreement / Disagreement

Participants generally agree on the approach to solving the problem using physics equations, but there are variations in the specific calculations and interpretations of the motion phases. No consensus is reached on a single method, as different participants present alternative calculations and approaches.

Contextual Notes

Some assumptions about uniform acceleration and the specific conditions of motion are made, but these are not universally accepted or clarified. The discussion does not resolve all mathematical steps or potential variations in approach.

Who May Find This Useful

Programmers and individuals interested in motion physics, particularly in the context of animations or simulations, may find this discussion relevant.

cubud
Messages
29
Reaction score
0
Hi everyone.

I am a programmer and I think some basic physics will help me to achieve something I wanted to do.

I want to move an object on the screen a fixed distance in a fixed time, but rather than moving with a uniformed velocity I want it to slow down at a constant rate so that it runs to a smooth stop.

So if for example I wanted to move 64m over 2s, how would I work out what my initial velocity and acceleration should be?

I appreciate any help. In fact I don't actually need to do this any more, but because I didn't know how to achieve the requirement I now have a strong urge to know how it should be solved.
 
Physics news on Phys.org


So you want it to start from rest (u=0) accelerate for a while then decelerate to a stop 64m away from the start in time (T=2 seconds).

Ok let's assume the rate of acceleration and deceleration are the same. In that case the problem can be split in two parts.

1) Acceleration phase...

It has to cover the first 32m in 1s. The relevant equation would be

s = ut + 0.5 at2

where
s = the displacement
u = initial velocity = 0
a = acceleration
t = time

Since u=0 it simplifies to

s= 0.5 at2

or

a = 2s/t2
= 2*32/12
= 64m/s2

2) The deceleration phase is identical except "a" will need to be negative.
 


Let me see if I can clarify. At an acceleration rate of 1pixel/second^2 I would expect my object to have the following Y locations over 6 seconds.

0,1,3,6,10,15,21

What I need to do is the opposite. I wanted to understand an equation that when given the acceleration rate (-1 pixels/s^2), distance to travel (21pixels), and the total time over which to travel (6s) I end up with the initial velocity - resulting in the following

Distance = 21pixels
Time = 6 seconds
Acceleration -1pixels/second^2
= Initial velocity of 6 pixels/second

Which would give me the following positions.
21,15,10,6,3,1,0
 


In which case you need...

s = ut + 0.5 at2

rearranged to give u the initial velocity..

ut= s - 0.5at2

u = s/t - 0.5at

Edit:

gives u = 6.5 pixels/second
 
Last edited:


I will give this a try, thank you!
 


Worked great, I thought I'd share the source in case anyone else stumbles across this. It should be pretty easy to work out the calculations from it.

Code:
function TSpriteBehaviorMoveTo.GetFullyEasedOffset(
  Original: Single;
  Target: Single;
  DurationSecs: Single;
  TotalDeltaTime: Single
): Single;
var
  HalfDistance: Single;
  HalfTime: Single;
  Acceleration: Single;
  CurrentTime: Single;
begin
  HalfTime := DurationSecs / 2;
  HalfDistance := (Target - Original) / 2;
  Acceleration := HalfDistance / ((HalfTime * HalfTime) * 0.5);

  if (TotalDeltaTime <= HalfTime) then
  begin
    CurrentTime:= TotalDeltaTime;
    Result := Original + (0.5 * acceleration * CurrentTime * CurrentTime);
  end else
  begin
    CurrentTime:= DurationSecs - TotalDeltaTime;
    Result := Target - (0.5 * acceleration * CurrentTime * CurrentTime);
  end;
end;
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 39 ·
2
Replies
39
Views
5K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 16 ·
Replies
16
Views
4K
  • · Replies 17 ·
Replies
17
Views
4K