我正在尝试在Openscad中使用Bresenham的算法。 我一点一点地把事情弄得一团糟,看看事情出了什么问题。 查看Openscad的输出,我发现所提供的值的cos值不正确。 以下是Openscad显示的值和cos(值)列表。
ECHO: 0.628319, 0.99994
ECHO: 1.25664, 0.999759
ECHO: 1.88496, 0.999459
ECHO: 2.51327, 0.999038
ECHO: 3.14159, 0.998497
ECHO: 3.76991, 0.997836
ECHO: 4.39823, 0.997055
ECHO: 5.02655, 0.996154
ECHO: 5.65487, 0.995133
ECHO: 6.28319, 0.993993
这是由代码生成的:
spots = 10;
difference(){
cylinder(r=50, h=10, center=true);
translate ([0,0,-10])cylinder(r=5, h=20);
for ( z = [1:10]) {
assign (step = z/spots)
assign (step2 = (2 * PI * step))
echo (step2, cos(abs(step2)));
}
}
答案 0 :(得分:3)
cos()需要度,请尝试:
//assign (step2 = (2 * PI * step))
assign(step2 = 360*step)