kdtop
2018-11-11 22:10:38 UTC
Hello all. First time poster, but long-time OpenSCAD user (2+ yrs).
I have the following code.
//Obtain vector of points on circumference of circle of radius = 50, start
angle=10, end angle=45, step of 2 degrees
circum_pts1 = circum_pts([[]], 10, 50, 2, 45);
echo(circum_pts1);
function circum_pts(pts, angle, rad, angle_step = 1, end_angle=360) =
let(x =rad * cos(angle))
let(y =rad * sin(angle))
angle < (end_angle+1) ?
concat(pts, [[x,y]], circum_pts(pts, angle+angle_step, rad, angle_step,
end_angle))
:
pts;
//-- End function ------------
This outputs the following value for result
ECHO: [[], [49.2404, 8.68241], [], [48.9074, 10.3956], [], [48.5148,
12.0961], [], [48.0631, 13.7819], [], [47.5528, 15.4508], [], [46.9846,
17.101], [], [46.3592, 18.7303], [], [45.6773, 20.3368], [], [44.9397,
21.9186], [], [44.1474, 23.4736], [], [43.3013, 25], [], [42.4024, 26.496],
[], [41.4519, 27.9596], [], [40.4508, 29.3893], [], [39.4005, 30.7831], [],
[38.3022, 32.1394], [], [37.1572, 33.4565], [], [35.967, 34.7329], []]
Notice that every other value is a null value. I can program around this,
but would like to figure out how to avoid.
Any ideas?
Thanks
Kevin Toppenberg
--
Sent from: http://forum.openscad.org/
I have the following code.
//Obtain vector of points on circumference of circle of radius = 50, start
angle=10, end angle=45, step of 2 degrees
circum_pts1 = circum_pts([[]], 10, 50, 2, 45);
echo(circum_pts1);
function circum_pts(pts, angle, rad, angle_step = 1, end_angle=360) =
let(x =rad * cos(angle))
let(y =rad * sin(angle))
angle < (end_angle+1) ?
concat(pts, [[x,y]], circum_pts(pts, angle+angle_step, rad, angle_step,
end_angle))
:
pts;
//-- End function ------------
This outputs the following value for result
ECHO: [[], [49.2404, 8.68241], [], [48.9074, 10.3956], [], [48.5148,
12.0961], [], [48.0631, 13.7819], [], [47.5528, 15.4508], [], [46.9846,
17.101], [], [46.3592, 18.7303], [], [45.6773, 20.3368], [], [44.9397,
21.9186], [], [44.1474, 23.4736], [], [43.3013, 25], [], [42.4024, 26.496],
[], [41.4519, 27.9596], [], [40.4508, 29.3893], [], [39.4005, 30.7831], [],
[38.3022, 32.1394], [], [37.1572, 33.4565], [], [35.967, 34.7329], []]
Notice that every other value is a null value. I can program around this,
but would like to figure out how to avoid.
Any ideas?
Thanks
Kevin Toppenberg
--
Sent from: http://forum.openscad.org/