J
jon
Tue, Feb 28, 2023 3:39 PM
I wrote some code to create a spiral of spheres around the surface of a
larger sphere. It works fine, but the spacing is too tight near the poles.
If I were writing in a "normal" language, I would calculate the position
of each possible new sphere, then calculate the distance from that
sphere to the most recently successfully placed sphere, and avoid
placing the new one if the distance was too small. But I am writing in
OpenSCAD, so that approach will not work; at least, I don't know how to
do this in OpenSCAD.
Any thoughts?
function x(r, theta, rho) = r * sin(theta) * cos(rho);
function y(r, theta, rho) = r * sin(theta) * sin(rho);
function z(r, theta, rho) = r * cos(theta);
sphereD = 5;
numRots = 7;
numSpheres = numRots * 360;
r = 100;
for (rho = [0:5:numSpheres])
let (theta = (180 * (rho / numSpheres)))
translate([x(r, theta, rho), y(r, theta, rho), z(r, theta, rho)])
sphere(d = sphereD);
I wrote some code to create a spiral of spheres around the surface of a
larger sphere. It works fine, but the spacing is too tight near the poles.
If I were writing in a "normal" language, I would calculate the position
of each possible new sphere, then calculate the distance from that
sphere to the most recently successfully placed sphere, and avoid
placing the new one if the distance was too small. But I am writing in
OpenSCAD, so that approach will not work; at least, I don't know how to
do this in OpenSCAD.
Any thoughts?
function x(r, theta, rho) = r * sin(theta) * cos(rho);
function y(r, theta, rho) = r * sin(theta) * sin(rho);
function z(r, theta, rho) = r * cos(theta);
sphereD = 5;
numRots = 7;
numSpheres = numRots * 360;
r = 100;
for (rho = [0:5:numSpheres])
let (theta = (180 * (rho / numSpheres)))
translate([x(r, theta, rho), y(r, theta, rho), z(r, theta, rho)])
sphere(d = sphereD);
FH
Father Horton
Tue, Feb 28, 2023 3:42 PM
Can you give a pseudo-code example of the algorithm you want?
On Tue, Feb 28, 2023 at 9:40 AM jon jon@jonbondy.com wrote:
I wrote some code to create a spiral of spheres around the surface of a
larger sphere. It works fine, but the spacing is too tight near the poles.
If I were writing in a "normal" language, I would calculate the position
of each possible new sphere, then calculate the distance from that
sphere to the most recently successfully placed sphere, and avoid
placing the new one if the distance was too small. But I am writing in
OpenSCAD, so that approach will not work; at least, I don't know how to
do this in OpenSCAD.
Any thoughts?
function x(r, theta, rho) = r * sin(theta) * cos(rho);
function y(r, theta, rho) = r * sin(theta) * sin(rho);
function z(r, theta, rho) = r * cos(theta);
sphereD = 5;
numRots = 7;
numSpheres = numRots * 360;
r = 100;
for (rho = [0:5:numSpheres])
let (theta = (180 * (rho / numSpheres)))
translate([x(r, theta, rho), y(r, theta, rho), z(r, theta, rho)])
sphere(d = sphereD);
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Can you give a pseudo-code example of the algorithm you want?
On Tue, Feb 28, 2023 at 9:40 AM jon <jon@jonbondy.com> wrote:
> I wrote some code to create a spiral of spheres around the surface of a
> larger sphere. It works fine, but the spacing is too tight near the poles.
>
> If I were writing in a "normal" language, I would calculate the position
> of each possible new sphere, then calculate the distance from that
> sphere to the most recently successfully placed sphere, and avoid
> placing the new one if the distance was too small. But I am writing in
> OpenSCAD, so that approach will not work; at least, I don't know how to
> do this in OpenSCAD.
>
> Any thoughts?
>
>
>
> function x(r, theta, rho) = r * sin(theta) * cos(rho);
> function y(r, theta, rho) = r * sin(theta) * sin(rho);
> function z(r, theta, rho) = r * cos(theta);
>
> sphereD = 5;
> numRots = 7;
> numSpheres = numRots * 360;
> r = 100;
> for (rho = [0:5:numSpheres])
> let (theta = (180 * (rho / numSpheres)))
> translate([x(r, theta, rho), y(r, theta, rho), z(r, theta, rho)])
> sphere(d = sphereD);
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
J
jon
Tue, Feb 28, 2023 4:44 PM
Imagine a spiral line drawn on the surface of the large [invisible]
sphere, from pole to pole, twisting around the sphere "n" times. Then
put smaller spheres along that line so that they are more-or-less
equally spaced.
I suppose I could write that algorithm external to OpenSCAD and then
import the x/y/z list to create the STL, but I would prefer to keep it
in OpenSCAD if I can
Jon
On 2/28/2023 10:42 AM, Father Horton wrote:
Can you give a pseudo-code example of the algorithm you want?
On Tue, Feb 28, 2023 at 9:40 AM jon jon@jonbondy.com wrote:
I wrote some code to create a spiral of spheres around the surface
of a
larger sphere. It works fine, but the spacing is too tight near
the poles.
If I were writing in a "normal" language, I would calculate the
position
of each possible new sphere, then calculate the distance from that
sphere to the most recently successfully placed sphere, and avoid
placing the new one if the distance was too small. But I am
writing in
OpenSCAD, so that approach will not work; at least, I don't know
how to
do this in OpenSCAD.
Any thoughts?
function x(r, theta, rho) = r * sin(theta) * cos(rho);
function y(r, theta, rho) = r * sin(theta) * sin(rho);
function z(r, theta, rho) = r * cos(theta);
sphereD = 5;
numRots = 7;
numSpheres = numRots * 360;
r = 100;
for (rho = [0:5:numSpheres])
let (theta = (180 * (rho / numSpheres)))
translate([x(r, theta, rho), y(r, theta, rho), z(r,
theta, rho)])
sphere(d = sphereD);
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org
Imagine a spiral line drawn on the surface of the large [invisible]
sphere, from pole to pole, twisting around the sphere "n" times. Then
put smaller spheres along that line so that they are more-or-less
equally spaced.
I suppose I could write that algorithm external to OpenSCAD and then
import the x/y/z list to create the STL, but I would prefer to keep it
in OpenSCAD if I can
Jon
On 2/28/2023 10:42 AM, Father Horton wrote:
> Can you give a pseudo-code example of the algorithm you want?
>
> On Tue, Feb 28, 2023 at 9:40 AM jon <jon@jonbondy.com> wrote:
>
> I wrote some code to create a spiral of spheres around the surface
> of a
> larger sphere. It works fine, but the spacing is too tight near
> the poles.
>
> If I were writing in a "normal" language, I would calculate the
> position
> of each possible new sphere, then calculate the distance from that
> sphere to the most recently successfully placed sphere, and avoid
> placing the new one if the distance was too small. But I am
> writing in
> OpenSCAD, so that approach will not work; at least, I don't know
> how to
> do this in OpenSCAD.
>
> Any thoughts?
>
>
>
> function x(r, theta, rho) = r * sin(theta) * cos(rho);
> function y(r, theta, rho) = r * sin(theta) * sin(rho);
> function z(r, theta, rho) = r * cos(theta);
>
> sphereD = 5;
> numRots = 7;
> numSpheres = numRots * 360;
> r = 100;
> for (rho = [0:5:numSpheres])
> let (theta = (180 * (rho / numSpheres)))
> translate([x(r, theta, rho), y(r, theta, rho), z(r,
> theta, rho)])
> sphere(d = sphereD);
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email todiscuss-leave@lists.openscad.org
RW
Rogier Wolff
Tue, Feb 28, 2023 5:39 PM
On Tue, Feb 28, 2023 at 10:39:59AM -0500, jon wrote:
I wrote some code to create a spiral of spheres around the surface of a
larger sphere. It works fine, but the spacing is too tight near the poles.
If I were writing in a "normal" language, I would calculate the position of
each possible new sphere, then calculate the distance from that sphere to
the most recently successfully placed sphere, and avoid placing the new one
if the distance was too small. But I am writing in OpenSCAD, so that
approach will not work; at least, I don't know how to do this in OpenSCAD.
You can do this in openscad.
Just calculate x,y, z for the new point,
but also do this for the "last" point. (in openscad I'd just calculate
it AGAIN)
Then calculate the distance between the two
d = sqrt ((xold-x)(xold-x)+(yold-y)(yold-y)+(zold-z)*(zold-z));
and then put
if (d > mindist)
in front of the sphere.
If you want ONE spiral, I'd have just one variable theta run from 0 to
360 * number of loops around the sphere.
Roger.
--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 **
f equals m times a. When your f is steady, and your m is going down
your a is going up. -- Chris Hadfield about flying up the space shuttle.
On Tue, Feb 28, 2023 at 10:39:59AM -0500, jon wrote:
> I wrote some code to create a spiral of spheres around the surface of a
> larger sphere. It works fine, but the spacing is too tight near the poles.
>
> If I were writing in a "normal" language, I would calculate the position of
> each possible new sphere, then calculate the distance from that sphere to
> the most recently successfully placed sphere, and avoid placing the new one
> if the distance was too small. But I am writing in OpenSCAD, so that
> approach will not work; at least, I don't know how to do this in OpenSCAD.
You can do this in openscad.
Just calculate x,y, z for the new point,
but also do this for the "last" point. (in openscad I'd just calculate
it AGAIN)
Then calculate the distance between the two
d = sqrt ((xold-x)*(xold-x)+(yold-y)*(yold-y)+(zold-z)*(zold-z));
and then put
if (d > mindist)
in front of the sphere.
If you want ONE spiral, I'd have just one variable theta run from 0 to
360 * number of loops around the sphere.
Roger.
--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 **
f equals m times a. When your f is steady, and your m is going down
your a is going up. -- Chris Hadfield about flying up the space shuttle.
NH
nop head
Tue, Feb 28, 2023 5:42 PM
You could write a list comprehension that produces a list of points on the
spiral at sufficient resolution and then calculate its total length with a
function like the path_length() function in NopSCADlib.
Then you could divide that by the number of spheres you want to the path
length between each sphere. Then, with another recursive function, you
could find how far along the list of points each sphere is and interpolate
between the nearest pair of points to get a fairly accurate position.
On Tue, 28 Feb 2023 at 16:44, jon jon@jonbondy.com wrote:
Imagine a spiral line drawn on the surface of the large [invisible]
sphere, from pole to pole, twisting around the sphere "n" times. Then put
smaller spheres along that line so that they are more-or-less equally
spaced.
I suppose I could write that algorithm external to OpenSCAD and then
import the x/y/z list to create the STL, but I would prefer to keep it in
OpenSCAD if I can
Jon
On 2/28/2023 10:42 AM, Father Horton wrote:
Can you give a pseudo-code example of the algorithm you want?
On Tue, Feb 28, 2023 at 9:40 AM jon jon@jonbondy.com wrote:
I wrote some code to create a spiral of spheres around the surface of a
larger sphere. It works fine, but the spacing is too tight near the
poles.
If I were writing in a "normal" language, I would calculate the position
of each possible new sphere, then calculate the distance from that
sphere to the most recently successfully placed sphere, and avoid
placing the new one if the distance was too small. But I am writing in
OpenSCAD, so that approach will not work; at least, I don't know how to
do this in OpenSCAD.
Any thoughts?
function x(r, theta, rho) = r * sin(theta) * cos(rho);
function y(r, theta, rho) = r * sin(theta) * sin(rho);
function z(r, theta, rho) = r * cos(theta);
sphereD = 5;
numRots = 7;
numSpheres = numRots * 360;
r = 100;
for (rho = [0:5:numSpheres])
let (theta = (180 * (rho / numSpheres)))
translate([x(r, theta, rho), y(r, theta, rho), z(r, theta, rho)])
sphere(d = sphereD);
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
You could write a list comprehension that produces a list of points on the
spiral at sufficient resolution and then calculate its total length with a
function like the path_length() function in NopSCADlib.
Then you could divide that by the number of spheres you want to the path
length between each sphere. Then, with another recursive function, you
could find how far along the list of points each sphere is and interpolate
between the nearest pair of points to get a fairly accurate position.
On Tue, 28 Feb 2023 at 16:44, jon <jon@jonbondy.com> wrote:
> Imagine a spiral line drawn on the surface of the large [invisible]
> sphere, from pole to pole, twisting around the sphere "n" times. Then put
> smaller spheres along that line so that they are more-or-less equally
> spaced.
>
> I suppose I could write that algorithm external to OpenSCAD and then
> import the x/y/z list to create the STL, but I would prefer to keep it in
> OpenSCAD if I can
>
> Jon
> On 2/28/2023 10:42 AM, Father Horton wrote:
>
> Can you give a pseudo-code example of the algorithm you want?
>
> On Tue, Feb 28, 2023 at 9:40 AM jon <jon@jonbondy.com> wrote:
>
>> I wrote some code to create a spiral of spheres around the surface of a
>> larger sphere. It works fine, but the spacing is too tight near the
>> poles.
>>
>> If I were writing in a "normal" language, I would calculate the position
>> of each possible new sphere, then calculate the distance from that
>> sphere to the most recently successfully placed sphere, and avoid
>> placing the new one if the distance was too small. But I am writing in
>> OpenSCAD, so that approach will not work; at least, I don't know how to
>> do this in OpenSCAD.
>>
>> Any thoughts?
>>
>>
>>
>> function x(r, theta, rho) = r * sin(theta) * cos(rho);
>> function y(r, theta, rho) = r * sin(theta) * sin(rho);
>> function z(r, theta, rho) = r * cos(theta);
>>
>> sphereD = 5;
>> numRots = 7;
>> numSpheres = numRots * 360;
>> r = 100;
>> for (rho = [0:5:numSpheres])
>> let (theta = (180 * (rho / numSpheres)))
>> translate([x(r, theta, rho), y(r, theta, rho), z(r, theta, rho)])
>> sphere(d = sphereD);
>> _______________________________________________
>> OpenSCAD mailing list
>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
J
jon
Tue, Feb 28, 2023 5:58 PM
Rogier:
Your algorithm is exactly what I had in mind. Can you code this in
OpenSCAD? Your description (and mine) seem too procedural, with various
variables (like r, rho, theta and oldR, oldRho, and oldTheta) assuming a
variety of values as the calculation proceeds, which is challenging in
OpenSCAD (where most "variables" are constants).
Jon
On 2/28/2023 12:39 PM, Rogier Wolff wrote:
On Tue, Feb 28, 2023 at 10:39:59AM -0500, jon wrote:
I wrote some code to create a spiral of spheres around the surface of a
larger sphere. It works fine, but the spacing is too tight near the poles.
If I were writing in a "normal" language, I would calculate the position of
each possible new sphere, then calculate the distance from that sphere to
the most recently successfully placed sphere, and avoid placing the new one
if the distance was too small. But I am writing in OpenSCAD, so that
approach will not work; at least, I don't know how to do this in OpenSCAD.
You can do this in openscad.
Just calculate x,y, z for the new point,
but also do this for the "last" point. (in openscad I'd just calculate
it AGAIN)
Then calculate the distance between the two
d = sqrt ((xold-x)(xold-x)+(yold-y)(yold-y)+(zold-z)*(zold-z));
and then put
if (d > mindist)
in front of the sphere.
If you want ONE spiral, I'd have just one variable theta run from 0 to
360 * number of loops around the sphere.
Roger.
Rogier:
Your algorithm is exactly what I had in mind. Can you code this in
OpenSCAD? Your description (and mine) seem too procedural, with various
variables (like r, rho, theta and oldR, oldRho, and oldTheta) assuming a
variety of values as the calculation proceeds, which is challenging in
OpenSCAD (where most "variables" are constants).
Jon
On 2/28/2023 12:39 PM, Rogier Wolff wrote:
> On Tue, Feb 28, 2023 at 10:39:59AM -0500, jon wrote:
>> I wrote some code to create a spiral of spheres around the surface of a
>> larger sphere. It works fine, but the spacing is too tight near the poles.
>>
>> If I were writing in a "normal" language, I would calculate the position of
>> each possible new sphere, then calculate the distance from that sphere to
>> the most recently successfully placed sphere, and avoid placing the new one
>> if the distance was too small. But I am writing in OpenSCAD, so that
>> approach will not work; at least, I don't know how to do this in OpenSCAD.
> You can do this in openscad.
>
> Just calculate x,y, z for the new point,
> but also do this for the "last" point. (in openscad I'd just calculate
> it AGAIN)
>
> Then calculate the distance between the two
> d = sqrt ((xold-x)*(xold-x)+(yold-y)*(yold-y)+(zold-z)*(zold-z));
>
> and then put
> if (d > mindist)
>
> in front of the sphere.
>
> If you want ONE spiral, I'd have just one variable theta run from 0 to
> 360 * number of loops around the sphere.
>
> Roger.
>
>
RW
Rogier Wolff
Tue, Feb 28, 2023 6:59 PM
On Tue, Feb 28, 2023 at 12:58:24PM -0500, jon wrote:
Rogier:
Your algorithm is exactly what I had in mind. Can you code this in
OpenSCAD? Your description (and mine) seem too procedural, with various
variables (like r, rho, theta and oldR, oldRho, and oldTheta) assuming a
variety of values as the calculation proceeds, which is challenging in
OpenSCAD (where most "variables" are constants).
In a procedural language, you'd optimize by keeping assigning oldrho =
rho; etc just before the loop goes to the next one.
in openscad you just calculate the old one based on <loopvariable-1> .
Oh.... My suggestion doesn't work if you need to skip more than one
sphere. :-(
Roger.
Jon
On 2/28/2023 12:39 PM, Rogier Wolff wrote:
On Tue, Feb 28, 2023 at 10:39:59AM -0500, jon wrote:
I wrote some code to create a spiral of spheres around the surface of a
larger sphere. It works fine, but the spacing is too tight near the poles.
If I were writing in a "normal" language, I would calculate the position of
each possible new sphere, then calculate the distance from that sphere to
the most recently successfully placed sphere, and avoid placing the new one
if the distance was too small. But I am writing in OpenSCAD, so that
approach will not work; at least, I don't know how to do this in OpenSCAD.
You can do this in openscad.
Just calculate x,y, z for the new point,
but also do this for the "last" point. (in openscad I'd just calculate
it AGAIN)
Then calculate the distance between the two
d = sqrt ((xold-x)(xold-x)+(yold-y)(yold-y)+(zold-z)*(zold-z));
and then put
if (d > mindist)
in front of the sphere.
If you want ONE spiral, I'd have just one variable theta run from 0 to
360 * number of loops around the sphere.
Roger.
--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 **
f equals m times a. When your f is steady, and your m is going down
your a is going up. -- Chris Hadfield about flying up the space shuttle.
On Tue, Feb 28, 2023 at 12:58:24PM -0500, jon wrote:
> Rogier:
>
> Your algorithm is exactly what I had in mind. Can you code this in
> OpenSCAD? Your description (and mine) seem too procedural, with various
> variables (like r, rho, theta and oldR, oldRho, and oldTheta) assuming a
> variety of values as the calculation proceeds, which is challenging in
> OpenSCAD (where most "variables" are constants).
In a procedural language, you'd optimize by keeping assigning oldrho =
rho; etc just before the loop goes to the next one.
in openscad you just calculate the old one based on <loopvariable-1> .
Oh.... My suggestion doesn't work if you need to skip more than one
sphere. :-(
Roger.
>
> Jon
>
> On 2/28/2023 12:39 PM, Rogier Wolff wrote:
> > On Tue, Feb 28, 2023 at 10:39:59AM -0500, jon wrote:
> > > I wrote some code to create a spiral of spheres around the surface of a
> > > larger sphere. It works fine, but the spacing is too tight near the poles.
> > >
> > > If I were writing in a "normal" language, I would calculate the position of
> > > each possible new sphere, then calculate the distance from that sphere to
> > > the most recently successfully placed sphere, and avoid placing the new one
> > > if the distance was too small. But I am writing in OpenSCAD, so that
> > > approach will not work; at least, I don't know how to do this in OpenSCAD.
> > You can do this in openscad.
> >
> > Just calculate x,y, z for the new point,
> > but also do this for the "last" point. (in openscad I'd just calculate
> > it AGAIN)
> >
> > Then calculate the distance between the two
> > d = sqrt ((xold-x)*(xold-x)+(yold-y)*(yold-y)+(zold-z)*(zold-z));
> >
> > and then put
> > if (d > mindist)
> >
> > in front of the sphere.
> >
> > If you want ONE spiral, I'd have just one variable theta run from 0 to
> > 360 * number of loops around the sphere.
> >
> > Roger.
> >
> >
--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 **
f equals m times a. When your f is steady, and your m is going down
your a is going up. -- Chris Hadfield about flying up the space shuttle.
JB
Jordan Brown
Tue, Feb 28, 2023 7:29 PM
I would think in terms of defining a function that describes the spiral
To my eye, Archimedean spirals start to degenerate during the center
loop, violating the constant-distance-between-loops behavior that you
see in the rest of the spiral. I would cope with that by either
skipping that loop, or by placing the dots there "by hand".
I think that what's going on in the center is that you're normally
looking at the distance from one loop to the next, 360° further
along the spiral, but in that innermost loop there *is* no loop
further in, and you're looking at the distance from one point to
another point that is closer than 360° away. Looking at the
Wikipedia page, the most extreme case looks like measuring from the
center point to the first time the spiral crosses the +Y axis.
That's only a quarter of a loop-to-loop distance, which looks really
small... and that's that because it's only 90° away, not 360°.
Now, I say that like I know how to do those things. I don't. I don't
know what an Archimedean spiral mapped onto a sphere really looks like.
I suspect that it is phi = a + b*theta, but I'd have to plot that out to
be sure. I have no idea how to measure the length of that path and no
idea how to find a particular point given a distance along the path.
(Well, other than iteratively, but that's just wrong.)
I would think in terms of defining a function that describes the spiral
- probably based on an Archimedean spiral
<https://en.wikipedia.org/wiki/Archimedean_spiral> - and then dividing
that path into N equal segments and placing a dot at each of those points.
To my eye, Archimedean spirals start to degenerate during the center
loop, violating the constant-distance-between-loops behavior that you
see in the rest of the spiral. I would cope with that by either
skipping that loop, or by placing the dots there "by hand".
I think that what's going on in the center is that you're normally
looking at the distance from one loop to the next, 360° further
along the spiral, but in that innermost loop there *is* no loop
further in, and you're looking at the distance from one point to
another point that is closer than 360° away. Looking at the
Wikipedia page, the most extreme case looks like measuring from the
center point to the first time the spiral crosses the +Y axis.
That's only a quarter of a loop-to-loop distance, which looks really
small... and that's that because it's only 90° away, not 360°.
Now, I say that like I know how to do those things. I don't. I don't
know what an Archimedean spiral mapped onto a sphere really looks like.
I suspect that it is phi = a + b*theta, but I'd have to plot that out to
be sure. I have no idea how to measure the length of that path and no
idea how to find a particular point given a distance along the path.
(Well, other than iteratively, but that's just wrong.)
FH
Father Horton
Tue, Feb 28, 2023 8:19 PM
In general, when you would loop in an imperative (a.k.a. "normal")
language, you either use list comprehensions or recursion in a
functional-esque language like OpenSCAD.
I don't think this is quite right, but it should get you close:
spirals = 7;
d = 25;
r = 100;
numspheres = 700;
step = PI * r / numspheres;
function dist(p1, p2) = norm([p1.x - p2.x, p1.y - p2.y, p1.z - p2.z]);
function points(rho, sofar) =
let (theta = (180 * (rho / numspheres)),
x = r * sin(theta) * cos(rho),
y = r * sin(theta) * sin(rho),
z = r * cos(theta),
dummy = echo(x, y, z, sofar),
ds = dist([x, y, z], sofar[0]))
rho > numspheres ? [] :
points(rho + step, ds > d ? concat([[x, y, z]], sofar): sofar);
pts = points(0, [[0, 0, r]]);
On Tue, Feb 28, 2023 at 1:30 PM Jordan Brown openscad@jordan.maileater.net
wrote:
I would think in terms of defining a function that describes the spiral -
probably based on an Archimedean spiral
https://en.wikipedia.org/wiki/Archimedean_spiral - and then dividing
that path into N equal segments and placing a dot at each of those points.
To my eye, Archimedean spirals start to degenerate during the center loop,
violating the constant-distance-between-loops behavior that you see in the
rest of the spiral. I would cope with that by either skipping that loop,
or by placing the dots there "by hand".
I think that what's going on in the center is that you're normally looking
at the distance from one loop to the next, 360° further along the spiral,
but in that innermost loop there is no loop further in, and you're
looking at the distance from one point to another point that is closer than
360° away. Looking at the Wikipedia page, the most extreme case looks like
measuring from the center point to the first time the spiral crosses the +Y
axis. That's only a quarter of a loop-to-loop distance, which looks really
small... and that's that because it's only 90° away, not 360°.
Now, I say that like I know how to do those things. I don't. I don't
know what an Archimedean spiral mapped onto a sphere really looks like. I
suspect that it is phi = a + b*theta, but I'd have to plot that out to be
sure. I have no idea how to measure the length of that path and no idea
how to find a particular point given a distance along the path. (Well,
other than iteratively, but that's just wrong.)
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
In general, when you would loop in an imperative (a.k.a. "normal")
language, you either use list comprehensions or recursion in a
functional-esque language like OpenSCAD.
I don't think this is quite right, but it should get you close:
spirals = 7;
d = 25;
r = 100;
numspheres = 700;
step = PI * r / numspheres;
function dist(p1, p2) = norm([p1.x - p2.x, p1.y - p2.y, p1.z - p2.z]);
function points(rho, sofar) =
let (theta = (180 * (rho / numspheres)),
x = r * sin(theta) * cos(rho),
y = r * sin(theta) * sin(rho),
z = r * cos(theta),
dummy = echo(x, y, z, sofar),
ds = dist([x, y, z], sofar[0]))
rho > numspheres ? [] :
points(rho + step, ds > d ? concat([[x, y, z]], sofar): sofar);
pts = points(0, [[0, 0, r]]);
On Tue, Feb 28, 2023 at 1:30 PM Jordan Brown <openscad@jordan.maileater.net>
wrote:
> I would think in terms of defining a function that describes the spiral -
> probably based on an Archimedean spiral
> <https://en.wikipedia.org/wiki/Archimedean_spiral> - and then dividing
> that path into N equal segments and placing a dot at each of those points.
>
> To my eye, Archimedean spirals start to degenerate during the center loop,
> violating the constant-distance-between-loops behavior that you see in the
> rest of the spiral. I would cope with that by either skipping that loop,
> or by placing the dots there "by hand".
>
> I think that what's going on in the center is that you're normally looking
> at the distance from one loop to the next, 360° further along the spiral,
> but in that innermost loop there *is* no loop further in, and you're
> looking at the distance from one point to another point that is closer than
> 360° away. Looking at the Wikipedia page, the most extreme case looks like
> measuring from the center point to the first time the spiral crosses the +Y
> axis. That's only a quarter of a loop-to-loop distance, which looks really
> small... and that's that because it's only 90° away, not 360°.
>
> Now, I say that like I know how to do those things. I don't. I don't
> know what an Archimedean spiral mapped onto a sphere really looks like. I
> suspect that it is phi = a + b*theta, but I'd have to plot that out to be
> sure. I have no idea how to measure the length of that path and no idea
> how to find a particular point given a distance along the path. (Well,
> other than iteratively, but that's just wrong.)
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
FH
Father Horton
Tue, Feb 28, 2023 8:28 PM
Oops. Minor fix:
rho > numspheres ? [] :
Should be
rho > numspheres ? sofar :
And you can take out the echo.
On Tue, Feb 28, 2023 at 2:19 PM Father Horton fatherhorton@gmail.com
wrote:
In general, when you would loop in an imperative (a.k.a. "normal")
language, you either use list comprehensions or recursion in a
functional-esque language like OpenSCAD.
I don't think this is quite right, but it should get you close:
spirals = 7;
d = 25;
r = 100;
numspheres = 700;
step = PI * r / numspheres;
function dist(p1, p2) = norm([p1.x - p2.x, p1.y - p2.y, p1.z - p2.z]);
function points(rho, sofar) =
let (theta = (180 * (rho / numspheres)),
x = r * sin(theta) * cos(rho),
y = r * sin(theta) * sin(rho),
z = r * cos(theta),
dummy = echo(x, y, z, sofar),
ds = dist([x, y, z], sofar[0]))
rho > numspheres ? [] :
points(rho + step, ds > d ? concat([[x, y, z]], sofar): sofar);
pts = points(0, [[0, 0, r]]);
On Tue, Feb 28, 2023 at 1:30 PM Jordan Brown <
openscad@jordan.maileater.net> wrote:
I would think in terms of defining a function that describes the spiral -
probably based on an Archimedean spiral
https://en.wikipedia.org/wiki/Archimedean_spiral - and then dividing
that path into N equal segments and placing a dot at each of those points.
To my eye, Archimedean spirals start to degenerate during the center
loop, violating the constant-distance-between-loops behavior that you see
in the rest of the spiral. I would cope with that by either skipping that
loop, or by placing the dots there "by hand".
I think that what's going on in the center is that you're normally
looking at the distance from one loop to the next, 360° further along the
spiral, but in that innermost loop there is no loop further in, and
you're looking at the distance from one point to another point that is
closer than 360° away. Looking at the Wikipedia page, the most extreme
case looks like measuring from the center point to the first time the
spiral crosses the +Y axis. That's only a quarter of a loop-to-loop
distance, which looks really small... and that's that because it's only 90°
away, not 360°.
Now, I say that like I know how to do those things. I don't. I don't
know what an Archimedean spiral mapped onto a sphere really looks like. I
suspect that it is phi = a + b*theta, but I'd have to plot that out to be
sure. I have no idea how to measure the length of that path and no idea
how to find a particular point given a distance along the path. (Well,
other than iteratively, but that's just wrong.)
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Oops. Minor fix:
rho > numspheres ? [] :
Should be
rho > numspheres ? sofar :
And you can take out the echo.
On Tue, Feb 28, 2023 at 2:19 PM Father Horton <fatherhorton@gmail.com>
wrote:
> In general, when you would loop in an imperative (a.k.a. "normal")
> language, you either use list comprehensions or recursion in a
> functional-esque language like OpenSCAD.
>
> I don't think this is quite right, but it should get you close:
>
> spirals = 7;
>
> d = 25;
> r = 100;
> numspheres = 700;
> step = PI * r / numspheres;
>
> function dist(p1, p2) = norm([p1.x - p2.x, p1.y - p2.y, p1.z - p2.z]);
>
> function points(rho, sofar) =
> let (theta = (180 * (rho / numspheres)),
> x = r * sin(theta) * cos(rho),
> y = r * sin(theta) * sin(rho),
> z = r * cos(theta),
> dummy = echo(x, y, z, sofar),
> ds = dist([x, y, z], sofar[0]))
> rho > numspheres ? [] :
> points(rho + step, ds > d ? concat([[x, y, z]], sofar): sofar);
>
> pts = points(0, [[0, 0, r]]);
>
>
>
> On Tue, Feb 28, 2023 at 1:30 PM Jordan Brown <
> openscad@jordan.maileater.net> wrote:
>
>> I would think in terms of defining a function that describes the spiral -
>> probably based on an Archimedean spiral
>> <https://en.wikipedia.org/wiki/Archimedean_spiral> - and then dividing
>> that path into N equal segments and placing a dot at each of those points.
>>
>> To my eye, Archimedean spirals start to degenerate during the center
>> loop, violating the constant-distance-between-loops behavior that you see
>> in the rest of the spiral. I would cope with that by either skipping that
>> loop, or by placing the dots there "by hand".
>>
>> I think that what's going on in the center is that you're normally
>> looking at the distance from one loop to the next, 360° further along the
>> spiral, but in that innermost loop there *is* no loop further in, and
>> you're looking at the distance from one point to another point that is
>> closer than 360° away. Looking at the Wikipedia page, the most extreme
>> case looks like measuring from the center point to the first time the
>> spiral crosses the +Y axis. That's only a quarter of a loop-to-loop
>> distance, which looks really small... and that's that because it's only 90°
>> away, not 360°.
>>
>> Now, I say that like I know how to do those things. I don't. I don't
>> know what an Archimedean spiral mapped onto a sphere really looks like. I
>> suspect that it is phi = a + b*theta, but I'd have to plot that out to be
>> sure. I have no idea how to measure the length of that path and no idea
>> how to find a particular point given a distance along the path. (Well,
>> other than iteratively, but that's just wrong.)
>>
>> _______________________________________________
>> OpenSCAD mailing list
>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>
>
AM
Adrian Mariano
Tue, Feb 28, 2023 9:15 PM
I would think in terms of defining a function that describes the spiral -
probably based on an Archimedean spiral
https://en.wikipedia.org/wiki/Archimedean_spiral - and then dividing
that path into N equal segments and placing a dot at each of those points.
To my eye, Archimedean spirals start to degenerate during the center loop,
violating the constant-distance-between-loops behavior that you see in the
rest of the spiral. I would cope with that by either skipping that loop,
or by placing the dots there "by hand".
I think that what's going on in the center is that you're normally looking
at the distance from one loop to the next, 360° further along the spiral,
but in that innermost loop there is no loop further in, and you're
looking at the distance from one point to another point that is closer than
360° away. Looking at the Wikipedia page, the most extreme case looks like
measuring from the center point to the first time the spiral crosses the +Y
axis. That's only a quarter of a loop-to-loop distance, which looks really
small... and that's that because it's only 90° away, not 360°.
Now, I say that like I know how to do those things. I don't. I don't
know what an Archimedean spiral mapped onto a sphere really looks like. I
suspect that it is phi = a + b*theta, but I'd have to plot that out to be
sure. I have no idea how to measure the length of that path and no idea
how to find a particular point given a distance along the path. (Well,
other than iteratively, but that's just wrong.)
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
BOSL2 implements this using the "Golden Spiral Method". You could use
that...or read the code.
https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-sphere_copies
On Tue, Feb 28, 2023 at 2:30 PM Jordan Brown <openscad@jordan.maileater.net>
wrote:
> I would think in terms of defining a function that describes the spiral -
> probably based on an Archimedean spiral
> <https://en.wikipedia.org/wiki/Archimedean_spiral> - and then dividing
> that path into N equal segments and placing a dot at each of those points.
>
> To my eye, Archimedean spirals start to degenerate during the center loop,
> violating the constant-distance-between-loops behavior that you see in the
> rest of the spiral. I would cope with that by either skipping that loop,
> or by placing the dots there "by hand".
>
> I think that what's going on in the center is that you're normally looking
> at the distance from one loop to the next, 360° further along the spiral,
> but in that innermost loop there *is* no loop further in, and you're
> looking at the distance from one point to another point that is closer than
> 360° away. Looking at the Wikipedia page, the most extreme case looks like
> measuring from the center point to the first time the spiral crosses the +Y
> axis. That's only a quarter of a loop-to-loop distance, which looks really
> small... and that's that because it's only 90° away, not 360°.
>
> Now, I say that like I know how to do those things. I don't. I don't
> know what an Archimedean spiral mapped onto a sphere really looks like. I
> suspect that it is phi = a + b*theta, but I'd have to plot that out to be
> sure. I have no idea how to measure the length of that path and no idea
> how to find a particular point given a distance along the path. (Well,
> other than iteratively, but that's just wrong.)
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
RD
Revar Desmera
Tue, Feb 28, 2023 9:55 PM
If you already have the path, then you can use BOSL2’s path_copies()
to get an equidistant spread of items along that path.
distributors.scad
github.com
-Revar
On Feb 28, 2023, at 7:40 AM, jon <jon@jonbondy.com> wrote:
I wrote some code to create a spiral of spheres around the surface of a larger sphere. It works fine, but the spacing is too tight near the poles.
If I were writing in a "normal" language, I would calculate the position of each possible new sphere, then calculate the distance from that sphere to the most recently successfully placed sphere, and avoid placing the new one if the distance was too small. But I am writing in OpenSCAD, so that approach will not work; at least, I don't know how to do this in OpenSCAD.
Any thoughts?
function x(r, theta, rho) = r * sin(theta) * cos(rho);
function y(r, theta, rho) = r * sin(theta) * sin(rho);
function z(r, theta, rho) = r * cos(theta);
sphereD = 5;
numRots = 7;
numSpheres = numRots * 360;
r = 100;
for (rho = [0:5:numSpheres])
let (theta = (180 * (rho / numSpheres)))
translate([x(r, theta, rho), y(r, theta, rho), z(r, theta, rho)])
sphere(d = sphereD);
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
J
jon
Tue, Feb 28, 2023 10:35 PM
Thank you, Revar!
When I do this
include <BOSL2/std.scad>
include <BOSL2/distributors.scad>
then I get the error
WARNING: Ignoring unknown module 'path_copies' in file xxx.scad, line 43
which is
path_copies(path, n = 100) sphere(d = bigDi/10);
Do I have the wrong includes?
Jon
On 2/28/2023 4:55 PM, Revar Desmera wrote:
On Feb 28, 2023, at 7:40 AM, jon jon@jonbondy.com wrote:
I wrote some code to create a spiral of spheres around the surface
of a larger sphere. It works fine, but the spacing is too tight near
the poles.
If I were writing in a "normal" language, I would calculate the
position of each possible new sphere, then calculate the distance
from that sphere to the most recently successfully placed sphere, and
avoid placing the new one if the distance was too small. But I am
writing in OpenSCAD, so that approach will not work; at least, I
don't know how to do this in OpenSCAD.
Any thoughts?
function x(r, theta, rho) = r * sin(theta) * cos(rho);
function y(r, theta, rho) = r * sin(theta) * sin(rho);
function z(r, theta, rho) = r * cos(theta);
sphereD = 5;
numRots = 7;
numSpheres = numRots * 360;
r = 100;
for (rho = [0:5:numSpheres])
let (theta = (180 * (rho / numSpheres)))
translate([x(r, theta, rho), y(r, theta, rho), z(r, theta, rho)])
sphere(d = sphereD);
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Thank you, Revar!
When I do this
include <BOSL2/std.scad>
include <BOSL2/distributors.scad>
then I get the error
WARNING: Ignoring unknown module 'path_copies' in file xxx.scad, line 43
which is
path_copies(path, n = 100) sphere(d = bigDi/10);
Do I have the wrong includes?
Jon
On 2/28/2023 4:55 PM, Revar Desmera wrote:
> If you already have the path, then you can use BOSL2’s `path_copies()`
> to get an equidistant spread of items along that path.
>
> 7f60f080-3992-11eb-9baf-22e99510b07f.png
> distributors.scad
> <https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
> github.com
> <https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
>
> <https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
>
> -Revar
>
>
>> On Feb 28, 2023, at 7:40 AM, jon <jon@jonbondy.com> wrote:
>>
>> I wrote some code to create a spiral of spheres around the surface
>> of a larger sphere. It works fine, but the spacing is too tight near
>> the poles.
>>
>> If I were writing in a "normal" language, I would calculate the
>> position of each possible new sphere, then calculate the distance
>> from that sphere to the most recently successfully placed sphere, and
>> avoid placing the new one if the distance was too small. But I am
>> writing in OpenSCAD, so that approach will not work; at least, I
>> don't know how to do this in OpenSCAD.
>>
>> Any thoughts?
>>
>>
>>
>> function x(r, theta, rho) = r * sin(theta) * cos(rho);
>> function y(r, theta, rho) = r * sin(theta) * sin(rho);
>> function z(r, theta, rho) = r * cos(theta);
>>
>> sphereD = 5;
>> numRots = 7;
>> numSpheres = numRots * 360;
>> r = 100;
>> for (rho = [0:5:numSpheres])
>> let (theta = (180 * (rho / numSpheres)))
>> translate([x(r, theta, rho), y(r, theta, rho), z(r, theta, rho)])
>> sphere(d = sphereD);
>> _______________________________________________
>> OpenSCAD mailing list
>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email todiscuss-leave@lists.openscad.org
AM
Adrian Mariano
Tue, Feb 28, 2023 10:40 PM
I assumed that he really wants a nice result on the sphere. The
path_copies() module implements something like what nophead
suggested----his suggestion, by the way, is really kind of nontrivial to
implement.
On Tue, Feb 28, 2023 at 5:12 PM Revar Desmera revarbat@gmail.com wrote:
If you already have the path, then you can use BOSL2’s path_copies()
to
get an equidistant spread of items along that path.
[image: 7f60f080-3992-11eb-9baf-22e99510b07f.png]
distributors.scad
https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies
github.com
https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies
https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies
-Revar
On Feb 28, 2023, at 7:40 AM, jon jon@jonbondy.com wrote:
I wrote some code to create a spiral of spheres around the surface of a
larger sphere. It works fine, but the spacing is too tight near the poles.
If I were writing in a "normal" language, I would calculate the position
of each possible new sphere, then calculate the distance from that sphere
to the most recently successfully placed sphere, and avoid placing the new
one if the distance was too small. But I am writing in OpenSCAD, so that
approach will not work; at least, I don't know how to do this in OpenSCAD.
Any thoughts?
function x(r, theta, rho) = r * sin(theta) * cos(rho);
function y(r, theta, rho) = r * sin(theta) * sin(rho);
function z(r, theta, rho) = r * cos(theta);
sphereD = 5;
numRots = 7;
numSpheres = numRots * 360;
r = 100;
for (rho = [0:5:numSpheres])
let (theta = (180 * (rho / numSpheres)))
translate([x(r, theta, rho), y(r, theta, rho), z(r, theta, rho)])
sphere(d = sphereD);
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
I assumed that he really wants a nice result on the sphere. The
path_copies() module implements something like what nophead
suggested----his suggestion, by the way, is really kind of nontrivial to
implement.
On Tue, Feb 28, 2023 at 5:12 PM Revar Desmera <revarbat@gmail.com> wrote:
> If you already have the path, then you can use BOSL2’s `path_copies()` to
> get an equidistant spread of items along that path.
>
> [image: 7f60f080-3992-11eb-9baf-22e99510b07f.png]
>
> distributors.scad
> <https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
> github.com
> <https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
>
> <https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
>
> -Revar
>
>
> On Feb 28, 2023, at 7:40 AM, jon <jon@jonbondy.com> wrote:
>
> I wrote some code to create a spiral of spheres around the surface of a
> larger sphere. It works fine, but the spacing is too tight near the poles.
>
> If I were writing in a "normal" language, I would calculate the position
> of each possible new sphere, then calculate the distance from that sphere
> to the most recently successfully placed sphere, and avoid placing the new
> one if the distance was too small. But I am writing in OpenSCAD, so that
> approach will not work; at least, I don't know how to do this in OpenSCAD.
>
> Any thoughts?
>
>
>
> function x(r, theta, rho) = r * sin(theta) * cos(rho);
> function y(r, theta, rho) = r * sin(theta) * sin(rho);
> function z(r, theta, rho) = r * cos(theta);
>
> sphereD = 5;
> numRots = 7;
> numSpheres = numRots * 360;
> r = 100;
> for (rho = [0:5:numSpheres])
> let (theta = (180 * (rho / numSpheres)))
> translate([x(r, theta, rho), y(r, theta, rho), z(r, theta, rho)])
> sphere(d = sphereD);
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
AM
Adrian Mariano
Tue, Feb 28, 2023 10:43 PM
You only need std.scad. Probably you need to update BOSL2.
On Tue, Feb 28, 2023 at 5:39 PM jon jon@jonbondy.com wrote:
Thank you, Revar!
When I do this
include <BOSL2/std.scad>
include <BOSL2/distributors.scad>
then I get the error
WARNING: Ignoring unknown module 'path_copies' in file xxx.scad, line 43
which is
path_copies(path, n = 100) sphere(d = bigDi/10);
Do I have the wrong includes?
Jon
On 2/28/2023 4:55 PM, Revar Desmera wrote:
If you already have the path, then you can use BOSL2’s path_copies()
to
get an equidistant spread of items along that path.
[image: 7f60f080-3992-11eb-9baf-22e99510b07f.png]
distributors.scad
https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies
github.com
https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies
https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies
-Revar
On Feb 28, 2023, at 7:40 AM, jon jon@jonbondy.com jon@jonbondy.com
wrote:
I wrote some code to create a spiral of spheres around the surface of a
larger sphere. It works fine, but the spacing is too tight near the poles.
If I were writing in a "normal" language, I would calculate the position
of each possible new sphere, then calculate the distance from that sphere
to the most recently successfully placed sphere, and avoid placing the new
one if the distance was too small. But I am writing in OpenSCAD, so that
approach will not work; at least, I don't know how to do this in OpenSCAD.
Any thoughts?
function x(r, theta, rho) = r * sin(theta) * cos(rho);
function y(r, theta, rho) = r * sin(theta) * sin(rho);
function z(r, theta, rho) = r * cos(theta);
sphereD = 5;
numRots = 7;
numSpheres = numRots * 360;
r = 100;
for (rho = [0:5:numSpheres])
let (theta = (180 * (rho / numSpheres)))
translate([x(r, theta, rho), y(r, theta, rho), z(r, theta, rho)])
sphere(d = sphereD);
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
You only need std.scad. Probably you need to update BOSL2.
On Tue, Feb 28, 2023 at 5:39 PM jon <jon@jonbondy.com> wrote:
> Thank you, Revar!
>
> When I do this
>
> include <BOSL2/std.scad>
> include <BOSL2/distributors.scad>
>
> then I get the error
>
> WARNING: Ignoring unknown module 'path_copies' in file xxx.scad, line 43
>
> which is
>
> path_copies(path, n = 100) sphere(d = bigDi/10);
>
> Do I have the wrong includes?
>
> Jon
>
>
> On 2/28/2023 4:55 PM, Revar Desmera wrote:
>
> If you already have the path, then you can use BOSL2’s `path_copies()` to
> get an equidistant spread of items along that path.
>
> [image: 7f60f080-3992-11eb-9baf-22e99510b07f.png]
>
> distributors.scad
> <https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
> github.com
> <https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
>
> <https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
>
> -Revar
>
>
> On Feb 28, 2023, at 7:40 AM, jon <jon@jonbondy.com> <jon@jonbondy.com>
> wrote:
>
> I wrote some code to create a spiral of spheres around the surface of a
> larger sphere. It works fine, but the spacing is too tight near the poles.
>
> If I were writing in a "normal" language, I would calculate the position
> of each possible new sphere, then calculate the distance from that sphere
> to the most recently successfully placed sphere, and avoid placing the new
> one if the distance was too small. But I am writing in OpenSCAD, so that
> approach will not work; at least, I don't know how to do this in OpenSCAD.
>
> Any thoughts?
>
>
>
> function x(r, theta, rho) = r * sin(theta) * cos(rho);
> function y(r, theta, rho) = r * sin(theta) * sin(rho);
> function z(r, theta, rho) = r * cos(theta);
>
> sphereD = 5;
> numRots = 7;
> numSpheres = numRots * 360;
> r = 100;
> for (rho = [0:5:numSpheres])
> let (theta = (180 * (rho / numSpheres)))
> translate([x(r, theta, rho), y(r, theta, rho), z(r, theta, rho)])
> sphere(d = sphereD);
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
J
jon
Tue, Feb 28, 2023 11:18 PM
Yes. Updated the library, and the path_copies() approach worked perfectly!
I love that BOSL2 library!
Jon
On 2/28/2023 5:43 PM, Adrian Mariano wrote:
You only need std.scad. Probably you need to update BOSL2.
On Tue, Feb 28, 2023 at 5:39 PM jon jon@jonbondy.com wrote:
Thank you, Revar!
When I do this
include <BOSL2/std.scad>
include <BOSL2/distributors.scad>
then I get the error
WARNING: Ignoring unknown module 'path_copies' in file xxx.scad,
line 43
which is
path_copies(path, n = 100) sphere(d = bigDi/10);
Do I have the wrong includes?
Jon
On 2/28/2023 4:55 PM, Revar Desmera wrote:
If you already have the path, then you can use BOSL2’s
`path_copies()` to get an equidistant spread of items along that
path.
7f60f080-3992-11eb-9baf-22e99510b07f.png
distributors.scad
<https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
github.com
<https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
<https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
-Revar
On Feb 28, 2023, at 7:40 AM, jon <jon@jonbondy.com>
<mailto:jon@jonbondy.com> wrote:
I wrote some code to create a spiral of spheres around the
surface of a larger sphere. It works fine, but the spacing is
too tight near the poles.
If I were writing in a "normal" language, I would calculate the
position of each possible new sphere, then calculate the
distance from that sphere to the most recently successfully
placed sphere, and avoid placing the new one if the distance was
too small. But I am writing in OpenSCAD, so that approach will
not work; at least, I don't know how to do this in OpenSCAD.
Any thoughts?
function x(r, theta, rho) = r * sin(theta) * cos(rho);
function y(r, theta, rho) = r * sin(theta) * sin(rho);
function z(r, theta, rho) = r * cos(theta);
sphereD = 5;
numRots = 7;
numSpheres = numRots * 360;
r = 100;
for (rho = [0:5:numSpheres])
let (theta = (180 * (rho / numSpheres)))
translate([x(r, theta, rho), y(r, theta, rho), z(r,
theta, rho)])
sphere(d = sphereD);
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org
Yes. Updated the library, and the path_copies() approach worked perfectly!
I love that BOSL2 library!
Jon
On 2/28/2023 5:43 PM, Adrian Mariano wrote:
> You only need std.scad. Probably you need to update BOSL2.
>
> On Tue, Feb 28, 2023 at 5:39 PM jon <jon@jonbondy.com> wrote:
>
> Thank you, Revar!
>
> When I do this
>
> include <BOSL2/std.scad>
> include <BOSL2/distributors.scad>
>
> then I get the error
>
> WARNING: Ignoring unknown module 'path_copies' in file xxx.scad,
> line 43
>
> which is
>
> path_copies(path, n = 100) sphere(d = bigDi/10);
>
> Do I have the wrong includes?
>
> Jon
>
>
> On 2/28/2023 4:55 PM, Revar Desmera wrote:
>> If you already have the path, then you can use BOSL2’s
>> `path_copies()` to get an equidistant spread of items along that
>> path.
>>
>> 7f60f080-3992-11eb-9baf-22e99510b07f.png
>> distributors.scad
>> <https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
>> github.com
>> <https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
>>
>> <https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
>>
>> -Revar
>>
>>
>>> On Feb 28, 2023, at 7:40 AM, jon <jon@jonbondy.com>
>>> <mailto:jon@jonbondy.com> wrote:
>>>
>>> I wrote some code to create a spiral of spheres around the
>>> surface of a larger sphere. It works fine, but the spacing is
>>> too tight near the poles.
>>>
>>> If I were writing in a "normal" language, I would calculate the
>>> position of each possible new sphere, then calculate the
>>> distance from that sphere to the most recently successfully
>>> placed sphere, and avoid placing the new one if the distance was
>>> too small. But I am writing in OpenSCAD, so that approach will
>>> not work; at least, I don't know how to do this in OpenSCAD.
>>>
>>> Any thoughts?
>>>
>>>
>>>
>>> function x(r, theta, rho) = r * sin(theta) * cos(rho);
>>> function y(r, theta, rho) = r * sin(theta) * sin(rho);
>>> function z(r, theta, rho) = r * cos(theta);
>>>
>>> sphereD = 5;
>>> numRots = 7;
>>> numSpheres = numRots * 360;
>>> r = 100;
>>> for (rho = [0:5:numSpheres])
>>> let (theta = (180 * (rho / numSpheres)))
>>> translate([x(r, theta, rho), y(r, theta, rho), z(r,
>>> theta, rho)])
>>> sphere(d = sphereD);
>>> _______________________________________________
>>> OpenSCAD mailing list
>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>
>> _______________________________________________
>> OpenSCAD mailing list
>> To unsubscribe send an email todiscuss-leave@lists.openscad.org
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email todiscuss-leave@lists.openscad.org
SP
Sanjeev Prabhakar
Wed, Mar 1, 2023 4:42 PM
is this what you were trying to do?
[image: Screenshot 2023-03-01 at 10.00.00 PM.png]
I did this with a slightly different approach.
steps:
- created a normal helix
- connected all helix points with the center line z-axis, so that all the
lines are parallel to x-y plane
- found intersection of the lines with sphere. This gives the helical path
along the sphere surface
- Divided the path in equally spaced points.
- translated spheres with diameter equal to the length between each point
On Wed, 1 Mar 2023 at 04:49, jon jon@jonbondy.com wrote:
Yes. Updated the library, and the path_copies() approach worked perfectly!
I love that BOSL2 library!
Jon
On 2/28/2023 5:43 PM, Adrian Mariano wrote:
You only need std.scad. Probably you need to update BOSL2.
On Tue, Feb 28, 2023 at 5:39 PM jon jon@jonbondy.com wrote:
Thank you, Revar!
When I do this
include <BOSL2/std.scad>
include <BOSL2/distributors.scad>
then I get the error
WARNING: Ignoring unknown module 'path_copies' in file xxx.scad, line 43
which is
path_copies(path, n = 100) sphere(d = bigDi/10);
Do I have the wrong includes?
Jon
On 2/28/2023 4:55 PM, Revar Desmera wrote:
If you already have the path, then you can use BOSL2’s path_copies()
to
get an equidistant spread of items along that path.
[image: 7f60f080-3992-11eb-9baf-22e99510b07f.png]
distributors.scad
https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies
github.com
https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies
https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies
-Revar
On Feb 28, 2023, at 7:40 AM, jon jon@jonbondy.com jon@jonbondy.com
wrote:
I wrote some code to create a spiral of spheres around the surface of a
larger sphere. It works fine, but the spacing is too tight near the poles.
If I were writing in a "normal" language, I would calculate the position
of each possible new sphere, then calculate the distance from that sphere
to the most recently successfully placed sphere, and avoid placing the new
one if the distance was too small. But I am writing in OpenSCAD, so that
approach will not work; at least, I don't know how to do this in OpenSCAD.
Any thoughts?
function x(r, theta, rho) = r * sin(theta) * cos(rho);
function y(r, theta, rho) = r * sin(theta) * sin(rho);
function z(r, theta, rho) = r * cos(theta);
sphereD = 5;
numRots = 7;
numSpheres = numRots * 360;
r = 100;
for (rho = [0:5:numSpheres])
let (theta = (180 * (rho / numSpheres)))
translate([x(r, theta, rho), y(r, theta, rho), z(r, theta, rho)])
sphere(d = sphereD);
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
is this what you were trying to do?
[image: Screenshot 2023-03-01 at 10.00.00 PM.png]
I did this with a slightly different approach.
steps:
1. created a normal helix
2. connected all helix points with the center line z-axis, so that all the
lines are parallel to x-y plane
3. found intersection of the lines with sphere. This gives the helical path
along the sphere surface
4. Divided the path in equally spaced points.
5. translated spheres with diameter equal to the length between each point
On Wed, 1 Mar 2023 at 04:49, jon <jon@jonbondy.com> wrote:
> Yes. Updated the library, and the path_copies() approach worked perfectly!
>
> I love that BOSL2 library!
>
> Jon
> On 2/28/2023 5:43 PM, Adrian Mariano wrote:
>
> You only need std.scad. Probably you need to update BOSL2.
>
> On Tue, Feb 28, 2023 at 5:39 PM jon <jon@jonbondy.com> wrote:
>
>> Thank you, Revar!
>>
>> When I do this
>>
>> include <BOSL2/std.scad>
>> include <BOSL2/distributors.scad>
>>
>> then I get the error
>>
>> WARNING: Ignoring unknown module 'path_copies' in file xxx.scad, line 43
>>
>> which is
>>
>> path_copies(path, n = 100) sphere(d = bigDi/10);
>>
>> Do I have the wrong includes?
>>
>> Jon
>>
>>
>> On 2/28/2023 4:55 PM, Revar Desmera wrote:
>>
>> If you already have the path, then you can use BOSL2’s `path_copies()` to
>> get an equidistant spread of items along that path.
>>
>> [image: 7f60f080-3992-11eb-9baf-22e99510b07f.png]
>>
>> distributors.scad
>> <https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
>> github.com
>> <https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
>>
>> <https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
>>
>> -Revar
>>
>>
>> On Feb 28, 2023, at 7:40 AM, jon <jon@jonbondy.com> <jon@jonbondy.com>
>> wrote:
>>
>> I wrote some code to create a spiral of spheres around the surface of a
>> larger sphere. It works fine, but the spacing is too tight near the poles.
>>
>> If I were writing in a "normal" language, I would calculate the position
>> of each possible new sphere, then calculate the distance from that sphere
>> to the most recently successfully placed sphere, and avoid placing the new
>> one if the distance was too small. But I am writing in OpenSCAD, so that
>> approach will not work; at least, I don't know how to do this in OpenSCAD.
>>
>> Any thoughts?
>>
>>
>>
>> function x(r, theta, rho) = r * sin(theta) * cos(rho);
>> function y(r, theta, rho) = r * sin(theta) * sin(rho);
>> function z(r, theta, rho) = r * cos(theta);
>>
>> sphereD = 5;
>> numRots = 7;
>> numSpheres = numRots * 360;
>> r = 100;
>> for (rho = [0:5:numSpheres])
>> let (theta = (180 * (rho / numSpheres)))
>> translate([x(r, theta, rho), y(r, theta, rho), z(r, theta, rho)])
>> sphere(d = sphereD);
>> _______________________________________________
>> OpenSCAD mailing list
>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>
>>
>> _______________________________________________
>> OpenSCAD mailing list
>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>
>> _______________________________________________
>> OpenSCAD mailing list
>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
J
jon
Wed, Mar 1, 2023 5:21 PM
Yes, Sanjeev, that was my objective. Basically a single line of
additional code using BOSL2
Jon
On 3/1/2023 11:42 AM, Sanjeev Prabhakar wrote:
is this what you were trying to do?
Screenshot 2023-03-01 at 10.00.00 PM.png
I did this with a slightly different approach.
steps:
- created a normal helix
- connected all helix points with the center line z-axis, so that all
the lines are parallel to x-y plane
- found intersection of the lines with sphere. This gives the helical
path along the sphere surface
- Divided the path in equally spaced points.
- translated spheres with diameter equal to the length between each point
On Wed, 1 Mar 2023 at 04:49, jon jon@jonbondy.com wrote:
Yes. Updated the library, and the path_copies() approach worked
perfectly!
I love that BOSL2 library!
Jon
On 2/28/2023 5:43 PM, Adrian Mariano wrote:
You only need std.scad. Probably you need to update BOSL2.
On Tue, Feb 28, 2023 at 5:39 PM jon <jon@jonbondy.com> wrote:
Thank you, Revar!
When I do this
include <BOSL2/std.scad>
include <BOSL2/distributors.scad>
then I get the error
WARNING: Ignoring unknown module 'path_copies' in file
xxx.scad, line 43
which is
path_copies(path, n = 100) sphere(d = bigDi/10);
Do I have the wrong includes?
Jon
On 2/28/2023 4:55 PM, Revar Desmera wrote:
If you already have the path, then you can use BOSL2’s
`path_copies()` to get an equidistant spread of items along
that path.
7f60f080-3992-11eb-9baf-22e99510b07f.png
distributors.scad
<https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
github.com
<https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
<https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
-Revar
On Feb 28, 2023, at 7:40 AM, jon <jon@jonbondy.com>
<mailto:jon@jonbondy.com> wrote:
I wrote some code to create a spiral of spheres around the
surface of a larger sphere. It works fine, but the spacing
is too tight near the poles.
If I were writing in a "normal" language, I would calculate
the position of each possible new sphere, then calculate
the distance from that sphere to the most recently
successfully placed sphere, and avoid placing the new one
if the distance was too small. But I am writing in
OpenSCAD, so that approach will not work; at least, I don't
know how to do this in OpenSCAD.
Any thoughts?
function x(r, theta, rho) = r * sin(theta) * cos(rho);
function y(r, theta, rho) = r * sin(theta) * sin(rho);
function z(r, theta, rho) = r * cos(theta);
sphereD = 5;
numRots = 7;
numSpheres = numRots * 360;
r = 100;
for (rho = [0:5:numSpheres])
let (theta = (180 * (rho / numSpheres)))
translate([x(r, theta, rho), y(r, theta, rho), z(r,
theta, rho)])
sphere(d = sphereD);
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to
discuss-leave@lists.openscad.org
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org
Yes, Sanjeev, that was my objective. Basically a single line of
additional code using BOSL2
Jon
On 3/1/2023 11:42 AM, Sanjeev Prabhakar wrote:
> is this what you were trying to do?
> Screenshot 2023-03-01 at 10.00.00 PM.png
>
> I did this with a slightly different approach.
> steps:
> 1. created a normal helix
> 2. connected all helix points with the center line z-axis, so that all
> the lines are parallel to x-y plane
> 3. found intersection of the lines with sphere. This gives the helical
> path along the sphere surface
> 4. Divided the path in equally spaced points.
> 5. translated spheres with diameter equal to the length between each point
>
>
>
> On Wed, 1 Mar 2023 at 04:49, jon <jon@jonbondy.com> wrote:
>
> Yes. Updated the library, and the path_copies() approach worked
> perfectly!
>
> I love that BOSL2 library!
>
> Jon
>
> On 2/28/2023 5:43 PM, Adrian Mariano wrote:
>> You only need std.scad. Probably you need to update BOSL2.
>>
>> On Tue, Feb 28, 2023 at 5:39 PM jon <jon@jonbondy.com> wrote:
>>
>> Thank you, Revar!
>>
>> When I do this
>>
>> include <BOSL2/std.scad>
>> include <BOSL2/distributors.scad>
>>
>> then I get the error
>>
>> WARNING: Ignoring unknown module 'path_copies' in file
>> xxx.scad, line 43
>>
>> which is
>>
>> path_copies(path, n = 100) sphere(d = bigDi/10);
>>
>> Do I have the wrong includes?
>>
>> Jon
>>
>>
>> On 2/28/2023 4:55 PM, Revar Desmera wrote:
>>> If you already have the path, then you can use BOSL2’s
>>> `path_copies()` to get an equidistant spread of items along
>>> that path.
>>>
>>> 7f60f080-3992-11eb-9baf-22e99510b07f.png
>>> distributors.scad
>>> <https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
>>> github.com
>>> <https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
>>>
>>> <https://github.com/revarbat/BOSL2/wiki/distributors.scad#functionmodule-path_copies>
>>>
>>> -Revar
>>>
>>>
>>>> On Feb 28, 2023, at 7:40 AM, jon <jon@jonbondy.com>
>>>> <mailto:jon@jonbondy.com> wrote:
>>>>
>>>> I wrote some code to create a spiral of spheres around the
>>>> surface of a larger sphere. It works fine, but the spacing
>>>> is too tight near the poles.
>>>>
>>>> If I were writing in a "normal" language, I would calculate
>>>> the position of each possible new sphere, then calculate
>>>> the distance from that sphere to the most recently
>>>> successfully placed sphere, and avoid placing the new one
>>>> if the distance was too small. But I am writing in
>>>> OpenSCAD, so that approach will not work; at least, I don't
>>>> know how to do this in OpenSCAD.
>>>>
>>>> Any thoughts?
>>>>
>>>>
>>>>
>>>> function x(r, theta, rho) = r * sin(theta) * cos(rho);
>>>> function y(r, theta, rho) = r * sin(theta) * sin(rho);
>>>> function z(r, theta, rho) = r * cos(theta);
>>>>
>>>> sphereD = 5;
>>>> numRots = 7;
>>>> numSpheres = numRots * 360;
>>>> r = 100;
>>>> for (rho = [0:5:numSpheres])
>>>> let (theta = (180 * (rho / numSpheres)))
>>>> translate([x(r, theta, rho), y(r, theta, rho), z(r,
>>>> theta, rho)])
>>>> sphere(d = sphereD);
>>>> _______________________________________________
>>>> OpenSCAD mailing list
>>>> To unsubscribe send an email to
>>>> discuss-leave@lists.openscad.org
>>>
>>> _______________________________________________
>>> OpenSCAD mailing list
>>> To unsubscribe send an email todiscuss-leave@lists.openscad.org
>> _______________________________________________
>> OpenSCAD mailing list
>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>
>>
>> _______________________________________________
>> OpenSCAD mailing list
>> To unsubscribe send an email todiscuss-leave@lists.openscad.org
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email todiscuss-leave@lists.openscad.org