PR#7075 https://github.com/openscad/openscad/pull/7075 adds a "style"
parameter to sphere(), with the primary goal being enabling
style="octa". The default is style="orig", which is the original sphere
style.
Setting style="octa" selects spheres based on octahedral subdivision
instead of the original "latitude/longitude" technique.
A picture is worth a thousand words. These are deliberately fairly
low-poly to make the difference clear.
I think the "octa" spheres are just plain prettier, but they have
several technical advantages:
Vertexes at the poles. Original-style spheres do not have vertexes at
the north and south poles, and usually do not have them at on the other
two axes either. This means that their bounding box is rarely the
specified size, and that can sometimes be a problem. It's subtle, but
look at this closeup of the left side of a sphere. The pink is a
highlighted cube with its size the same as the sphere diameter.
Axis-aligned great circles have the same vertexes as a circle or
cylinder of the same size and number of sides. This means that you can
attach an octa sphere to a cylinder or other round thing, and everything
lines up. In the original on the left, notice the little lip where the
sphere meets the cylinder, and how it isn't there with the octa sphere
on the right. This works on all three axes. (But note: this is only
convenient with $fn, and maybe in the future with $fe, because octa
spheres always use a multiple of four sides, and the $fs/$fa
calculations don't so cylinders won't.)
Fewer facets. For a given circular resolution (that is, a given $fn),
an octa sphere has fewer facets and thus better performance. With
$fn=16 (and combined with something else so that it gets fully
triangulated), an original sphere gets 210 facets while an octa sphere
gets 128.
What would be the behavior with $fn set to an odd number?
On Thu, Oct 1, 2026 at 6:49 PM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:
PR#7075 https://github.com/openscad/openscad/pull/7075 adds a "style"
parameter to sphere(), with the primary goal being enabling style="octa".
The default is style="orig", which is the original sphere style.
Setting style="octa" selects spheres based on octahedral subdivision
instead of the original "latitude/longitude" technique.
A picture is worth a thousand words. These are deliberately fairly
low-poly to make the difference clear.
I think the "octa" spheres are just plain prettier, but they have several
technical advantages:
Vertexes at the poles. Original-style spheres do not have vertexes at the
north and south poles, and usually do not have them at on the other two
axes either. This means that their bounding box is rarely the specified
size, and that can sometimes be a problem. It's subtle, but look at this
closeup of the left side of a sphere. The pink is a highlighted cube with
its size the same as the sphere diameter.
Axis-aligned great circles have the same vertexes as a circle or cylinder
of the same size and number of sides. This means that you can attach an
octa sphere to a cylinder or other round thing, and everything lines up.
In the original on the left, notice the little lip where the sphere meets
the cylinder, and how it isn't there with the octa sphere on the right.
This works on all three axes. (But note: this is only convenient with
$fn, and maybe in the future with $fe, because octa spheres always use a
multiple of four sides, and the $fs/$fa calculations don't so cylinders
won't.)
Fewer facets. For a given circular resolution (that is, a given $fn), an
octa sphere has fewer facets and thus better performance. With $fn=16 (and
combined with something else so that it gets fully triangulated), an
original sphere gets 210 facets while an octa sphere gets 128.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
On 10/1/2026 8:36 PM, Leonard Martin Struttmann via Discuss wrote:
What would be the behavior with $fn set to an odd number?
With style="orig", the behavior is of course unchanged.
With style="octa", it's rounded up to a multiple of four.
That looks nice. BTW, if you wanted to make the number of facets fully
parametric, you might be able to use a Fibonacci Lattice, where you can
define how many vertices you want to calculate. It is also very fast to
run typically.
EBo --
On Thu, Oct 1, 2026 at 8:56 PM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:
On 10/1/2026 8:36 PM, Leonard Martin Struttmann via Discuss wrote:
What would be the behavior with $fn set to an odd number?
With style="orig", the behavior is of course unchanged.
With style="octa", it's rounded up to a multiple of four.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
On 10/1/2026 9:28 PM, John David wrote:
That looks nice. BTW, if you wanted to make the number of facets
fully parametric, you might be able to use a Fibonacci Lattice, where
you can define how many vertices you want to calculate. It is also
very fast to run typically.
The "style" parameter was intended to allow for future alternative
algorithms.
"octa" was specifically chosen and designed to address the points I
mentioned: vertexes at the poles and matching with cylinders. (That's
why, for instance, it won out over icosahedronal subdivision.)
I don't personally feel the need for any additional work in this area.
I did the initial implementation of a built-in octahedral-subdivision
sphere, based on the BOSL2 implementation, and I was happy with it, but
others who are pickier and more mathematically inclined worked on the
details to produce what we got here... and that's fine with me. (If
you're interested, see PR #6100
https://github.com/openscad/openscad/pull/6100.)
But if somebody else wants to... the avenue is there.
The main test I use to see if the vertices of an octa sphere are well placed, is to quickly swap between top, right, and front views of the sphere and see if the vertices appear to move at all. Another way could be to difference the same octa sphere from itself rotated by 90° degrees around X or Y.
-Revar
On Oct 1, 2026, at 6:37 PM, Jordan Brown via Discuss <discuss@lists.openscad.org> wrote:
On 10/1/2026 9:28 PM, John David wrote:
That looks nice. BTW, if you wanted to make the number of facets fully parametric, you might be able to use a Fibonacci Lattice, where you can define how many vertices you want to calculate. It is also very fast to run typically.
The "style" parameter was intended to allow for future alternative algorithms.
"octa" was specifically chosen and designed to address the points I mentioned: vertexes at the poles and matching with cylinders. (That's why, for instance, it won out over icosahedronal subdivision.)
I don't personally feel the need for any additional work in this area. I did the initial implementation of a built-in octahedral-subdivision sphere, based on the BOSL2 implementation, and I was happy with it, but others who are pickier and more mathematically inclined worked on the details to produce what we got here... and that's fine with me. (If you're interested, see PR #6100.)
But if somebody else wants to... the avenue is there.
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Another variation that I use puts the vertices on the poles, but keeps the
Lat/Lon scheme, which I like for some designs:
//************************************************************************
// Redefines 'sphere()' to always have a vertex on all six half axes I.e.
// vertices at the poles and the equator, regardless of '$fn' value..
//
// NOTE: To match this sphere to a cylinder along the X or Y axes, the $fn
// specified for this sphere must be a multiple of four and must be
// HALF the $fn specified for the cylinder.
// To match this sphere to a cylinder along the Z axis, the $fn
// specified for this sphere must be a multiple of four and must be
// EQUAL TO the $fn specified for the cylinder.
//
//************************************************************************
module L_sphere( r=1, d = undef, $fn=$fn )
//************************************************************************
{
// echo("sphere $fn: ", $fn);
function MYfn(f) = floor((f + 2) / 4) * 4;
F = MYfn($fn);
// echo("sphere F: ", F );
R = is_undef(d) ? r : d / 2;
p = [ for (a=[-90:180/F:90]) polar_to_rectangular([ R, a ] ) ];
rotate_extrude(angle = 360, convexity = 10, $fn=F )
polygon( p );
}
//************************************************************************
On Thu, Oct 1, 2026 at 9:00 PM Revar Desmera via Discuss <
discuss@lists.openscad.org> wrote:
The main test I use to see if the vertices of an octa sphere are well
placed, is to quickly swap between top, right, and front views of the
sphere and see if the vertices appear to move at all. Another way could be
to difference the same octa sphere from itself rotated by 90° degrees
around X or Y.
-Revar
On Oct 1, 2026, at 6:37 PM, Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:
On 10/1/2026 9:28 PM, John David wrote:
That looks nice. BTW, if you wanted to make the number of facets fully
parametric, you might be able to use a Fibonacci Lattice, where you can
define how many vertices you want to calculate. It is also very fast to
run typically.
The "style" parameter was intended to allow for future alternative
algorithms.
"octa" was specifically chosen and designed to address the points I
mentioned: vertexes at the poles and matching with cylinders. (That's
why, for instance, it won out over icosahedronal subdivision.)
I don't personally feel the need for any additional work in this area. I
did the initial implementation of a built-in octahedral-subdivision sphere,
based on the BOSL2 implementation, and I was happy with it, but others who
are pickier and more mathematically inclined worked on the details to
produce what we got here... and that's fine with me. (If you're
interested, see PR #6100 https://github.com/openscad/openscad/pull/6100
.)
But if somebody else wants to... the avenue is there.
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
My comments on the Fibonacci Lattice come from knowing that the distance
between points are uniform for all except the first point or two, and they
only vary >> 1% when dealing with billions of points. For small number of
points (say a few hundred), I found that the distance between all points is
typically vanishingly small.
On Thu, Oct 1, 2026 at 10:09 PM Leonard Martin Struttmann via Discuss <
discuss@lists.openscad.org> wrote:
Another variation that I use puts the vertices on the poles, but keeps the
Lat/Lon scheme, which I like for some designs:
//************************************************************************
// Redefines 'sphere()' to always have a vertex on all six half axes I.e.
// vertices at the poles and the equator, regardless of '$fn' value..
//
// NOTE: To match this sphere to a cylinder along the X or Y axes, the $fn
// specified for this sphere must be a multiple of four and must be
// HALF the $fn specified for the cylinder.
// To match this sphere to a cylinder along the Z axis, the $fn
// specified for this sphere must be a multiple of four and must be
// EQUAL TO the $fn specified for the cylinder.
//
//************************************************************************
module L_sphere( r=1, d = undef, $fn=$fn )
//************************************************************************
{
// echo("sphere $fn: ", $fn);
function MYfn(f) = floor((f + 2) / 4) * 4;
F = MYfn($fn);
// echo("sphere F: ", F );
R = is_undef(d) ? r : d / 2;
p = [ for (a=[-90:180/F:90]) polar_to_rectangular([ R, a ] ) ];
rotate_extrude(angle = 360, convexity = 10, $fn=F )
polygon( p );
}
//************************************************************************
On Thu, Oct 1, 2026 at 9:00 PM Revar Desmera via Discuss <
discuss@lists.openscad.org> wrote:
The main test I use to see if the vertices of an octa sphere are well
placed, is to quickly swap between top, right, and front views of the
sphere and see if the vertices appear to move at all. Another way could be
to difference the same octa sphere from itself rotated by 90° degrees
around X or Y.
-Revar
On Oct 1, 2026, at 6:37 PM, Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:
On 10/1/2026 9:28 PM, John David wrote:
That looks nice. BTW, if you wanted to make the number of facets fully
parametric, you might be able to use a Fibonacci Lattice, where you can
define how many vertices you want to calculate. It is also very fast to
run typically.
The "style" parameter was intended to allow for future alternative
algorithms.
"octa" was specifically chosen and designed to address the points I
mentioned: vertexes at the poles and matching with cylinders. (That's
why, for instance, it won out over icosahedronal subdivision.)
I don't personally feel the need for any additional work in this area. I
did the initial implementation of a built-in octahedral-subdivision sphere,
based on the BOSL2 implementation, and I was happy with it, but others who
are pickier and more mathematically inclined worked on the details to
produce what we got here... and that's fine with me. (If you're
interested, see PR #6100 https://github.com/openscad/openscad/pull/6100
.)
But if somebody else wants to... the avenue is there.
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
On 10/1/2026 9:59 PM, Revar Desmera via Discuss wrote:
The main test I use to see if the vertices of an octa sphere are well
placed, is to quickly swap between top, right, and front views of the
sphere and see if the vertices appear to move at all. Another way
could be to difference the same octa sphere from itself rotated by 90°
degrees around X or Y.
... which I should have mentioned; I believe this implementation passes
that test.
On 10/1/26 22:17, John David via Discuss wrote:
My comments on the Fibonacci Lattice come from knowing that the
distance between points are uniform for all except the first point or
two, and they only vary >> 1% when dealing with billions of points.
For small number of points (say a few hundred), I found that the
distance between all points is typically vanishingly small.
On Thu, Oct 1, 2026 at 10:09 PM Leonard Martin Struttmann via Discuss
discuss@lists.openscad.org wrote:
Another variation that I use puts the vertices on the poles, but
keeps the Lat/Lon scheme, which I like for some designs:
//************************************************************************
// Redefines 'sphere()' to always have a vertex on all six half
axes I.e.
// vertices at the poles and the equator, regardless of '$fn' value..
//
// NOTE: To match this sphere to a cylinder along the X or Y axes,
the $fn
// specified for this sphere must be a multiple of four and must be
// HALF the $fn specified for the cylinder.
// To match this sphere to a cylinder along the Z axis, the $fn
// specified for this sphere must be a multiple of four and must be
// EQUAL TO the $fn specified for the cylinder.
//
//************************************************************************
module L_sphere( r=1, d = undef, $fn=$fn )
//************************************************************************
{
// echo("sphere $fn: ", $fn);
function MYfn(f) = floor((f + 2) / 4) * 4;
F = MYfn($fn);
// echo("sphere F: ", F );
R = is_undef(d) ? r : d / 2;
p = [ for (a=[-90:180/F:90]) polar_to_rectangular([ R, a ] ) ];
rotate_extrude(angle = 360, convexity = 10, $fn=F )
polygon( p );
}
//************************************************************************
On Thu, Oct 1, 2026 at 9:00 PM Revar Desmera via Discuss
<discuss@lists.openscad.org> wrote:
The main test I use to see if the vertices of an octa sphere
are well placed, is to quickly swap between top, right, and
front views of the sphere and see if the vertices appear to
move at all. Another way could be to difference the same octa
sphere from itself rotated by 90° degrees around X or Y.
-Revar
On Oct 1, 2026, at 6:37 PM, Jordan Brown via Discuss
<discuss@lists.openscad.org> wrote:
On 10/1/2026 9:28 PM, John David wrote:
That looks nice. BTW, if you wanted to make the number of
facets fully parametric, you might be able to use a
Fibonacci Lattice, where you can define how many vertices
you want to calculate. It is also very fast to run typically.
The "style" parameter was intended to allow for future
alternative algorithms.
"octa" was specifically chosen and designed to address the
points I mentioned: vertexes at the poles and matching with
cylinders. (That's why, for instance, it won out over
icosahedronal subdivision.)
I don't personally feel the need for any additional work in
this area. I did the initial implementation of a built-in
octahedral-subdivision sphere, based on the BOSL2
implementation, and I was happy with it, but others who are
pickier and more mathematically inclined worked on the
details to produce what we got here... and that's fine with
me. (If you're interested, see PR #6100
<https://github.com/openscad/openscad/pull/6100>.)
But if somebody else wants to... the avenue is there.
I think this is prettier, but it might not slice as well for printing.
How long b4 this shows up in the ubuntu repo's?
Cheers, Gene
_______________________________________________
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 todiscuss-leave@lists.openscad.org