1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-12 17:54:18 +02:00

fix a_step == 0

This commit is contained in:
Justin Lin
2022-07-21 18:00:27 +08:00
parent 709c92714e
commit 15c1cd605f

View File

@@ -6,7 +6,38 @@ function arc_great_circle(p1, p2, center = [0, 0, 0]) =
radius = norm(p1 - center),
normal_vt = cross(p2, p1),
a = acos(p2 * p1 / pow(radius, 2)),
steps = round(a / (360 / __frags(radius))),
a_step = a / steps
steps = round(a / (360 / __frags(radius)))
)
[for(i = [0:steps]) ptf_rotate(p1, a_step * i, normal_vt)];
steps == 0 ? [p1, p2] :
let(a_step = a / steps)
[for(i = [0:steps]) ptf_rotate(p1, a_step * i, normal_vt)];
/*
use <experimental/arc_great_circle.scad>
use <voronoi/vrn_sphere.scad>
use <fibonacci_lattice.scad>
use <polyline_join.scad>
n = 10;
radius = 10;
points = fibonacci_lattice(n, radius);
#for(p = points) {
translate(p)
sphere(.5);
}
%sphere(radius);
for(cell = vrn_sphere(points)) {
pts = concat(cell, [cell[0]]);
for(i = [0:len(pts) - 2]) {
p1 = pts[i];
p2 = pts[i + 1];
arc = arc_great_circle(pts[i], pts[i + 1], $fn = 36);
polyline_join(arc)
sphere(.5, $fn = 4);
}
}
*/