From f62079f334f9896837a821424906e87a811489a1 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Mon, 18 Apr 2022 16:47:51 +0800 Subject: [PATCH] refactor: we don't need acos --- src/util/rands_sphere.scad | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/util/rands_sphere.scad b/src/util/rands_sphere.scad index 71db9598..f2fcd4bf 100644 --- a/src/util/rands_sphere.scad +++ b/src/util/rands_sphere.scad @@ -6,24 +6,24 @@ function rands_sphere(radius, value_count, seed = undef) = for(i = [0:value_count - 1]) let( theta = degrees(2 * PI * r_nums[i]), - phi = acos(r_nums[i + value_count] * 2 - 1), - sin_phi = sin(phi), + cos_phi = r_nums[i + value_count] * 2 - 1, + sin_phi = sqrt(1 - cos_phi ^ 2), x = sin_phi * cos(theta), y = sin_phi * sin(theta), - z = cos(phi) + z = cos_phi ) [x, y, z] ] * radius; /* -use ; +use ; use ; number = 20; radius = 2; -points = rand_pts_sphere(radius, number); +points = rands_sphere(radius, number); polyhedron_hull(points);