一个点绕另外一个点旋转一个角度

c++代码如下所示

class Point 
{
    
    
public:
Point(int _x, int _y) : x(_x), y(_y) {
    
    }
  int x() {
    
    return x;}
  int y() {
    
    return y;}
private:
  int x;
  int y;
}

 Point centerP = Point((p1.x() + p2.x())/2.0, (p1.y() + p2.y())/2.0);
 int startAngle=60;//角度,欧拉角
//旋转之后的横纵坐标
float x0 = (p2.x() - centerP.x())*cos(startAngle*PI / 180.0) - (p2.y() centerP.y())*sin(startAngle*M_PI / 180.0) + centerP.x();
                                                                      
float y0 = (p2.x() - centerP.x())*sin(startAngle*PI / 180.0) + (p2.y() - centerP.y())*cos(startAngle*PI / 180.0) + centerP.y();

猜你喜欢

转载自blog.csdn.net/qq_41841073/article/details/132456659