0
我正在学习2D图形,我试图绘制圆,但是我得到了一些奇怪的曲线。为什么它不是圈子?
function rotatePoint (point, centerPoint, theta) {
point[0] = point[0] - centerPoint[0];
point[1] = point[1] - centerPoint[1];
point[0] = point[0]*Math.cos(theta)-point[1]*Math.sin(theta);
point[1] = point[0]*Math.sin(theta)+point[1]*Math.cos(theta);
point[0] = point[0] + centerPoint[0];
point[1] = point[1] + centerPoint[1];
}
配方看起来不错,但...我不知道,我无法弄清楚:/ ...感谢您的帮助。 http://jsfiddle.net/nQvGT/173/
也许你传递的角度。 Javascript需要弧度。所以theta不在0-360的范围内;它的0-2pi – duffymo 2013-03-25 13:28:47
没有。 'rotatePoint(d,[400,400],Math.PI * n/180);'或'rotatePoint(d,[400,400],n);' - 没有区别 – Isinlor 2013-03-25 13:36:19
然后Guffa的答案很可能是正确的。 – duffymo 2013-03-25 13:40:10