我试图理解这个 raphael.js 演示的数学:
检查扇区方法:
function sector(cx, cy, r, startAngle, endAngle, params) {
var x1 = cx + r * Math.cos(-startAngle * rad),
x2 = cx + r * Math.cos(-endAngle * rad),
y1 = cy + r * Math.sin(-startAngle * rad),
y2 = cy + r * Math.sin(-endAngle * rad);
return paper.path(["M", cx, cy, "L", x1, y1, "A", r, r, 0, +(endAngle - startAngle > 180), 0, x2, y2, "z"]).attr(params);
}
这是实际的演示: http ://raphaeljs.com/pie.html
我的数学有点生疏,我试图理解扇区函数 - 给定 startAngle 和 endAngle 参数(每个起点和终点值在 0 到 360 之间绘制一个弧线),为什么这个函数有效?