Uniform Acceleration and Deceleration for Smooth Movement to (0,0,0)?

  • Context: Undergrad 
  • Thread starter Thread starter Morcam
  • Start date Start date
  • Tags Tags
    Movement Smooth
Click For Summary
SUMMARY

The discussion focuses on implementing uniform acceleration and deceleration for smooth movement of an object to the coordinates (0,0,0) in a game modification. The user initially employed a damped spring equation but encountered issues with the object never fully stopping at the target angle. The solution involves using the uniform acceleration equation, x(t) = (1/2)at² + v₀t + x₀, applied separately for acceleration and deceleration phases, ensuring continuity in position and velocity at the transition point. The user seeks a method that accommodates variable calculation times and potential changes in direction during movement.

PREREQUISITES
  • Understanding of basic physics concepts, particularly kinematics.
  • Familiarity with the uniform acceleration equation.
  • Knowledge of vector notation and its application in game physics.
  • Experience with game development frameworks that handle object transformations.
NEXT STEPS
  • Research the implementation of kinematic equations in game engines like Unity or Unreal Engine.
  • Learn about interpolation techniques for smoother transitions in object movement.
  • Explore predictive algorithms to manage variable delta time in physics calculations.
  • Investigate the use of state machines for managing object movement states in games.
USEFUL FOR

Game developers, physics programmers, and anyone involved in creating smooth object movements in interactive applications will benefit from this discussion.

Morcam
Messages
4
Reaction score
0
Hey there! I'm working on a bit of a game modification, and I'm looking for a little help with some physics-related math. I'm only in my second year of high-school physics, so I'm not completely sure where to go with this question. And sorry if this is in the wrong forum.

Essentially, I'm trying to rotate an object to how the player is looking. To achieve this, I was originally doing a little bit of math to find the angular difference, and just using a damped spring equation to rotate the object back to how I want it fairly smoothly. Quite simple. The only problem with this is that it steadily slows down as it approaches the angle (0,0,0), never quite stopping or reaching the angle, which makes sense for this equation.

Unfortunately, I'd like the object to uniformly accelerate and uniformly decelerate back to (0,0,0). Differing acceleration and deceleration speeds are necessary, as well as a top speed. Since this is a computer, I can only run so many calculations per second, and I can ignore drag and gravity if I so choose. The player may also choose to change the direction in the middle of the trip back to zero, which would, of course, be necessary to take into account. I realize this may seem a bit demanding, but it's really what's necessary to solve this.

The actual game-use of this is to turn an aircraft to where the player is looking. The turning of their view in conjunction with this is already compensated for. However, I'm sure I'll find some other uses for this in the future, so it's quite beneficial.

A real-world analogy of this would be having a car, say, 50 meters away from a line, which can accelerate and decelerate at certain speeds, and having the car evenly accelerate to a point, then decelerate from that point to a full stop. The line may move mid-trip, which would have to be taken into account, and only so many calculations (say 10) can be done per second.

Logically, this should seem easier, but I'm honestly at a bit of a loss as to what equations I should use for this. If this is an impossibility for me/out of my scope, I can always go back to my simpler equations, but I would very much prefer a better solution. I've been looking for a solution to this for a couple weeks now, and I haven't been able to find anything. It's really been quite a learning experience, that's for sure, but I'd like to finally put this problem away. Any help would be very much appreciated.
 
Physics news on Phys.org
Morcam said:
A real-world analogy of this would be having a car, say, 50 meters away from a line, which can accelerate and decelerate at certain speeds, and having the car evenly accelerate to a point, then decelerate from that point to a full stop.
I don't really understand your question, especially the use of vector notation to describe an angle. However, the equation for uniform acceleration is:
x(t) = \frac{1}{2}a t^2 + v_0 t + x_0
where x_0 is the initial position, v_0 is the initial velocity, and a is the acceleration. Since you want uniform acceleration followed by uniform deceleration you will have to use this equation twice, once for the acceleration stage and once for the deceleration stage. You will need to make sure that the position and velocity of the two stages are equal at the time that you switch between them.
 
DaleSpam said:
I don't really understand your question, especially the use of vector notation to describe an angle. However, the equation for uniform acceleration is:
x(t) = \frac{1}{2}a t^2 + v_0 t + x_0
where x_0 is the initial position, v_0 is the initial velocity, and a is the acceleration. Since you want uniform acceleration followed by uniform deceleration you will have to use this equation twice, once for the acceleration stage and once for the deceleration stage. You will need to make sure that the position and velocity of the two stages are equal at the time that you switch between them.

Feel free to completely ignore that it is an angle and treat it completely like a vector. That's why I put in the real-world comparison. There isn't a difference in this scenario. And I was originally going to do that solution, but would that not require me to do a pair of square roots? I was trying to avoid square roots, if possible. I'm also not sure if the delta time is going to be completely stable, which could mess that up when it reaches zero. Because of the wait time in calculations, you would overshoot, then overshoot back, and would just jitter there, trying to reach zero. I'm probably not explaining this very well.

Ideally the velocity-time graph would be a simple upside-down V. This would mean locating the peak of the graph would be easy. However, even if I know where it is, if it doesn't line up with the calculation times (picture a bunch of vertical lines on the graph), then I would not be able to apply the correct deceleration force at the correct time. I could theoretically get past this by predicting the acceleration/deceleration in that time period and adding them, but once I reach zero, I think this method would break down. If the deltatime (time between calculations) is inconsistent, then I believe it is impossible. Ideally, there would be a simple method to bypass this (such as the damped spring equation), but I'm not entirely sure that there is. And if there is, I'm not sure if it lies entirely in the realm of physics.
 
Last edited:

Similar threads

  • · Replies 2 ·
Replies
2
Views
10K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 22 ·
Replies
22
Views
932
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 25 ·
Replies
25
Views
4K
  • · Replies 5 ·
Replies
5
Views
8K
  • · Replies 17 ·
Replies
17
Views
4K