discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Undersized Spheres

AM
Adrian Mariano
Wed, Jul 1, 2026 10:20 AM

Sanjeev, you need to read farther because the cube sphere doesn't produce
the best point alignment.  Instead, you want a sphere based on an
octahedron.

On Tue, Jun 30, 2026 at 2:51 AM Sanjeev Prabhakar via Discuss <
discuss@lists.openscad.org> wrote:

I have read the first few pages of this cube sphere and the idea is that
you create a cube with multiple points centered at origin.
Then when you normalise all the points of that cube and multiply by some
distance, say 'r', it will create a sphere with radius 'r'.
This I think is a good idea and should not be very difficult to implement.

On Tue, 30 Jun 2026 at 07:36, Leonard Martin Struttmann via Discuss <
discuss@lists.openscad.org> wrote:

Wow!  The octahedron based sphere would be complicated.  I think that
I’ll try something simpler:

module MYsphere( r=1, d = undef)

{

function MYfn(f) = floor((f + 2) / 4) * 4;

F = MYfn($fn);

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 );

}

Len

For $fn = 24
[image: image.png]


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

Sanjeev, you need to read farther because the cube sphere doesn't produce the best point alignment. Instead, you want a sphere based on an octahedron. On Tue, Jun 30, 2026 at 2:51 AM Sanjeev Prabhakar via Discuss < discuss@lists.openscad.org> wrote: > I have read the first few pages of this cube sphere and the idea is that > you create a cube with multiple points centered at origin. > Then when you normalise all the points of that cube and multiply by some > distance, say 'r', it will create a sphere with radius 'r'. > This I think is a good idea and should not be very difficult to implement. > > > On Tue, 30 Jun 2026 at 07:36, Leonard Martin Struttmann via Discuss < > discuss@lists.openscad.org> wrote: > >> Wow! The octahedron based sphere would be complicated. I think that >> I’ll try something simpler: >> >> module MYsphere( r=1, d = undef) >> >> { >> >> function MYfn(f) = floor((f + 2) / 4) * 4; >> >> F = MYfn($fn); >> >> 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 ); >> >> } >> >> Len >> >> For $fn = 24 >> [image: image.png] >> _______________________________________________ >> 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
SP
Sanjeev Prabhakar
Wed, Jul 1, 2026 4:56 PM

OK
I will check that once I have some time
But maybe you can explain it as i can see you have already implemented it.

On Wed, 1 Jul, 2026, 3:51 pm Adrian Mariano via Discuss, <
discuss@lists.openscad.org> wrote:

Sanjeev, you need to read farther because the cube sphere doesn't produce
the best point alignment.  Instead, you want a sphere based on an
octahedron.

On Tue, Jun 30, 2026 at 2:51 AM Sanjeev Prabhakar via Discuss <
discuss@lists.openscad.org> wrote:

I have read the first few pages of this cube sphere and the idea is that
you create a cube with multiple points centered at origin.
Then when you normalise all the points of that cube and multiply by some
distance, say 'r', it will create a sphere with radius 'r'.
This I think is a good idea and should not be very difficult to implement.

On Tue, 30 Jun 2026 at 07:36, Leonard Martin Struttmann via Discuss <
discuss@lists.openscad.org> wrote:

Wow!  The octahedron based sphere would be complicated.  I think that
I’ll try something simpler:

module MYsphere( r=1, d = undef)

{

function MYfn(f) = floor((f + 2) / 4) * 4;

F = MYfn($fn);

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 );

}

Len

For $fn = 24
[image: image.png]


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

OK I will check that once I have some time But maybe you can explain it as i can see you have already implemented it. On Wed, 1 Jul, 2026, 3:51 pm Adrian Mariano via Discuss, < discuss@lists.openscad.org> wrote: > Sanjeev, you need to read farther because the cube sphere doesn't produce > the best point alignment. Instead, you want a sphere based on an > octahedron. > > On Tue, Jun 30, 2026 at 2:51 AM Sanjeev Prabhakar via Discuss < > discuss@lists.openscad.org> wrote: > >> I have read the first few pages of this cube sphere and the idea is that >> you create a cube with multiple points centered at origin. >> Then when you normalise all the points of that cube and multiply by some >> distance, say 'r', it will create a sphere with radius 'r'. >> This I think is a good idea and should not be very difficult to implement. >> >> >> On Tue, 30 Jun 2026 at 07:36, Leonard Martin Struttmann via Discuss < >> discuss@lists.openscad.org> wrote: >> >>> Wow! The octahedron based sphere would be complicated. I think that >>> I’ll try something simpler: >>> >>> module MYsphere( r=1, d = undef) >>> >>> { >>> >>> function MYfn(f) = floor((f + 2) / 4) * 4; >>> >>> F = MYfn($fn); >>> >>> 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 ); >>> >>> } >>> >>> Len >>> >>> For $fn = 24 >>> [image: image.png] >>> _______________________________________________ >>> 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
RD
Revar Desmera
Wed, Jul 1, 2026 11:37 PM

I was the one who implemented octa sphere in BOSL2.  It is noooot as simple as you might immediately think.
My first implementation was horribly naive, and not very good.  That ended up sparking a long discussion at:

https://github.com/openscad/openscad/pull/6100

I eventually got the BOSL2 implementation corrected, but it's definitely not simple, and would take a lot of work to make library-free.
If you want to take a shot at it, look for _make_octa_sphere() in shapes3d.scad.

  • Revar

On Jul 1, 2026, at 9:56 AM, Sanjeev Prabhakar via Discuss discuss@lists.openscad.org wrote:

OK
I will check that once I have some time
But maybe you can explain it as i can see you have already implemented it.

On Wed, 1 Jul, 2026, 3:51 pm Adrian Mariano via Discuss, <discuss@lists.openscad.org mailto:discuss@lists.openscad.org> wrote:

Sanjeev, you need to read farther because the cube sphere doesn't produce the best point alignment.  Instead, you want a sphere based on an octahedron.

On Tue, Jun 30, 2026 at 2:51 AM Sanjeev Prabhakar via Discuss <discuss@lists.openscad.org mailto:discuss@lists.openscad.org> wrote:

I have read the first few pages of this cube sphere and the idea is that you create a cube with multiple points centered at origin.
Then when you normalise all the points of that cube and multiply by some distance, say 'r', it will create a sphere with radius 'r'.
This I think is a good idea and should not be very difficult to implement.

On Tue, 30 Jun 2026 at 07:36, Leonard Martin Struttmann via Discuss <discuss@lists.openscad.org mailto:discuss@lists.openscad.org> wrote:

Wow!  The octahedron based sphere would be complicated.  I think that I’ll try something simpler:

module MYsphere( r=1, d = undef)
{
function MYfn(f) = floor((f + 2) / 4) * 4;

F = MYfn($fn);
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 );
}

Len

For $fn = 24
<image.png>


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org mailto:discuss-leave@lists.openscad.org_______________________________________________

OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org mailto:discuss-leave@lists.openscad.org_______________________________________________

OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org mailto:discuss-leave@lists.openscad.org_______________________________________________

OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I was the one who implemented octa sphere in BOSL2. It is noooot as simple as you might immediately think. My first implementation was horribly naive, and not very good. That ended up sparking a long discussion at: https://github.com/openscad/openscad/pull/6100 I eventually got the BOSL2 implementation corrected, but it's definitely not simple, and would take a lot of work to make library-free. If you want to take a shot at it, look for `_make_octa_sphere()` in shapes3d.scad. - Revar > On Jul 1, 2026, at 9:56 AM, Sanjeev Prabhakar via Discuss <discuss@lists.openscad.org> wrote: > > OK > I will check that once I have some time > But maybe you can explain it as i can see you have already implemented it. > > On Wed, 1 Jul, 2026, 3:51 pm Adrian Mariano via Discuss, <discuss@lists.openscad.org <mailto:discuss@lists.openscad.org>> wrote: >> Sanjeev, you need to read farther because the cube sphere doesn't produce the best point alignment. Instead, you want a sphere based on an octahedron. >> >> On Tue, Jun 30, 2026 at 2:51 AM Sanjeev Prabhakar via Discuss <discuss@lists.openscad.org <mailto:discuss@lists.openscad.org>> wrote: >>> I have read the first few pages of this cube sphere and the idea is that you create a cube with multiple points centered at origin. >>> Then when you normalise all the points of that cube and multiply by some distance, say 'r', it will create a sphere with radius 'r'. >>> This I think is a good idea and should not be very difficult to implement. >>> >>> >>> On Tue, 30 Jun 2026 at 07:36, Leonard Martin Struttmann via Discuss <discuss@lists.openscad.org <mailto:discuss@lists.openscad.org>> wrote: >>>> Wow! The octahedron based sphere would be complicated. I think that I’ll try something simpler: >>>> >>>> module MYsphere( r=1, d = undef) >>>> { >>>> function MYfn(f) = floor((f + 2) / 4) * 4; >>>> >>>> F = MYfn($fn); >>>> 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 ); >>>> } >>>> >>>> Len >>>> >>>> For $fn = 24 >>>> <image.png> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org>_______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org>_______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org>_______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
RD
Revar Desmera
Wed, Jul 1, 2026 11:41 PM

Interestingly, it appears that Manifold actually implements a proper Octa sphere in C++.

  • Revar

On Jul 1, 2026, at 4:37 PM, Revar Desmera revarbat@gmail.com wrote:

I was the one who implemented octa sphere in BOSL2.  It is noooot as simple as you might immediately think.
My first implementation was horribly naive, and not very good.  That ended up sparking a long discussion at:

 https://github.com/openscad/openscad/pull/6100

I eventually got the BOSL2 implementation corrected, but it's definitely not simple, and would take a lot of work to make library-free.
If you want to take a shot at it, look for _make_octa_sphere() in shapes3d.scad.

  • Revar

On Jul 1, 2026, at 9:56 AM, Sanjeev Prabhakar via Discuss discuss@lists.openscad.org wrote:

OK
I will check that once I have some time
But maybe you can explain it as i can see you have already implemented it.

On Wed, 1 Jul, 2026, 3:51 pm Adrian Mariano via Discuss, <discuss@lists.openscad.org mailto:discuss@lists.openscad.org> wrote:

Sanjeev, you need to read farther because the cube sphere doesn't produce the best point alignment.  Instead, you want a sphere based on an octahedron.

On Tue, Jun 30, 2026 at 2:51 AM Sanjeev Prabhakar via Discuss <discuss@lists.openscad.org mailto:discuss@lists.openscad.org> wrote:

I have read the first few pages of this cube sphere and the idea is that you create a cube with multiple points centered at origin.
Then when you normalise all the points of that cube and multiply by some distance, say 'r', it will create a sphere with radius 'r'.
This I think is a good idea and should not be very difficult to implement.

On Tue, 30 Jun 2026 at 07:36, Leonard Martin Struttmann via Discuss <discuss@lists.openscad.org mailto:discuss@lists.openscad.org> wrote:

Wow!  The octahedron based sphere would be complicated.  I think that I’ll try something simpler:

module MYsphere( r=1, d = undef)
{
function MYfn(f) = floor((f + 2) / 4) * 4;

F = MYfn($fn);
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 );
}

Len

For $fn = 24
<image.png>


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org mailto:discuss-leave@lists.openscad.org_______________________________________________

OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org mailto:discuss-leave@lists.openscad.org_______________________________________________

OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org mailto:discuss-leave@lists.openscad.org_______________________________________________

OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Interestingly, it appears that Manifold actually implements a proper Octa sphere in C++. - Revar > On Jul 1, 2026, at 4:37 PM, Revar Desmera <revarbat@gmail.com> wrote: > > I was the one who implemented octa sphere in BOSL2. It is noooot as simple as you might immediately think. > My first implementation was horribly naive, and not very good. That ended up sparking a long discussion at: > > https://github.com/openscad/openscad/pull/6100 > > I eventually got the BOSL2 implementation corrected, but it's definitely not simple, and would take a lot of work to make library-free. > If you want to take a shot at it, look for `_make_octa_sphere()` in shapes3d.scad. > > - Revar > > > >> On Jul 1, 2026, at 9:56 AM, Sanjeev Prabhakar via Discuss <discuss@lists.openscad.org> wrote: >> >> OK >> I will check that once I have some time >> But maybe you can explain it as i can see you have already implemented it. >> >> On Wed, 1 Jul, 2026, 3:51 pm Adrian Mariano via Discuss, <discuss@lists.openscad.org <mailto:discuss@lists.openscad.org>> wrote: >>> Sanjeev, you need to read farther because the cube sphere doesn't produce the best point alignment. Instead, you want a sphere based on an octahedron. >>> >>> On Tue, Jun 30, 2026 at 2:51 AM Sanjeev Prabhakar via Discuss <discuss@lists.openscad.org <mailto:discuss@lists.openscad.org>> wrote: >>>> I have read the first few pages of this cube sphere and the idea is that you create a cube with multiple points centered at origin. >>>> Then when you normalise all the points of that cube and multiply by some distance, say 'r', it will create a sphere with radius 'r'. >>>> This I think is a good idea and should not be very difficult to implement. >>>> >>>> >>>> On Tue, 30 Jun 2026 at 07:36, Leonard Martin Struttmann via Discuss <discuss@lists.openscad.org <mailto:discuss@lists.openscad.org>> wrote: >>>>> Wow! The octahedron based sphere would be complicated. I think that I’ll try something simpler: >>>>> >>>>> module MYsphere( r=1, d = undef) >>>>> { >>>>> function MYfn(f) = floor((f + 2) / 4) * 4; >>>>> >>>>> F = MYfn($fn); >>>>> 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 ); >>>>> } >>>>> >>>>> Len >>>>> >>>>> For $fn = 24 >>>>> <image.png> >>>>> _______________________________________________ >>>>> OpenSCAD mailing list >>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org>_______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org>_______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org>_______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >
SP
Sanjeev Prabhakar
Thu, Jul 2, 2026 2:51 AM

Got some idea, something like this, points are not evenly spaced. But there
is no use of hull in this.
[image: Screenshot 2026-07-02 at 8.18.33 AM.png]

On Thu, 2 Jul 2026 at 05:07, Revar Desmera via Discuss <
discuss@lists.openscad.org> wrote:

I was the one who implemented octa sphere in BOSL2.  It is noooot as
simple as you might immediately think.
My first implementation was horribly naive, and not very good.  That ended
up sparking a long discussion at:

 https://github.com/openscad/openscad/pull/6100

I eventually got the BOSL2 implementation corrected, but it's definitely
not simple, and would take a lot of work to make library-free.
If you want to take a shot at it, look for _make_octa_sphere() in
shapes3d.scad.

  • Revar

On Jul 1, 2026, at 9:56 AM, Sanjeev Prabhakar via Discuss <
discuss@lists.openscad.org> wrote:

OK
I will check that once I have some time
But maybe you can explain it as i can see you have already implemented it.

On Wed, 1 Jul, 2026, 3:51 pm Adrian Mariano via Discuss, <
discuss@lists.openscad.org> wrote:

Sanjeev, you need to read farther because the cube sphere doesn't produce
the best point alignment.  Instead, you want a sphere based on an
octahedron.

On Tue, Jun 30, 2026 at 2:51 AM Sanjeev Prabhakar via Discuss <
discuss@lists.openscad.org> wrote:

I have read the first few pages of this cube sphere and the idea is that
you create a cube with multiple points centered at origin.
Then when you normalise all the points of that cube and multiply by some
distance, say 'r', it will create a sphere with radius 'r'.
This I think is a good idea and should not be very difficult to
implement.

On Tue, 30 Jun 2026 at 07:36, Leonard Martin Struttmann via Discuss <
discuss@lists.openscad.org> wrote:

Wow!  The octahedron based sphere would be complicated.  I think that
I’ll try something simpler:

module MYsphere( r=1, d = undef)
{
function MYfn(f) = floor((f + 2) / 4) * 4;

F = MYfn($fn);
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 );
}

Len

For $fn = 24
<image.png>


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

Got some idea, something like this, points are not evenly spaced. But there is no use of hull in this. [image: Screenshot 2026-07-02 at 8.18.33 AM.png] On Thu, 2 Jul 2026 at 05:07, Revar Desmera via Discuss < discuss@lists.openscad.org> wrote: > I was the one who implemented octa sphere in BOSL2. It is noooot as > simple as you might immediately think. > My first implementation was horribly naive, and not very good. That ended > up sparking a long discussion at: > > https://github.com/openscad/openscad/pull/6100 > > I eventually got the BOSL2 implementation corrected, but it's definitely > not simple, and would take a lot of work to make library-free. > If you want to take a shot at it, look for `_make_octa_sphere()` in > shapes3d.scad. > > - Revar > > > > On Jul 1, 2026, at 9:56 AM, Sanjeev Prabhakar via Discuss < > discuss@lists.openscad.org> wrote: > > OK > I will check that once I have some time > But maybe you can explain it as i can see you have already implemented it. > > On Wed, 1 Jul, 2026, 3:51 pm Adrian Mariano via Discuss, < > discuss@lists.openscad.org> wrote: > >> Sanjeev, you need to read farther because the cube sphere doesn't produce >> the best point alignment. Instead, you want a sphere based on an >> octahedron. >> >> On Tue, Jun 30, 2026 at 2:51 AM Sanjeev Prabhakar via Discuss < >> discuss@lists.openscad.org> wrote: >> >>> I have read the first few pages of this cube sphere and the idea is that >>> you create a cube with multiple points centered at origin. >>> Then when you normalise all the points of that cube and multiply by some >>> distance, say 'r', it will create a sphere with radius 'r'. >>> This I think is a good idea and should not be very difficult to >>> implement. >>> >>> >>> On Tue, 30 Jun 2026 at 07:36, Leonard Martin Struttmann via Discuss < >>> discuss@lists.openscad.org> wrote: >>> >>>> Wow! The octahedron based sphere would be complicated. I think that >>>> I’ll try something simpler: >>>> >>>> module MYsphere( r=1, d = undef) >>>> { >>>> function MYfn(f) = floor((f + 2) / 4) * 4; >>>> >>>> F = MYfn($fn); >>>> 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 ); >>>> } >>>> >>>> Len >>>> >>>> For $fn = 24 >>>> <image.png> >>>> _______________________________________________ >>>> 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
L
larry
Thu, Jul 2, 2026 4:01 AM

On Mon, 2026-06-29 at 19:31 -0400, Adrian Mariano via Discuss wrote:

The right solution is to use the octahedron based sphere.  If you do
that, then for $fn=4, it always works.  The octahedron based sphere
is also much more symmetric and doesn't have extra triangles at poles
somewhere so it's more spherical for the same triangle count.  You
can go implement it yourself if you're a masochist.  You can get it
from BOSL2.  You can, I think, find BOSL2-free code in the discussion
of an openscad issue about this very problem, or actually on the
linked PR, where there was a lengthy discussion about how to
implement this.  It's not the simplest thing to implement.  There is
some subtlety in exactly how the triangles of the octahedron get
subdivided.  

https://github.com/openscad/openscad/issues/1983

image.png

I have often wondered why, when I render something that should be
centred, the bounding box shows it to be non-centred.
This discussion seems to show me why that is.

Just because of the way I think, I wrote it this way.
I purposely made the sphere 0.025 larger for better visualization.

//-----
include <BOSL2/std.scad>
$fn=$preview ? 60 : 360;

%left(10) fwd(10) down(10)
cube(20);
sphere(10.025,$fn=360);
//-----

On Mon, Jun 29, 2026 at 7:21 PM Leonard Martin Struttmann via Discuss
discuss@lists.openscad.org wrote:

Raymond, 

Your solution, just pushes points out at the appropriate places to
make the sphere look like it fits the box. 

Yes, I agree.  However, for my current design, that is sufficient. 
I need an approximate sphere and for there to be vertices on each
of the axes.  Using $fn=48 for the sphere(), what I normally render
at, the differences are minimal.

If the $fn is a multiple of four, it always fits. 

Yes, I could certainly use that constraint.  But, that only works
for circles.  That still leaves the flat spots at the poles of
sphere.

Len


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 Mon, 2026-06-29 at 19:31 -0400, Adrian Mariano via Discuss wrote: > The right solution is to use the octahedron based sphere.  If you do > that, then for $fn=4, it always works.  The octahedron based sphere > is also much more symmetric and doesn't have extra triangles at poles > somewhere so it's more spherical for the same triangle count.  You > can go implement it yourself if you're a masochist.  You can get it > from BOSL2.  You can, I think, find BOSL2-free code in the discussion > of an openscad issue about this very problem, or actually on the > linked PR, where there was a lengthy discussion about how to > implement this.  It's not the simplest thing to implement.  There is > some subtlety in exactly how the triangles of the octahedron get > subdivided.   > > https://github.com/openscad/openscad/issues/1983 > > image.png I have often wondered why, when I render something that should be centred, the bounding box shows it to be non-centred. This discussion seems to show me why that is. Just because of the way I think, I wrote it this way. I purposely made the sphere 0.025 larger for better visualization. //----- include <BOSL2/std.scad> $fn=$preview ? 60 : 360; %left(10) fwd(10) down(10) cube(20); sphere(10.025,$fn=360); //----- > > On Mon, Jun 29, 2026 at 7:21 PM Leonard Martin Struttmann via Discuss > <discuss@lists.openscad.org> wrote: > > Raymond,  > > > > Your solution, just pushes points out at the appropriate places to > > make the sphere look like it fits the box.  > > > > Yes, I agree.  However, for my current design, that is sufficient.  > > I need an approximate sphere and for there to be vertices on each > > of the axes.  Using $fn=48 for the sphere(), what I normally render > > at, the differences are minimal. > > > > If the $fn is a multiple of four, it always fits.  > > > > Yes, I could certainly use that constraint.  But, that only works > > for circles.  That still leaves the flat spots at the poles of > > sphere. > > > > Len > > > > _______________________________________________ > > 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
JB
Jordan Brown
Thu, Jul 2, 2026 4:57 AM

On 7/1/2026 9:01 PM, larry via Discuss wrote:

I have often wondered why, when I render something that should be
centred, the bounding box shows it to be non-centred.
This discussion seems to show me why that is.

OpenSCAD built-in spheres always have their +Z and -Z poles truncated.
If $fn is a multiple of 2 but not a multiple of 4, they also have their
+Y and -Y poles truncated.
If $fn is not even a multiple of 2, it also has its -X pole truncated. 
(And the +Y/-Y poles are truncated differently.)

There are better strategies for constructing spheres, that ensure that
all eight poles are in the right place, but alas OpenSCAD doesn't use
them, and there's a backward compatibility argument against improving
the algorithm.

$fn=$preview ? 60 : 360;

You're making my head hurt.

First, never set $fn at the top level like this, except maybe for
specific demonstrations.  Use $fs and $fa, or in recent builds maybe the
experimental $fe.  Use $fn only for regular polygons and a few special
cases, and none of those cases will want it at the top level.  For more
information, see my message of 22 June 2026 in this thread: 
https://lists.openscad.org/empathy/thread/UQIEQJOV3JIUGU2K2YCIKNTXUHF7IE4I

Second, $fn=360 is almost never necessary.  Do test prints for yourself

  • see the test program from that message - but I found that $fn=300 was
    necessary only for very large circles, like with a radius of a meter.

Third, all complexity arguments about circles go double for spheres,
because the number of faces on a sphere is around ($fn^2)/2.  Your
$fn=360 sphere has about 64,000 faces.  Double that when they're split
into triangles for Manifold.

Do not use what the shape looks like on the screen to guide your circle
resolution.  The screen will have faces visible in cases where they will
be totally invisible in plastic.

And:  some slicers (like PrusaSlicer) do arc fitting; they will notice
that a sequence of lines is very close to an arc, and will convert them
into low-level arc operations that will generate perfect arcs.  Once you
get into that range, adding more lines just makes for more work for
everything involved.

On 7/1/2026 9:01 PM, larry via Discuss wrote: > I have often wondered why, when I render something that should be > centred, the bounding box shows it to be non-centred. > This discussion seems to show me why that is. OpenSCAD built-in spheres always have their +Z and -Z poles truncated. If $fn is a multiple of 2 but not a multiple of 4, they also have their +Y and -Y poles truncated. If $fn is not even a multiple of 2, it also has its -X pole truncated.  (And the +Y/-Y poles are truncated differently.) There are better strategies for constructing spheres, that ensure that all eight poles are in the right place, but alas OpenSCAD doesn't use them, and there's a backward compatibility argument against improving the algorithm. > $fn=$preview ? 60 : 360; You're making my head hurt. First, never set $fn at the top level like this, except maybe for specific demonstrations.  Use $fs and $fa, or in recent builds maybe the experimental $fe.  Use $fn only for regular polygons and a few special cases, and none of those cases will want it at the top level.  For more information, see my message of 22 June 2026 in this thread:  https://lists.openscad.org/empathy/thread/UQIEQJOV3JIUGU2K2YCIKNTXUHF7IE4I Second, $fn=360 is almost never necessary.  Do test prints for yourself - see the test program from that message - but I found that $fn=300 was necessary only for very large circles, like with a radius of a meter. Third, all complexity arguments about circles go double for spheres, because the number of faces on a sphere is around ($fn^2)/2.  Your $fn=360 sphere has about 64,000 faces.  Double that when they're split into triangles for Manifold. Do not use what the shape looks like on the screen to guide your circle resolution.  The screen will have faces visible in cases where they will be totally invisible in plastic. And:  some slicers (like PrusaSlicer) do arc fitting; they will notice that a sequence of lines is very close to an arc, and will convert them into low-level arc operations that will generate perfect arcs.  Once you get into that range, adding more lines just makes for more work for everything involved.
LM
Leonard Martin Struttmann
Thu, Jul 2, 2026 10:30 AM

First, never set $fn at the top level like this, except maybe for specific
demonstrations.  Use $fs and $fa,...

I've seen statements like this several times.  However, understanding $fn
is easy.  I have a hard time grasping how to actually use $fa and $fs
together. Is there some sort of guide that gives example values for various
situations?

  1. Could someone explain this line from the OpenSCAD documentation:

"The number of line segments for a cylinder is determined using the greater
of the two radii."

What radii?  As a user I am specifying the radius of the cylinder.

Thanks!  Len, the Confused

1. *First, never set $fn at the top level like this, except maybe for specific demonstrations. Use $fs and $fa,...* I've seen statements like this several times. However, understanding $fn is easy. I have a hard time grasping how to actually use $fa and $fs together. Is there some sort of guide that gives example values for various situations? 2. Could someone explain this line from the OpenSCAD documentation: "The number of line segments for a cylinder is determined using the greater of the two radii." What radii? As a user I am specifying the radius of the cylinder. Thanks! Len, the Confused
AM
Adrian Mariano
Thu, Jul 2, 2026 11:54 AM

Larry, I don't understand what you mean about objects coming out
non-centered.  Your example appears centered to me, with exactly equal
circles sticking out from the cube at each face.

Revar, it doesn't look like _make_octa_sphere depends deeply on library
code---really just one cumsum call.

On Thu, Jul 2, 2026 at 12:02 AM larry via Discuss <
discuss@lists.openscad.org> wrote:

On Mon, 2026-06-29 at 19:31 -0400, Adrian Mariano via Discuss wrote:

The right solution is to use the octahedron based sphere.  If you do
that, then for $fn=4, it always works.  The octahedron based sphere
is also much more symmetric and doesn't have extra triangles at poles
somewhere so it's more spherical for the same triangle count.  You
can go implement it yourself if you're a masochist.  You can get it
from BOSL2.  You can, I think, find BOSL2-free code in the discussion
of an openscad issue about this very problem, or actually on the
linked PR, where there was a lengthy discussion about how to
implement this.  It's not the simplest thing to implement.  There is
some subtlety in exactly how the triangles of the octahedron get
subdivided.

https://github.com/openscad/openscad/issues/1983

image.png

I have often wondered why, when I render something that should be
centred, the bounding box shows it to be non-centred.
This discussion seems to show me why that is.

Just because of the way I think, I wrote it this way.
I purposely made the sphere 0.025 larger for better visualization.

//-----
include <BOSL2/std.scad>
$fn=$preview ? 60 : 360;

%left(10) fwd(10) down(10)
cube(20);
sphere(10.025,$fn=360);
//-----

On Mon, Jun 29, 2026 at 7:21 PM Leonard Martin Struttmann via Discuss
discuss@lists.openscad.org wrote:

Raymond,

Your solution, just pushes points out at the appropriate places to
make the sphere look like it fits the box.

Yes, I agree.  However, for my current design, that is sufficient.
I need an approximate sphere and for there to be vertices on each
of the axes.  Using $fn=48 for the sphere(), what I normally render
at, the differences are minimal.

If the $fn is a multiple of four, it always fits.

Yes, I could certainly use that constraint.  But, that only works
for circles.  That still leaves the flat spots at the poles of
sphere.

Len


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

Larry, I don't understand what you mean about objects coming out non-centered. Your example appears centered to me, with exactly equal circles sticking out from the cube at each face. Revar, it doesn't look like _make_octa_sphere depends deeply on library code---really just one cumsum call. On Thu, Jul 2, 2026 at 12:02 AM larry via Discuss < discuss@lists.openscad.org> wrote: > On Mon, 2026-06-29 at 19:31 -0400, Adrian Mariano via Discuss wrote: > > The right solution is to use the octahedron based sphere. If you do > > that, then for $fn=4, it always works. The octahedron based sphere > > is also much more symmetric and doesn't have extra triangles at poles > > somewhere so it's more spherical for the same triangle count. You > > can go implement it yourself if you're a masochist. You can get it > > from BOSL2. You can, I think, find BOSL2-free code in the discussion > > of an openscad issue about this very problem, or actually on the > > linked PR, where there was a lengthy discussion about how to > > implement this. It's not the simplest thing to implement. There is > > some subtlety in exactly how the triangles of the octahedron get > > subdivided. > > > > https://github.com/openscad/openscad/issues/1983 > > > > image.png > > I have often wondered why, when I render something that should be > centred, the bounding box shows it to be non-centred. > This discussion seems to show me why that is. > > Just because of the way I think, I wrote it this way. > I purposely made the sphere 0.025 larger for better visualization. > > //----- > include <BOSL2/std.scad> > $fn=$preview ? 60 : 360; > > %left(10) fwd(10) down(10) > cube(20); > sphere(10.025,$fn=360); > //----- > > > > > > > On Mon, Jun 29, 2026 at 7:21 PM Leonard Martin Struttmann via Discuss > > <discuss@lists.openscad.org> wrote: > > > Raymond, > > > > > > Your solution, just pushes points out at the appropriate places to > > > make the sphere look like it fits the box. > > > > > > Yes, I agree. However, for my current design, that is sufficient. > > > I need an approximate sphere and for there to be vertices on each > > > of the axes. Using $fn=48 for the sphere(), what I normally render > > > at, the differences are minimal. > > > > > > If the $fn is a multiple of four, it always fits. > > > > > > Yes, I could certainly use that constraint. But, that only works > > > for circles. That still leaves the flat spots at the poles of > > > sphere. > > > > > > Len > > > > > > _______________________________________________ > > > 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
AM
Adrian Mariano
Thu, Jul 2, 2026 1:27 PM

Leonard,  "cylinders" in OpenSCAD are actually truncated cones, and hence
have a top and bottom radius.

On Thu, Jul 2, 2026 at 6:31 AM Leonard Martin Struttmann via Discuss <
discuss@lists.openscad.org> wrote:

First, never set $fn at the top level like this, except maybe for
specific demonstrations.  Use $fs and $fa,...

I've seen statements like this several times.  However, understanding $fn
is easy.  I have a hard time grasping how to actually use $fa and $fs
together. Is there some sort of guide that gives example values for various
situations?

  1. Could someone explain this line from the OpenSCAD documentation:

"The number of line segments for a cylinder is determined using the
greater of the two radii."

What radii?  As a user I am specifying the radius of the cylinder.

Thanks!  Len, the Confused


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Leonard, "cylinders" in OpenSCAD are actually truncated cones, and hence have a top and bottom radius. On Thu, Jul 2, 2026 at 6:31 AM Leonard Martin Struttmann via Discuss < discuss@lists.openscad.org> wrote: > 1. > > *First, never set $fn at the top level like this, except maybe for > specific demonstrations. Use $fs and $fa,...* > > I've seen statements like this several times. However, understanding $fn > is easy. I have a hard time grasping how to actually use $fa and $fs > together. Is there some sort of guide that gives example values for various > situations? > > 2. Could someone explain this line from the OpenSCAD documentation: > > "The number of line segments for a cylinder is determined using the > greater of the two radii." > > What radii? As a user I am specifying the radius of the cylinder. > > Thanks! Len, the Confused > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org