HTML5 Canvas : Advanced Circular Motion
Review circular motion
The HTML5 Canvas :Motion And Trajectory paper introduces the realization principle of circular motion, and reviews its calculation method as follows:
// (centerx, center) : center coordinates
// radius : radius of rotation
// angle : the angle of rotation
x = centerX + Math.sin(angle) * radius
y = centerY + Math.cos(angle) * radius
The above formula shows that we have known center point
coordinates, known radius of rotation
and the angle between the rotating control point and the x-axis, that is, angle of rotation
. Then, the coordinates of the control points after rotation are calculated based on the rotation radius and the changing rotation angle.
But sometimes...