Calculating speed and reversing inertia

  • Thread starter Thread starter SeanCocteau
  • Start date Start date
  • Tags Tags
    Inertia Speed
AI Thread Summary
The discussion revolves around the challenges of calculating the speed and inertia of an object during an animation sequence where the object must dock at a specific position. The programmer is struggling with the correct application of physics formulas, particularly in adjusting speed to ensure the object stops at the desired location. Current methods involve decrementing speed by a percentage, leading to inaccuracies, and the use of traditional equations of motion does not account for the non-linear acceleration due to the decrementing speed. Suggestions include treating acceleration as a constant value rather than a percentage and using calculus to derive the final velocity and stopping distance. The goal is to achieve a more precise and natural animation effect while addressing the complexities of variable speed and inertia.
SeanCocteau
Messages
2
Reaction score
0
Hi

I'm a programmer and while my maths is OK, my understanding of physics is not the best so apologies in advance if I'm missing something obvious. My problem is an interaction and animation sequence I'm writing, the user can swipe an object from one position to another. No problem here. The issue is that I need the object to 'dock' to a specific position, again no problem calculating the final resting position.

My problem is that I applying inertia (I decrement the detected speed on each animation cycle so this value is undeterminent) causing the object to slow and then stop once it hits a specific figure. Originally I thought I could calculate the 'expected distance' the object would travel to, but I believe that I did not have enough parameters to do this, only the speed and deceleration value. To calculate the expected distance, I create a second loop, decrement the speed but adding to the expected distance until it hits the stop speed. Not overly elegant, but it returns the correct figure.

However, to get the object to end at a specific position I need to reverse this calculation, adjusting the speed of the object so it lands in the appropriate position. At the moment, I've been using Vf^2 = Vi^2 + 2ad but this hasn't been providing the correct values so far.

For instance, the speed is 38 pixels per animation frame, the initial starting velocity is 0.05 pixels per animation frame and we expect to move 721.0825 pixels in total. After the positioning calculation (which is fine), the expected distance is revised to 785. Note: during the animation, the speed is decremented by 95% on each animation frame so I'm setting the acceleration to 1.05225 (as an arbitary figure).

So if I done things correctly, the speed should be square root of ( ( 2 * 785 * 1.05225 ) + ( 0.05 ^ 2 ) ), which equals 40.65542.

But as you've guessed it, this isn't working and is providing very wonky results? Have I missed something out? Am I using the wrong formula as the speed is not constant (as it is decremented on each animation until the speed reaches 0.05)?

Any help, (of any kind) is gratefully received.

S

Note: I do have a workaround by adjusting the speed using a percentage, e.g. (revised distance / expected distance) * speed that works but isn't pixel perfect. But I'm sure there's a more elegant approach.
 
Physics news on Phys.org
hello there. The equations of motion you have used are for frames that have linear acceleration. However when you are deducing the decrement in speed (the effecting acceleration) you calculate the acceleration based on a percentage of the speed of the object. this means the acceleration (total speed decrement) at some point p is going to be smaller than the acceleration at some later point q because the speed at q is lower. try making the acceleration a parameter thatll be an absolute constant i.e. change the speed decrement to a non percentage value like 5 or 10. or you could change ur motion calculation formulae to take into account a non linear acceleration. for example: if you let y be the y cordinate of your object then at some later time t
y = y_0 + vt + (1/2 * a * t^2)
where a == speed decrement * v
or equivalently, the formulae you used in ur program
Vf^2 = Vi^2 + 2ad
but now a = speed decrement * v
mind you this may cause some uncertainty because we are using a linear formulae for a nonlinear acceleration
 
and by that i mean error
 
Unfortunately I need the animation to feel like a natural action (i.e. fiction stops the object from moving). In addition, the speed may very well differ meaning that a higher speed will take much, much longer to stop with a constant speed as opposed to a decrementing value.

Thanks for your input though, I'll have to see how well the percentage adjustment works in the wild.

However, if there is a true way of calculating with the anticipated speed I would dearly love to hear it :)
 
after a very large delay, and having fun with my ban... the answer to your question was in my original post. the value a should take (aceleration) isn't simply the decrementing coefficient but the decrementing coefficient times the velocity of the particle at that time.
for the non linear formulae of motion, all i can do is refer you to any classical mechanics or dynamics books. you should find examples answered also in calculus books.
 
im going to demonstrate with an example:
say you adjust the parameters so that the particle leaves with initial velocity u. you adjust the acceleration coefficient so that at some well defined time interval dt, the velocity is decremented by some coefficient c of its initial value, hence the value of acceleration (change in velocity) is equal to: a=v.c
the velocity of the particle the final point (vfin) then is given by vfin = u + a.dt
here I have missed out an integral sign behind a.dt as I am not sure how to draw one.
in essense then, if you set your program to decrement values from the velocity at some well defined time interval dt, and record the velocity at each point, you then know the acceleration at each point, letting you calculate the final velocity. to find the stopping distance then you take the integral of the vfin function.
 
Hi there, im studying nanoscience at the university in Basel. Today I looked at the topic of intertial and non-inertial reference frames and the existence of fictitious forces. I understand that you call forces real in physics if they appear in interplay. Meaning that a force is real when there is the "actio" partner to the "reactio" partner. If this condition is not satisfied the force is not real. I also understand that if you specifically look at non-inertial reference frames you can...
I have recently been really interested in the derivation of Hamiltons Principle. On my research I found that with the term ##m \cdot \frac{d}{dt} (\frac{dr}{dt} \cdot \delta r) = 0## (1) one may derivate ##\delta \int (T - V) dt = 0## (2). The derivation itself I understood quiet good, but what I don't understand is where the equation (1) came from, because in my research it was just given and not derived from anywhere. Does anybody know where (1) comes from or why from it the...

Similar threads

Back
Top