简单地从绘制一个分段的螺旋线开始。
螺旋半径从起始角到结束角,螺旋半径从内圆半径到外圆半径。
为了让您了解我的意思,请选择若干件 (n)
var n = 20, // The number of lines in the spiral
rStep = (outerRadius - innerRadius)/n, // the radius increase between points
aStep = (outerAngle - innerAngle)/n, // the angle change between points
points = [];
// compute the cartesian coordinates (x, y) from polar coordinates (r, a)
function cartesian(r, a) {
return [
r * Math.cos(a),
r * Math.sin(a)
];
}
for (i = 0; i <= n; i += 1) {
points.push(cartesian(innerRadius + (i * rStep), innerAngle + (i * aStep));
}
我已经使用极坐标演示了一个基本的分段螺旋:
http://jsfiddle.net/xmDx8/
尝试更改 n 以查看碎片如何构建。
drawLine(innerCircleIndex, outerCircleIndex, 1); // This is what you did
drawLine(innerCircleIndex, outerCircleIndex, 100); // 100 lines in the example
drawLine(innerCircleIndex, outerCircleIndex, n); // Choose n to see how it grows