要计算旋转点的位置,可以使用旋转矩阵。
转换为Javascript后,将计算旋转点:
function rotate(x, y, xm, ym, a) { var cos = Math.cos, sin = Math.sin, a = a * Math.PI / 180, // Convert to radians because that is what // Javascript likes // Subtract midpoints, so that midpoint is translated to origin // and add it in the end again xr = (x - xm) * cos(a) - (y - ym) * sin(a) + xm, yr = (x - xm) * sin(a) + (y - ym) * cos(a) + ym; return [xr, yr];}rotate(16, 32, 16, 16, 30); // [8, 29.856...]


