Today, at the company's request, we have implemented a turntable Rotation Algorithm,
I found a lot of information on the Internet and constructed an algorithm based on the actual results. In fact, the principle is very simple. Next I will make a summary: I hope to help or inspire friends who encounter such problems.
First, the turntable is rotated in several stages: acceleration, deceleration, and stopping to the specified position.
Of course, rotation is related to angle and radians. Here I will not introduce the radians. Of course, the rotation angle is used for conversion. The formula is: Angle/180 * PI.
At the beginning, I thought a lot about the acceleration and deceleration processes. The results were not close to the reality. However, it is certainly not futile to do so many experiments. From these methods, I finally chose the tangent function curve (),
I divide the rotation process into two parts: acceleration and deceleration. I use the coordinate of the origin to indicate acceleration to the over-point of deceleration. See the sketch below.
We can conclude that:
∞Reduce to 0, ∞Add. (Haha, it's exactly what I want, and it's not linearly increased, it's closer to authenticity)
M_dCurAngle; // current Rotation Angle
M_dTime; // the time from which the rotation starts.
M_dCurveMid; // the excessive time (and the total time of the previous acceleration period)
):
2. The problem of rotating to a specified point has not been solved (the random end point must be controllable)
M_dCurveParam; // curve parameter (set to 150 here)
M_dCurveScale; // curve table
M_dCurveOffset; // The total rotation speed.
)
)
)
)
)