How to obtain the trajectory of circle in cocos2d-x

Source: Internet
Author: User



The principle of circle is not mentioned. If you go to Baidu or google, you should know it.
I am here to provide that if you use a program to obtain the point on the path of the circle


Struct YuanInfo
{
Point point; // Point coordinate on the circle
Float fDu; // The tangent angle of the Change Point on the circle
};




YuanInfo getPointByDu (Point point, float fR, float fAuToDu)
{
YunInfo info;
Int r = fR;
Int a = point. x;
Int B = point. y + fR;


Float fDushu = fAuToDu * M_PI/180.0;
Float k =-1.0/std: tan (fDushu );
Float fDu = std: atan (k) * 180.0f/M_PI;
If (fAuToDu> 0 & fAuToDu <180.0f)
{
FDu = 180.0f + fDu;
}


Float x = (a + r * std: cos (fDushu ));
Float y = (B + r * std: sin (fDushu ));


Info. point = Point (x, y );
Info. fDu = fDu * M_PI/180.0f;


Return info;
}




How can this be called?
Here I will first introduce the getPointByDu (Point point, float fR, float fAuToDu) Parameters
Point point: this value is a coordinate at the bottom of the circle.
Float fR: the radius of the circle
Float fAuToDu: This is the Rotation Degree of the radius.




In this way, as long as you keep changing float fAuToDu, This is the Rotation Degree of the radius, it is possible to return the point on the circle trajectory one by one, and the tangent angle

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.