Moving in a straight line with multiple constraints

AI Thread 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.
  • #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)
 
Physics news on Phys.org
  • #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
  • #71
kuruman said:
While playing with possible trajectory equations
That is what you would get as suggested in #21
 
  • #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:
Back
Top