I'm trying to calculate an uniformly accelerated rotation for the autopilot module in my 3d space game shooter. The autopilot should fly the spaceship to any given point in the 3d space on the shortest way possible.
For complexity reasons, I created a plane between the target and the spaceship so all calculations can be made in 2d.
There are some parameters given the rotation should be based on (1 second = 60 ticks):
- v = speed of the spaceship (meter per tick)
- d = direction union vector of the spaceship (x, y)
- ω = current rotational speed (radians per tick)
- ω_max = maximum rotational speed (radians per tick)
- Δω = maximum rotational speed increase/decrease (radians per tick)
Example (rotational speed per tick):
- rotate to right: ω = min(ω + Δω, ω_max)
- rotate back: ω = max(ω - Δω, 0)
(Note: This example is simplified and does not work for turns to the left because of min/max.)
Example of the curve when "turning the steering wheel" slowly (black) to the most right position (red). Maybe some sort of hyperbolic spiral?:
-- My problem --
Find the angle when it is time to rotate back so that ω = 0 when d points to the target point. The angle to the target has changed due to the rotational movement.
Find the target position when rotation is done.
Check if the rotation is even possible (e.g. because the spaceship can not rotate fast enough, the target point is too close). A boolean would be enough so I can fly the spaceship for a second straight on and check again later.
If it would be possible to set a target direction vector like in this answer, that would be insane, but optional! This answer only works if ω is either 0 or ω_max.
Thank you!