As shown in the figure, how to find the coordinates of point b after point a is rotated around point o by an angle (counterclockwise here)?
Assuming that point o is the center of the circle (the origin), there is a calculation formula:
bx = ax*cos(angle) - ay*sin(angle)
by = ax*sin(angle) + ay*cos(angle)
The clockwise rotation is positive, the counterclockwise rotation is negative, and the angle angle is the radian value. For example, the conversion of 30 degrees to radians is: angle = pi/180 * 30.
If o is not the origin, you can first convert the coordinates of point a into relative coordinates for calculation, and add the coordinates of point o to the calculation result.
The coordinates of point a involved in the calculation should actually be a - 0, and the final calculation formula is as follows:
bx = ( ax - ox)*cos(angle) - (ay - oy)*sin(angle) + ox
by = (ax - ox)*sin(angle) + (ay - oy)*cos(angle) + oy
Quote: http://blog.csdn.net/can3981132/article/details/52518833