1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-04-19 05:33:57 +02:00

add vrn_sphere

This commit is contained in:
Justin Lin 2022-01-11 11:34:12 +08:00
parent 1ec50f7b85
commit 84eeaf913a
3 changed files with 47 additions and 1 deletions

View File

@ -6,4 +6,5 @@ new:
- maze/mz_wang_tiles?
- surface/sf_cylinder?
- noise/worley_sphere?
- noise/worley_sphere?
- voronoi/vrn_sphere?

View File

@ -0,0 +1,7 @@
function stereographic_proj_to_plane(point) =
let(n = 1 - point.z)
[point.x / n, point.y / n];
function stereographic_proj_to_sphere(point) =
let(n = 1 + point.x ^ 2 + point.y ^ 2)
[2 * point.x / n, 2 * point.y / n, (-1 + point.x ^ 2 + point.y ^ 2) / n];

View File

@ -0,0 +1,38 @@
use <_impl/_vrn_sphere_impl.scad>;
use <vrn2_cells_from.scad>;
function vrn_sphere(points) =
let(
r = norm(points[0]),
plane_pts = [for(p = points) stereographic_proj_to_plane(p / r)],
inifinity = [4.5e8, 0],
vrn2_cells = vrn2_cells_from(concat(plane_pts, [inifinity]))
)
[
for(i = [0:len(vrn2_cells) - 2])
[for(p = vrn2_cells[i]) stereographic_proj_to_sphere(p) * r]
];
/*
use <voronoi/vrn_sphere.scad>;
use <fibonacci_lattice.scad>;
use <polyline_join.scad>;
n = 60;
radius = 2;
pts = fibonacci_lattice(n, radius);
#for(p = pts) {
translate(p)
sphere(.05);
}
cells = vrn_sphere(pts);
for(i = [0:len(cells) - 1]) {
cell = cells[i];
polyline_join(concat(cell, [cell[0]]))
sphere(.05);
}
*/