great_circle_arc.scad
1 use <__comm__/__frags.scad> 2 use <ptf/ptf_rotate.scad> 3 4 function great_circle_arc(p1, p2) = 5 let( 6 radius = norm(p1), 7 normal_vt = cross(p2, p1), 8 a = asin(norm(normal_vt) / (p1 * p1)), 9 steps = round(a / (360 / __frags(radius))) 10 ) 11 steps == 0 ? [p1, p2] : 12 let(a_step = a / steps) 13 [for(i = [0:steps]) ptf_rotate(p1, a_step * i, normal_vt)]; 14 15 /* 16 use <experimental/great_circle_arc.scad> 17 use <voronoi/vrn_sphere.scad> 18 use <fibonacci_lattice.scad> 19 use <polyline_join.scad> 20 21 use <util/dedup.scad> 22 use <util/sorted.scad> 23 24 include <__comm__/_str_hash.scad> 25 26 n = 8; 27 radius = 20; 28 29 points = fibonacci_lattice(n, radius); 30 #for(p = points) { 31 translate(p) 32 sphere(1); 33 } 34 35 %sphere(radius); 36 37 edges = [ 38 for(cell = vrn_sphere(points)) 39 for(i = [0:len(cell) - 2]) 40 [cell[i], cell[i + 1]] 41 ]; 42 43 deduped = dedup(edges, function(e1, e2) sorted(e1) == sorted(e2), function(e) _str_hash(str(sorted(e)))); 44 45 for(edge = deduped) { 46 p1 = edge[0]; 47 p2 = edge[1]; 48 49 color("green") { 50 translate(p1, $fn = 36) 51 sphere(3); 52 53 translate(p2) 54 sphere(3, $fn = 36); 55 } 56 57 polyline_join(great_circle_arc(p1, p2, $fn = 96)) 58 sphere(2, $fn = 4); 59 } 60 */ 61 62 /* 63 use <experimental/great_circle_arc.scad> 64 use <voronoi/vrn_sphere.scad> 65 use <fibonacci_lattice.scad> 66 67 use <shape_star.scad> 68 use <path_extrude.scad> 69 70 use <util/dedup.scad> 71 use <util/sorted.scad> 72 73 include <__comm__/_str_hash.scad> 74 75 n = 8; 76 radius = 20; 77 78 points = fibonacci_lattice(n, radius); 79 #for(p = points) { 80 translate(p) 81 sphere(1); 82 } 83 84 %sphere(radius); 85 86 shape = shape_star(inner_radius = .5) * 2; 87 88 edges = [ 89 for(cell = vrn_sphere(points)) 90 for(i = [0:len(cell) - 2]) 91 [cell[i], cell[i + 1]] 92 ]; 93 94 deduped = dedup(edges, function(e1, e2) sorted(e1) == sorted(e2), function(e) _str_hash(str(sorted(e)))); 95 96 for(edge = deduped) { 97 p1 = edge[0]; 98 p2 = edge[1]; 99 100 color("green") { 101 translate(p1, $fn = 36) 102 sphere(3); 103 104 translate(p2) 105 sphere(3, $fn = 36); 106 } 107 108 path_extrude(shape, great_circle_arc(p1, p2, $fn = 96)); 109 } 110 */