Moving in a straight line with multiple constraints

Click For Summary
The discussion revolves around solving a motion problem where a body moves from Point A to Point B over 10 meters in 4 seconds, ending with a velocity of 20 m/s. The challenge lies in determining the initial velocity and acceleration, as the user initially assumed the body starts from rest, leading to incorrect calculations. It is clarified that if the initial velocity is not zero, the SUVAT equations can be applied effectively to find both initial velocity and acceleration. The conversation also explores the possibility of using non-linear acceleration to achieve the desired motion profile, emphasizing the need for a clear approach to define the acceleration function. Ultimately, the user seeks practical steps to implement these concepts in a computer program for animation.
  • #91
malawi_glenn said:
You could define piece-wise constant accelerations over several time-intervals.
...
Ahh! I see! Thank you so much for explaining it like that, that makes a lot of sense!

So it sounds like I need to write a custom function. This function needs to:
  • Fix the "v0" and "t0" values to zero
  • Fix the "v" and "t" values to the relevant constraints
  • Use some sort of loop to iteratively add in additional points until the area = "s" (± some small error)
That gives me a clear route forward.

The key challenge I foresee with doing this automated is keeping the shape of the curve smooth. As you point out, it should avoid sharp rises as much as possible, so it will need to stagger the slope as much as possible. This requires the function to have a method of assessing the shape as points are added, and factoring that into the construction process. It sounds like this will be a challenge! But it does give me a clear route forward which helps tremendously. (I suspect there are algorithms that are already capable of doing this, so I will look into that).

Thank you so much!
 
Physics news on Phys.org
  • #92
Jack7 said:
The key challenge I foresee with doing this automated is keeping the shape of the curve smooth
Since the particle has to cover most of its distance in the end of its trajectory, i would not worry too much about the smoothness. You are dealing with pixels, even if you had a continuous velocity function to start with, it will become discretized anyway in your program.
 
  • #93
malawi_glenn said:
Since the particle has to cover most of its distance in the end of its trajectory, i would not worry too much about the smoothness. You are dealing with pixels, even if you had a continuous velocity function to start with, it will become discretized anyway in your program.

Okay thanks, that's very true. I could start by just adding one point and shifting it around until the approximation is good enough. The shape will be very crude but the effect might be satisfactory. I'll give it a go and post some results soon. Thanks again!
 
  • #94
Reading through all this I wonder if the first post had all the information given in this challenge? What was the exact statement of the problem?
 
  • #95
bob012345 said:
Reading through all this I wonder if the first post had all the information given in this challenge? What was the exact statement of the problem?
I think it was determined that it wasn't a homework problem, but instead just a hobbyist game designer question about some unexpected results. @Jack7 mentioned about being succinct to decrease the length of the initial post.
 
  • Like
Likes bob012345
  • #96
kuruman said:
While playing with possible trajectory equations, it occurred to me that one could exploit the fact the factors of 2 are prominent. Ignoring units, the final speed is twice the distance and the time is 22. There is a single power of ##t## that will do the trick here:$$x(t)=\frac{5}{2^{15}}t^8~\implies v(t)=\frac{8\times 5}{2^{15}}t^7.$$With this,$$x(2^2)=\frac{5}{2^{15}}2^{16}=10~;~~v(2^2)=\frac{8\times5}{2^{15}}2^{14}=20.$$Note the effect of the many vanishing derivatives at small values of time.

View attachment 304870
This can be nicely generalized.

Assume the acceleration is of the form ##a(t) = a_0 t^{\alpha}## with ##a_0, \alpha## constants. Assuming initial values are zero and given independent final values for ##x_f##, ##v_f## and ##t_f## we can solve for ##a_0## and ##\alpha##.

$$v(t) = \int_0^t a(t)dt = \frac {a_0}{\alpha+1} t^{(\alpha+1)}$$ and
$$x(t)= \int_0^t v(t)dt = \frac {a_0}{(\alpha+1)(\alpha + 2)} t^{(\alpha+2)}$$

solving for ##\alpha## and ##a_0## we get;

$$\alpha = \frac{t_f v_f}{x_f} - 2$$ and

$$a_0 = \frac{v_f (\alpha+1)}{t_f^{\alpha+1}}$$

We do require ##\alpha ≥0## as the case ##\alpha=0## is constant acceleration and it diverges for ##\alpha<0##.

We end up with;

$$a(t) = a_0 t^{\alpha} = \frac{v_f (\alpha + 1)}{t_f} \left(\frac{t}{t_f}\right)^{\alpha}$$

$$v(t) = v_f \left(\frac{t}{t_f} \right)^{\alpha+1}$$ and

$$x(t) = x_f \left(\frac{t}{t_f} \right)^{\alpha+2}$$
 
  • Like
Likes Jack7 and erobz
  • #97
I have been experimenting with curves as per malawi_glenn's recommendation and I managed to get some very nice results even with crude curves.

I also implemented bob's solution above and it works even better, because there is no curve shaping required. It literally just uses two equations and the results are equally as good, with just two lines of code!

So you guys have solved my problem, seriously I cannot thank you enough. :bow:

Most importantly I think I actually learned quite a bit by discussing this with you all. I will continue visiting these forums to learn more and improve my knowledge.
 
  • Like
Likes bob012345 and erobz
  • #98
looking forward to play your game! We can have a small release party here :partytime:
 
  • Like
Likes bob012345, erobz and Jack7
  • #99
Jack7 said:
So to summarise:
  • A body starts at Point A
  • It moves in a straight line to Point B, covering a distance of 10m
  • The time taken to travel this distance is 4 seconds
  • When it reaches Point B, it has a velocity of 20 m/s
I realize that there have been many replies to this thread.

It is possible to meet the above requirements using two (uniform) accelerations as @haruspex states below. The two accelerations are not very difficult to determine. Not only that, but this can be accomplished using an initial velocity of zero.
haruspex said:
Suppose a low acceleration a1 for time t and a greater acceleration a2 for the rest. That's three unknowns, which is one too many for the given constraints, so you can in principle pick a value for anyone and solve for the other two. But for some choices you will still end up getting illegal moves, so you will have to play about with your choice until it gives a valid solution.

Our object will accelerate uniformly (acceleration of ##a_1##) from 0 velocity to a velocity of ##v_1## over a time interval from 0 to ##t_1##.

It then accelerates uniformly (acceleration of ##a_2##) from a velocity of ##v_1## at time ##t_1## to a velocity of ##v_2## at time ##t_2## . For the given problem, ##v_2 = 20\text{ m/s }## and ##t_2=4\text{ seconds .}##

Consider the following velocity - time graph .

1659127197797.png


Now, following our requirements, the area under this graph needs to be ##10\text{ m . }##

A convenient way to find this area is to sum the area of triangle ABD, which is ##\frac 1 2 t_2 v_1 = \frac 1 2 4 v_1##, plus the area of triangle BCD, which is ##\frac 1 2 (v_2-v_1) (t_2-t_1) = \frac 1 2 (20-v_1) (4-t_1)## .

Setting this sum to be equal to 10 (meters) gives the following for ##v_1## as a function of ##t_1##.

##\displaystyle \quad \quad \quad v_1=5(t_1-3)##

For example, if ##t_1=3.5 \text{ (s),} ## then ##v_1=2.5\text{ (m/s) .}## This gives a slope of 5/7 m/s2 for ##a_1##. Although, this time interval is 7/8 of the overall 4 seconds of acceleration, our object covers a distance of only ##4 \frac3 8 ## meters (4.375) of the total of 10 meters.
For ##a_2## we have 35 m/s2 , due to accelerating from 2.5 to 20 m/s in half a second.
 
Last edited:

Similar threads

Replies
24
Views
2K
Replies
7
Views
2K
  • · Replies 6 ·
Replies
6
Views
262
Replies
8
Views
2K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 11 ·
Replies
11
Views
2K
Replies
7
Views
2K
  • · Replies 6 ·
Replies
6
Views
1K
  • · Replies 1 ·
Replies
1
Views
7K