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.
  • #36
Jack7 said:
If anyone could please outline where I've gone wrong, I'd really appreciate it.
How did you match the final linear speed in pixels per time-step to the constant speed around the circle? If your rectangle advances by 10 pixels for every time-step when it's moving along a straight line, it must advance by the same number of pixels when going around the circle. For the latter calculation, the radius of the circle in pixels becomes important.
 
Physics news on Phys.org
  • #37
malawi_glenn said:
no no it does not have to be 0, it is a contraint you can play around with once you have settled for what velocity profile you want.

I would be happy with a simple linear profile if it made life easier. I think I am making a mistake between Steps 2-3 though; I suspect it is my method rather than the velocity graph itself.
 
  • #38
Jack7 said:
I would be happy with a simple linear profile if it made life easier
Thing is, if the velocity is linear in time, then acceleration is constant, and then SUVAT equations gave you negative acceleration so that the particle initially moved in the wrong direction. Thus linear velocity is not possible.
 
  • #39
kuruman said:
How did you match the final linear speed in pixels per time-step to the constant speed around the circle? If your rectangle advances by 10 pixels for every time-step when it's moving along a straight line, it must advance by the same number of pixels when going around the circle. For the latter calculation, the radius of the circle in pixels becomes important.

That's a very good question, I am doing this in the Unity Engine which handles that inside the engine. I know the movement is matched because if I send it into the circle with the specified linear velocity, I do indeed see a nice smooth transition. So this issue is not a synchronisation issue, it is a miscalculation somewhere in my method.
 
  • #40
malawi_glenn said:
Then yes, an exponential acceleration will make the last second cover 87% of the total distance (3,46 m) and not look any nice.
Which is why I recommended the cubic easing.

EDIT: Note that these workings result in an initial acceleration in the wrong direction!


We don't normally give full answers in homework forums, but I think in this case it would be appropriate. So picking up from
pbuk said:
In some contexts we call these animations easings. You can find out more about easings at https://easings.net/ (no kidding!)

A useful easing when you want to specify slope (velocity) at the beginning and end of the transition is a cubic spline defined by $$ x(t) = \alpha t^3 + \beta t^2 + \gamma t $$ (we define ## x(0) = 0 ## so there is no constant coefficent).
We differentiate this to get $$ \dot x(t) = 3 \alpha t^2 + 2 \beta t + \gamma $$ and taking ## \dot x(0) = 0 ## (the initial velocity) we see that ## \gamma = 0 ##.

  1. So we now have an equation for the total distance traveled S after time T: ## S = x(T) = T^3 \alpha + T^2 \beta+ 0 T ##,
  2. and the speed V after time T: ## V = \dot x(T) = 3 T^2 \alpha + 2 T \beta + 0 ##.
  3. Multiply the equation in step 2 through by ## T ## to get ## VT = 3 T^3 \alpha + 2 T^2 \beta ##.
  4. Subtract 2x the equation in step 1 from step 3 to get ## VT - 2S = 3 T^3 \alpha + 2 T^2 \beta - 2 T^3 \alpha - 2 T^2 \beta ##
  5. Cancel and group terms in step 4 to get ## VT - 2S = T^3 \alpha \implies \alpha = \frac{VT - 2S}{T^3}.
  6. Subtract 3x the equation in step 1 from step 3 to get ## VT - 3S = 3 T^3 \alpha + 2 T^2 \beta - 3 T^3 \alpha - 3 T^2 \beta ##
  7. Cancel and group terms in step 6 to get ## VT - 3S = - T^3 \beta \implies \beta = \frac{3S - VT}{T^3}##.
We now have our equation for position at time t:
$$ x(t) = \frac{VT - 2S}{T^3} t^3 + \frac{3S - VT}{T^3} t^2 $$
Using ## T = 4 s, S = 10 m, V = 20 m/s ## we have
$$ x(t) = \frac{20 \times 4 - 2 \times 10}{4^3} t^3 + \frac{3 \times 10 - 20 \times 4}{4^3} t^2 = \frac{15}{16} t^3 + \frac{-25}{8} t^2 $$
Note also that differentiating this we have ## \dot x(t) = \frac{45}{16} t^2 + \frac{-25}{4} t ##; you can check these give the correct values for ## S \text{ and } V \text{ at } t = 4s ##.
 
Last edited:
  • Like
Likes Jack7
  • #41
malawi_glenn said:
Thing is, if the velocity is linear in time, then acceleration is constant, and then SUVAT equations gave you negative acceleration so that the particle initially moved in the wrong direction. Thus linear velocity is not possible.
Yes precisely, I recall that's why it's necessary to use a varying acceleration. I think I'm getting closer but still some ways away from a working solution.
 
  • #42
Jack7 said:
So this issue is not a synchronisation issue, it is a miscalculation somewhere in my method.
No, I think it is probably that you are using the wrong method.
 
  • #43
##v(t) = kt^2 + v(0)##
##s(t) = kt^3 / 3 ##
Constraints ##s(4) = 10## and ##v(4) = 20## gives ##k=5/32## and ##v(0) = 12.5##
Simulation:
 
Last edited:
  • Like
Likes Jack7
  • #44
malawi_glenn said:
##v(t) = kt^2 + v(0)##
##s(t) = kt^3 / 3 ##
Constraints ##s(4) = 10## and ##v(4) = 20## gives ##k=5/32## and ##v(0) = 12.5##
That's better, cubic easing is always going to transition better to the next stage than exponential.
 
  • #45
pbuk said:
That's better, cubic easing is always going to transition better to the next stage than exponential.
I have animations for exponential and power-function too :)
If I knew the whole story, that the particle was going to move in a circle with constant angular speed, I would have suggested something else. Exponentials are easy to differentiate and integrate.
 
  • #46
pbuk said:
Which is why I recommended the cubic easing.

EDIT: Note that these workings result in an initial acceleration in the wrong direction!

I cannot thank you enough for taking the time to write all that out, seriously thanks! I have implemented your equation and it is a big improvement! I don't actually see an initial acceleration in the wrong direction as position is always positive when I feed in the V,S,T,t values.

Here is what it produces:

Screen Recording 2022-07-26 at 22.54.26.gif


It's probably hard to see given the jerky GIF, but it is more clear in the 60 FPS that I am seeing. The square does still appear to arrive the destination a little too fast, causing an apparent slowdown as it starts orbiting. Is this due to the cubic function? As I mentioned it's a lot better but still not smooth per se.
 
  • #47
malawi_glenn said:
I have animations for exponential and power-function too :)
If I knew the whole story, that the particle was going to move in a circle with constant angular speed, I would have suggested something else. Exponentials are easy to differentiate and integrate.

Sorry malawi_glenn, I was trying to break the problem up to simplify it. I feared my original post would be too long if I included all the extra details.
 
  • Like
Likes malawi_glenn
  • #48
@Jack7
Do you have correct radius and tangential speed for the circular motion?
 
  • #49
malawi_glenn said:
@Jack7
Do you have correct radius and tangential speed for the circular motion?

Yes I do, and I know for a fact that it is correct because if I send the square in with a simple linear velocity (no acceleration), the transition is perfectly smooth. So I can be certain that my angular and linear velocities are matched.
 
  • #50
Jack7 said:
Yes I do, and I know for a fact that it is correct because if I send the square in with a simple linear velocity (no acceleration), the transition is perfectly smooth. So I can be certain that my angular and linear velocities are matched.
Can you primt the horisontal velocity components for each frame?
Did you see my animation? I had 50 fps.

If you like to do animations, and solve problems graphically, I can really recommend you get Geogebra. It is free and pretty easy to use.
 
  • #51
malawi_glenn said:
Can you primt the horisontal velocity components for each frame?
Did you see my animation? I had 50 fps.

If you like to do animations, and solve problems graphically, I can really recommend you get Geogebra. It is free and pretty easy to use.
In order to print the velocity components per frame I would have to calculate the distance traveled since the last frame and divide by the elapsed time. pbuk's equation gives position so I can easily check the position per frame, and it does indeed ease into the final position over the last few frames.

I did see your animation but it confused me a little since the motion upon joining the circle seems to rapidly speed up. There is no smooth transition?

(P.S. It is quite late where I live so I may not reply until tomorrow. I honestly cannot thank you guys for helping me this much, you're all awesome! I aim to continue with this challenge tomorrow)
 
  • #52
Jack7 said:
In order to print the velocity components per frame I would have to calculate the distance traveled since the last frame and divide by the elapsed time. pbuk's equation gives position so I can easily check the position per frame, and it does indeed ease into the final position over the last few frames.

I did see your animation but it confused me a little since the motion upon joining the circle seems to rapidly speed up. There is no smooth transition?

(P.S. It is quite late where I live so I may not reply until tomorrow. I honestly cannot thank you guys for helping me this much, you're all awesome! I aim to continue with this challenge tomorrow)
To me it looks like your animation is really slowing down at the change. How does the circular motion part created? It seems like pixels are a finite size with a range of coordinates assigned to each, and the pixel/pixel group that the center of the ball is in lights up to in a time step ##dt## is the range of coordinates that contain the computation:

$$ \begin{align} x &= x_o + v \cos \theta \, dt \tag*{} \\ \quad \tag*{} \\ y &= y_o + v \sin \theta \, dt \tag*{} \end{align} $$

or is the "circular motion" achieved in some other way ( I'm completely inexperienced in animation - perhaps it shows)?

Maybe you just solve the equation explicitly for ##x## and ##y## via the following diff eqs?

$$ \begin{align} \frac{dx}{dt} &= v \sqrt{ 1 - \left( \frac x r \right)^2 } \tag*{} \\ \quad \tag*{} \\ \frac{dy}{dt} &= v \sqrt{ 1 - \left( \frac{r-y}{r} \right)^2 } \tag*{} \end{align} $$

##x## is measured from the vertical datum passing through the center of the circle, and ##y## is measured from the horizontal datum through which the particle enters the circle.
 
Last edited:
  • #53
Could I please clarify something with you guys before I continue trying to implement your recommendations? Because I still feel that my understanding is lacking, and that I need to get this point clear in my head before proceeding.

If I say: I want the particle to accelerate at a constant rate, in accordance with the specified s,v,t, I am essentially saying that the motion must follow this graph:

Graph.png


Question: Am I correct in saying this?

If so, the next question becomes whether this graph can actually be constructed. I believe the answer is no, hence we are trying to change the shape of the curve, such that the area underneath it does actually equal 10.

Is my understanding correct? Having it visualised in a graph helps tremendously since the equations are hard to derive any meaning from.
 
  • Like
Likes malawi_glenn
  • #54
Jack7 said:
If so, the next question becomes whether this graph can actually be constructed.
1658909301510.png

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.
 
  • #55
@malawi_glenn Thank you for clarifying that. What you are saying makes sense to me. My area is 40 so clearly the curve is invalid. It would reach 10m far too soon, which is what I was seeing in my first GIF. This makes sense.

Am I correct in thinking that there is only one curve (where v is always positive) that satisfies my needs? Our exercises up to now have been an attempt to find this curve. Is this correct?
 
  • #56
Jack7 said:
My area is 80
In that graph? How do you calculate the area of a triangle?

Jack7 said:
Am I correct in thinking that there is only one curve (where v is always positive) that satisfies my needs? Our exercises up to now have been an attempt to find this curve. Is this correct?
No there are "infinetly" many such curves. The excerises has been to attempt to find a curve that fulfils the constraints and is simple to calculate (e.g. you can determine the shape with a few parameters which can be calculated algebraically)
 
  • #57
Yeah, for a constant acceleration that you have shown ##v= at##, is the equation of the line. The area under the curve from ## t = 0 \rm{s} \to 4 \rm{s} ## ( which represents the distance traveled in time ## t = 0 \rm{s} \to 4 \rm{s} ## ) is already fixed at some value other than the value you are trying to make it be.
 
  • #58
malawi_glenn said:
In that graph? How do you calculate the area of a triangle?No there are "infinetly" many such curves. The excerises has been to attempt to find a curve that fulfils the constraints and is simple to calculate (e.g. you can determine the shape with a few parameters which can be calculated algebraically)

Apologies that was a typo, I meant to say the area is 40 (20 * 4 * 0.5 = 40).

I don't understand how there can be infinitely many such curves. How is this possible?

There is only one curve that gives an area of 40 (where v(4) = 20 and the area is always positive), which is what I showed. So I don't see why the same rule doesn't apply to an area of 10. Clearly I have fundamentally misunderstood something so I am glad to be clearing this up.
 
  • #59
Jack7 said:
There is only one curve that gives an area of 40
v(t) = 5t + sin(πt/2) does
1658911200593.png


All curves of the form v(t) = 5t + k*sin(m*πt/2) where k is a real number and m is an integer, will do as well (well not all, you have to make sure that the values of k and m does not make the graph have a zero between 0 and 4, but you get the idea)
 
  • Like
Likes erobz and Jack7
  • #60
Jack7 said:
If I say: I want the particle to accelerate at a constant rate, in accordance with the specified s,v,t, I am essentially saying that the motion must follow this graph:

View attachment 304858

Question: Am I correct in saying this?
Yes, the area is the distance traveled so must satisfy the constraint that S = 10 m.

Jack7 said:
If so, the next question becomes whether this graph can actually be constructed. I believe the answer is no, hence we are trying to change the shape of the curve, such that the area underneath it does actually equal 10.
Yes, if the shape is as drawn you can see that the area is a triangle with area half the base x perpendicular height = 0.5 x 4 s x 20 m/s = 40 m.

Jack7 said:
Is my understanding correct? Having it visualised in a graph helps tremendously since the equations are hard to derive any meaning from.
Yes that is correct: the graph needs to satisfy the three constraints you are interested in: starting at t = 0 s with speed = 0 m/s, ending at t = 4 s with speed = 20 m/s and having area of 10 m representing distance travelled.

You can see that in order to achieve this we need to lose a lot of area from the graph, which means that most of the acceleration has to happen at the end so it will never look great. Reducing the time would help.

Having said all of that, it looks like you are trying to model insertion of an object into a circular orbit. The equations of motion governing this are far more complicated and I don't think you have the background level of maths to tackle this without a lot of additional study.
 
  • Like
Likes Jack7
  • #61
malawi_glenn said:
v(t) = 5t + sin(πt/2) does
View attachment 304865

All curves of the form v(t) = 5t + k*sin(m*πt/2) where k is a real number and m is an integer, will do as well (well not all, you have to make sure that the values of k and m does not make the graph have a zero between 0 and 4, but you get the idea)

D'oh! Of course! You are absolutely right, thank you for showing that as it makes it a lot easier to understand with a visual aid. I can see now why there is an infinite number of possible curves.
 
  • #62
pbuk said:
Yes, the area is the distance traveled so must satisfy the constraint that S = 10 m.
...

Thanks pbuk for your comments. I am now at least confident that I understand what the equations are trying to do. As mentioned, seeing graphs helps a lot.

I appreciate your honest feedback regarding my poor maths, I fully accept that. I need to restudy calculus for sure :doh:.The equations of motion are not a problem for me, it is the calculus that I struggle with. I just need to better understand now how to construct the graph that gives me the required area.
 
  • #63
pbuk said:
Which is why I recommended the cubic easing.
To avoid any reverse movement, go to quartic.
 
  • #64
haruspex said:
To avoid any reverse movement, go to quartic.
Yes I started going down that path :wink: but the main problem is the constraints: if you want to take as long as 4 s to cover 10 m but end up at a speed of 20 m/s there is going to be a lot of acceleration at the end.
 
  • #65
Jack7 said:
I just need to better understand now how to construct the graph that gives me the required area.
... and that is where you really need the maths for the quantitive results to back up the qualitative understanding you can get from a graph. The key points to grasp are:
  • Speed is the derivative of distance with respect to time
    • This means that speed is the slope of a distance vs time graph
    • The converse of this is that position is the anti-derivative (or integral) of speed with respect to time
      • This means that distance is the area under a speed vs time graph
  • Acceleration is the derivative of speed with respect to time
    • This means that acceleration is the slope of a speed vs time graph
    • The converse of this is that speed is the anti-derivative (or integral) of acceleration with respect to time
      • This means that speed is the area under a acceleration vs time graph
 
  • Like
Likes Jack7
  • #66
It might help if you could explain what the context for this is: is it a high school project you are working on alone? or as part of a group project? a hobby project? And what is the end goal: an interesting graphic? A game? A simulation?

This would help us to point you towards approriate resources, e.g. whether you are better off with Kerbal Space Program, Howard Curtis' book or something else.
 
  • #67
pbuk said:
It might help if you could explain what the context for this is: is it a high school project you are working on alone? or as part of a group project? a hobby project? And what is the end goal: an interesting graphic? A game? A simulation?

This would help us to point you towards approriate resources, e.g. whether you are better off with Kerbal Space Program, Howard Curtis' book or something else.

Thanks pbuk, and everyone else who has been helping me in this thread. You guys are truly awesome for helping novices like me! I am sorry if I frustrate on occasion.

The context for this is that I am designing a video game as a hobby in my spare time. I have a need to shoot an object into a circular orbit within a specified 's', 'v' and 't'. I have already implemented objects moving in very nice circular paths with uniform motion, so generally I understand equations of motion. I struggle though when it comes to accelerating and decelerating things, since my calculus is lacking.

I want to do this very accurately and therefore I need to use a mathematically sound approach. So if you had any resources that would be really appreciated!
 
  • #68
Why can't you adjust the angular velocity so that you can use constant acceleration instead?
 
  • #69
malawi_glenn said:
Why can't you adjust the angular velocity so that you can use constant acceleration instead?

I can't do that for a very specific reason. In my actual game, there is already a body orbiting at an angular velocity. This new object that is shooting in needs to have half the angular velocity of that existing object, and it needs to shoot in at a very specific time, when the other body will be a certain number of degrees away.

This is why I need it to reach a very specific velocity, in a very specific time, over a very specific distance. The distance originates at the point lying just off-screen. Hopefully this clarifies why the three constraints exist.
 
  • #70
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.

Plots.png
 
  • Like
Likes SammyS, Jack7, Delta2 and 1 other person

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
536
  • Introductory Physics Homework Help
Replies
11
Views
2K
  • Introductory Physics Homework Help
Replies
17
Views
909
  • Introductory Physics Homework Help
Replies
8
Views
1K
  • Introductory Physics Homework Help
Replies
5
Views
1K
  • Precalculus Mathematics Homework Help
Replies
17
Views
1K
  • Introductory Physics Homework Help
Replies
2
Views
208
Back
Top