1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-14 10:44:48 +02:00

refactor: we don't need acos

This commit is contained in:
Justin Lin
2022-04-18 16:47:51 +08:00
parent ed1027f9de
commit f62079f334

View File

@@ -6,24 +6,24 @@ function rands_sphere(radius, value_count, seed = undef) =
for(i = [0:value_count - 1]) for(i = [0:value_count - 1])
let( let(
theta = degrees(2 * PI * r_nums[i]), theta = degrees(2 * PI * r_nums[i]),
phi = acos(r_nums[i + value_count] * 2 - 1), cos_phi = r_nums[i + value_count] * 2 - 1,
sin_phi = sin(phi), sin_phi = sqrt(1 - cos_phi ^ 2),
x = sin_phi * cos(theta), x = sin_phi * cos(theta),
y = sin_phi * sin(theta), y = sin_phi * sin(theta),
z = cos(phi) z = cos_phi
) )
[x, y, z] [x, y, z]
] * radius; ] * radius;
/* /*
use <experimental/rand_pts_sphere.scad>; use <util/rands_sphere.scad>;
use <polyhedron_hull.scad>; use <polyhedron_hull.scad>;
number = 20; number = 20;
radius = 2; radius = 2;
points = rand_pts_sphere(radius, number); points = rands_sphere(radius, number);
polyhedron_hull(points); polyhedron_hull(points);