From cc47f81dc1de614a193dd443a12b28cd34954a70 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sun, 9 Feb 2020 17:55:19 +0800 Subject: [PATCH] add simple doc --- src/experimental/pt_to_sphere.scad | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/experimental/pt_to_sphere.scad b/src/experimental/pt_to_sphere.scad index b2487b27..2a2187eb 100644 --- a/src/experimental/pt_to_sphere.scad +++ b/src/experimental/pt_to_sphere.scad @@ -1,16 +1,22 @@ use ; -function pt_to_sphere(p, size, r, angle = [180, 360]) = +/* + size: The size of the rectangle mapping to a sphere. + p: A point in the rectangle. + r: sphere radius. + angle: [za, xa] mapping angles. +*/ +function pt_to_sphere(size, p, r, angle = [180, 360]) = let( x = p[0], y = p[1], - za = angle[0], - xa = angle[1], + za = angle[0], + xa = angle[1], xlen = size[0], ylen = size[1], za_step = za / ylen, rza = za_step * y, - rzpt = [r * cos(rza), r * sin(rza), 0], - rxpt = rotate_p(rzpt, [xa / xlen * x, 0, 0]) + rzpt = [r * cos(rza), r * sin(rza), 0], + rxpt = rotate_p(rzpt, [xa / xlen * x, 0, 0]) ) rxpt; \ No newline at end of file