Turntable Rotation Algorithm

Source: Internet
Author: User

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.


)

)

)

)

)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.