为什么我不能将元素正确定位在圆周上?
Why can't I position the elements correctly on the circumference of a circle?
我有这个 fiddle : http://jsfiddle.net/wQXCL/427/
效果很好。将图像定位在圆弧的末端。但是这是因为我在定位图片的时候带走了90度(Math.PI/2
)
前移 90 度:http://jsfiddle.net/wQXCL/428/
对我来说,它看起来像是计算圆上的点的公式:
x = cx + r * cos(a)
y = cy + r * sin(a)
起始角是90度,对吗?
还是我对整件事的理解不正确?
D3 的 arc.startAngle()
指定为:
Angles are specified in radians; 0 corresponds to 12 o’clock (negative y) and proceeds clockwise, repeating at 2π.
相比之下,trigonometric functions on the unit circle定义如下:
the ray from the origin (0, 0) to (x, y) makes an angle θ from the positive x-axis, (where counterclockwise turning is positive)
为了弥补这一点,您需要从圆弧的角度中减去 π / 2,以便在三角计算中使用它们。
我有这个 fiddle : http://jsfiddle.net/wQXCL/427/
效果很好。将图像定位在圆弧的末端。但是这是因为我在定位图片的时候带走了90度(Math.PI/2
)
前移 90 度:http://jsfiddle.net/wQXCL/428/
对我来说,它看起来像是计算圆上的点的公式:
x = cx + r * cos(a)
y = cy + r * sin(a)
起始角是90度,对吗?
还是我对整件事的理解不正确?
D3 的 arc.startAngle()
指定为:
Angles are specified in radians; 0 corresponds to 12 o’clock (negative y) and proceeds clockwise, repeating at 2π.
相比之下,trigonometric functions on the unit circle定义如下:
the ray from the origin (0, 0) to (x, y) makes an angle θ from the positive x-axis, (where counterclockwise turning is positive)
为了弥补这一点,您需要从圆弧的角度中减去 π / 2,以便在三角计算中使用它们。