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.
  • #31
Honestly guys I think I've hit a brick wall. I struggle to make sense of the equations above since they are too abstract, it's been too long since I did any proper maths! I have however tried to find a solution based on my understanding (or lack thereof!) of the above recommendations. Here is what I did:
  1. Plot a velocity time graph where u = 0, v = 20, t = 4. The shape of this graph is something I arbitrarily set to an exponential shape, given that this is the profile I am looking for. I think you guys were recommending this above too.
  2. Use step wise integrals to find the area under the graph, in order to create a corresponding displacement time graph. Remember that I said I need displacement as a function of time. (I have a function that can do this accurately for as many intervals as needed).
  3. Now Step 2 doesn't take into account my distance of s = 10m since it only looks at the velocity time graph, so the y-axis of my displacement time graph is not correctly scaled. Therefore I scale it to match my displacement profile of s = 10.
  4. I move the particle using this displacement time graph.

The result of this process is below:

Video.gif


The motion discussed in this thread is the motion from off-screen right up until it hits the circle directly below the yellow point. After that the particle follows a circular motion with an angular velocity matched to the linear velocity. So if it works, we should see a nice smooth transition.

You can see however that it has not worked. I get an acceleration but it is too rapid, which makes the particle suddenly slow down after the linear motion has occurred. I assume that I have made a mistake in Steps 2-3 because I am effectively experimenting here without actually knowing what I am doing. :headbang:

If anyone could please outline where I've gone wrong, I'd really appreciate it.
 
Physics news on Phys.org
  • #32
Jack7 said:
If anyone could please outline where I've gone wrong,
Very hard to tell if you do not show any equations.

So your ultimate goal is for that square to start at a distance 10 m from the lowest point of a circle, accelerate towards it in 4 seconds, hit speed 20 m/s and then it will move along that circle with such tangential speed?

Then yes, an exponential acceleration will make the last second cover 87% of the total distance (3,46 m) and not look any nice.

Does the initial speed has to be zero?
 
Last edited:
  • #33
malawi_glenn said:
Very hard to tell if you do not show any equations.

So your ultimate goal is for that square to start at a distance 10 m from the lowest point of a circle, accelerate towards it in 4 seconds, hit speed 20 m/s and then it will move along that circle with such tangential speed?

Then yes, an exponential acceleration will make the last second cover 87% of the total distance (3,46 m) and not look any nice.

Does the initial speed has to be zero?
The only equation I am using is for the step integrals on the velocity time graph. The equation is as follows:

Code:
    private float StepIntegral(float x0, float y0, float x1, float y1)
    {
        float a = (y1 - y0) / (x1 - x0);
        float b = y0 - a * x0;
        return (a / 2 * x1 * x1 + b * x1) - (a / 2 * x0 * x0 + b * x0);
    }

This is partly why I have gone with using graphs rather than solving equations, I just find it a lot more intuitive and easy to visualise what is going on.
 
  • #34
malawi_glenn said:
Very hard to tell if you do not show any equations.

So your ultimate goal is for that square to start at a distance 10 m from the lowest point of a circle, accelerate towards it in 4 seconds, hit speed 20 m/s and then it will move along that circle with such tangential speed?

Then yes, an exponential acceleration will make the last second cover 87% of the total distance (3,46 m) and not look any nice.

Does the initial speed has to be zero?
Yes that's absolutely right, that is my goal. (Note that 4 seconds and 20 m/s is one case, the values will change in different cases and the clip shown above uses different values. The key is getting the transition to the tangential speed to be smooth).

Regarding your exponential comment.. shouldn't matter though right? It should still end with the correct velocity shouldn't it? Therefore the transition to tangential speed should still be smooth. The initial speed does not have to be zero per se, but I thought we established earlier in the thread that it had to be.
 
  • #35
Jack7 said:
I thought we established earlier in the thread that it had to be.
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.
 
  • #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.
 
  • #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

Similar threads

Replies
24
Views
2K
Replies
7
Views
2K
  • · Replies 6 ·
Replies
6
Views
416
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