Moving in a straight line with multiple constraints

In summary, a body starts at Point A and moves in a straight line to Point B, covering a distance of 10m in 4 seconds with a final velocity of 20 m/s. The initial velocity and acceleration of the body are currently unknown. The task is to write a computer program to animate this motion, but there is a struggle in finding the rate of acceleration and determining the initial velocity. The SUVAT equations do not work in this case, so a non-linear method may be needed. It is possible to solve the problem with a system of two equations, with two unknowns, but another SUVAT equation that does not involve time may be more helpful.
  • #71
kuruman said:
While playing with possible trajectory equations
That is what you would get as suggested in #21
 
Physics news on Phys.org
  • #72
malawi_glenn said:
That is what you would get as suggested in #21
Perhaps. This is more specific than than the suggestions in #21 which include an exponential and a piecewise constant acceleration.
 
  • #73
kuruman said:
Perhaps. This is more specific than than the suggestions in #21
I thought
malawi_glenn said:
or power function a(t)=k⋅tα−2,
was pretty specific?

Anyway, in terms of distance traveled the last second, it is not that much of a difference compared to exponential acceleration (90% vs. 87%)
 
  • #74
If everyone is worried about the "sharpness" of the acceleration, why not use something like:

$$ \frac{dx}{dt} = \beta \ln \left( 1 + \gamma x\right) $$

It looks like it could produce a fairly "natural" acceleration.
 
  • #75
Integrating logarithm functions :bugeye:
But, such function will not work.
 
  • #76
malawi_glenn said:
Integrating logarithm functions :bugeye:
The program I use doesn't miss a beat!
malawi_glenn said:
But, such function will not work.
This I did not check, but I wonder how you recognize so quickly that it won't be able to produce a solution?
 
  • #77
Because of its convexity/concavity
1658934628751.png

we already know that linear velocity won't work
 
  • Like
Likes erobz
  • #78
malawi_glenn said:
Because of its convexity/concavity
View attachment 304871
we already know that linear velocity won't work

Ahh! Didn't have an inkling of an idea to think about it like that.
 
  • Like
Likes malawi_glenn
  • #79
Well, how about a simple quadratic model:

$$ \frac{dv}{dt} = k - \beta v^2 $$

Surely that has to have a chance and be more "natural" form of acceleration?

If it too doesn't work, I'll give up (joking)!

I think it gives (admittedly less than simple solution):

$$ \Large v(t) = \sqrt{ \frac{k}{\beta}} \frac{\left( e^{2 \beta \sqrt{ \frac{k}{\beta} } t } - 1 \right)}{\left( 1+ e^{2 \beta \sqrt{ \frac{k}{\beta} } t } \right) } $$

EDIT:
Math has to be checked yet, I feel I'm getting some funny results on a plot.

Fixed

Playing around with the graph, it appears that it is going to fail for the same reason @malawi_glenn has pointed out! SMH...
 
Last edited:
  • Like
Likes Jack7
  • #80
Okay so I have re-read this thread multiple times and I think the advice is finally starting to sink in! Talking it through with graphs has definitely aided my understanding.

The issue with the first GIF I posted (#31) was that I was forcing the particle to follow a curve that did not satisfy the constraints, i.e. the area under the velocity curve did not satisfy the total distance.

I have been experimenting with different curves, and tried adjusting the "u" values as you guys recommended, and I am much more closely able to approximate the area. As I mentioned before, I don't actually care much what "u" is, so long as it "s", "v", and "t" are satisfied and it only moves in one direction. In fact, a deceleration to "v" is fine too and this seems to work better.

You can see below that I am able to reach "v" in the required "t" and "s" and get a nice smooth transition!

Screen Recording 2022-07-27 at 21.08.40.gif


This is fantastic. The issue is, I achieved this with a lot of manual tweaking. I now need to achieve this programatically at run-time, as the "s", "v", "t" values will change. So that's my next challenge. I will continue reflecting on your advice and hopefully get there soon. Thank you guys so much!
 
  • Like
Likes erobz
  • #81
I don't know if I helped much (If I didn't confuse you more), but I don't believe you ever stated how the circular part of the animation works? What calculations does it use to generate the pixels that will light over time? This is basically, for my own curiosity (since you say it works fine)...but I'm assuming it is some method different from what I asked in post #52 ?
 
Last edited:
  • #82
erobz said:
I don't know if I helped much (If I didn't confuse you more), but I don't believe you ever stated how the circular part of the animation works? What calculations does it use to generate the pixels that will light over time? This is basically, for my own curiosity (since you say it works fine)...but I'm assuming it is some method different from what I asked in post #52 ?

Sorry erobz, I forgot to reply to #52. You have indeed helped me so thank you. Below is the answer:

It basically works as your first explanation described. The game world is three dimensional, but as this segment is top down, the positional co-ordinates of the square are treated two dimensional (z is fixed at 0). Since the radius is fixed, the co-ordinates are as you described (x , y) = (r.cosθ, r.sinθ).

Now, the angle is swept uniformly by multiplying the angular velocity by time. This is done in accordance with the timestep of the engine, so that it is independent of framerate. So it is a very simple calculation and it is very precise.

It's also worth noting that the pink square is not treated as pixels per se, it is a rigidbody inside the game world, which let's one move it around easily with physics. The world space co-ordinates are then converted to pixel space (aka screen space) by the engine as part of its rendering process. This part is a very involved process, more details here if you are interested.
 
  • Like
Likes erobz
  • #83
malawi_glenn said:
View attachment 304860
now the only way to get that area to become 10 is if v0 is negative, because the picture you posted shows the minimal area with v0≥0

You can come up with any kind of v(t) for your problem as long as the graph is above the horisontal axis between 0 < t < 4, it has v(4) = 20, and the area is equal to 10.
Is there an easy way of determining what the v0 should be for a particular curve, such that the area actually is 10? In your case above it's not actually possible given the shape.

I am trying to solve this problem programmatically so I see there being two challenges:
  1. Constructing a curve in which area underneath can actually equal 10.
  2. Setting the v0 that actually satisfies the area.
How do I decide which one to do first? As mentioned, I cannot do this manually as the "s", "v", "t" values will be different for different orbits, so manually defining a velocity profile that works is not viable. I need a programmatic way to shape the curve with the correct v0, which works for any number of "s", "v", "t" automatically.

I'm sure you guys have probably already given the answer to this but I just haven't recognised it yet. Have I missed something?
 
  • #84
Jack7 said:
Is there an easy way of determining what the v0 should be for a particular curve, such that the area actually is 10? In your case above it's not actually possible given the shape.
Depends on the shape of the curve. But you can see that for a v0>0 you must have an even larger acceleration (slope) in the v-t diagram to make sure the final speed is 20 m/s and only covers 10 m (area)
 
  • #85
malawi_glenn said:
Depends on the shape of the curve. But you can see that for a v0>0 you must have an even larger acceleration (slope) in the v-t diagram to make sure the final speed is 20 m/s and only covers 10 m (area)
This seems a bit like a chicken and egg situation. If we want v0 to always be positive (one direction of travel), then don't the curve and v0 need to be defined together through manual iteration?

Or, here is another question:

Can I define one curve, that will satisfy any "s", "v", "t" constraints and then use it find the appropriate v0 that is always positive, given the "s", "v", "t" of a particular case.

It seems like this is what I need to do, if I am not mistaken. But I am not sure if this is possible.
 
  • #86
This should illustrate the problem with having a non-zero v0
1658995835415.png

These velocity profiles have the same final speed and the particle will cover the same distance (well, the picture here should be taken with a grain of salt, I have not actually measured their areas but it is just for illustrational purposes)
The particle with higher v0 has to experience a much larger acceleration at the end of its trajectory.
 
Last edited:
  • Like
Likes Jack7
  • #87
malawi_glenn said:
This should illustrate the problem with having a non-zero v0
View attachment 304914
These velocity profiles have the same final speed and the particle will cover the same distance.
But the particle with higher v0 has to experience a much larger acceleration at the end of its trajectory.

Thanks malawi_glenn, I understand fully what you are saying and I completely agree. The red one is preferable as it will show a smoother acceleration.

So then, let's say we do this:
  • We always set v0 = 0
  • We always set v = our linear velocity target when it joins the circle (varies case by case)
  • We always set t = our time span (varies case by case)
  • We know the area the curve must satisfy = our distance that must be covered (varies case by case)
How then can I create the correct curve that satisfies the above in an automated fashion?

I cannot do it manually as the context is a game, so the constraints change dynamically during gameplay, i.e. other squares fly in that need to satisfy other orbit speeds, which are different distances from a fixed starting point. Hence "s", "v", "t" vary in real-time. So I need to be able to construct the correct curve in an automated fashion.
 
  • #88
You could define piece-wise constant accelerations over several time-intervals.
Here is an example I made in Geogebra, by inserting 6 points and varying their position (keepin the origin and (4,20) fixed). Then use the polygon tool and displaying its area
1658997122229.png

You can adjust until you get something that looks reasonable for you. Also you can use more points to determine the shape.
In this, crude, example - we see that in the last 0.5 seconds the speed will increase from 4 to 20.
And the ratio of distance traveled is ~54%
1658997285328.png


In the last second, the speed will increase from ~2.5 to 20 m/s and the ratio of distance traveled is ~70%
1658997412519.png
 
  • Like
Likes Jack7
  • #89
I haven't read all the posts, so perhaps this has been pointed out already. If you have a displacement of ##10m## in ##4s##, then your average velocity is ##2.5m/s##. If your final velocity is ##20m/s## then, assuming constant acceleration, your initial velocity must have been negative.

That much should be clear without any equations.
 
  • #90
If it was up to me, I would sit around at A for ##3s##, then accelerate at ##20m/s^2## for the last second.
 
  • Like
Likes SammyS
  • #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!
 
  • #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

  • Introductory Physics Homework Help
Replies
8
Views
1K
  • Introductory Physics Homework Help
Replies
7
Views
2K
  • Introductory Physics Homework Help
Replies
3
Views
1K
  • Introductory Physics Homework Help
2
Replies
44
Views
443
  • Introductory Physics Homework Help
Replies
11
Views
2K
  • Introductory Physics Homework Help
Replies
17
Views
846
  • Introductory Physics Homework Help
Replies
5
Views
1K
  • Introductory Physics Homework Help
Replies
8
Views
1K
  • Precalculus Mathematics Homework Help
Replies
17
Views
995
  • Introductory Physics Homework Help
Replies
2
Views
181
Back
Top