discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

New Algorithm for Spheres

GS
Guenther Sohler
Sun, Jul 26, 2015 2:35 PM

Hi Group,

I have realized, that the exising implementation of spheres have higher

vertex densities

at the polar region due the method how its implemented.

So I have created a fast algorithm to create an almost constant point

density all over its surface.

See some samples:

If this is interesting, I can provide a c sample such that it can be

integrated into openscad.

Guenther

Hi Group, I have realized, that the exising implementation of spheres have higher vertex densities at the polar region due the method how its implemented. So I have created a fast algorithm to create an almost constant point density all over its surface. See some samples: If this is interesting, I can provide a c sample such that it can be integrated into openscad. Guenther
TP
Torsten Paul
Sun, Jul 26, 2015 4:02 PM

On 07/26/2015 04:35 PM, Guenther Sohler wrote:

I have realized, that the existing implementation of spheres have higher
vertex densities at the polar region due the method how its implemented.

Right, Blender has both algorithms too and calls it UV-Sphere (the one
we have already) and Ico-Sphere. Looks like someone decided it's useful
to have both in Blender, so maybe that would be an option for OpenSCAD
too.

I guess the interesting question would be how to add this.

icosphere();

sphere(ico = true);

And the effect of $fn would need to be clarified. The example code from
http://blog.andreaskahler.com/2009/06/creating-icosphere-mesh-in-code.html
uses recursion to increase the resolution, so the number of vertices
increases quite fast. How's your code doing that?

ciao,
Torsten.

On 07/26/2015 04:35 PM, Guenther Sohler wrote: > I have realized, that the existing implementation of spheres have higher > vertex densities at the polar region due the method how its implemented. > Right, Blender has both algorithms too and calls it UV-Sphere (the one we have already) and Ico-Sphere. Looks like someone decided it's useful to have both in Blender, so maybe that would be an option for OpenSCAD too. I guess the interesting question would be how to add this. icosphere(); sphere(ico = true); And the effect of $fn would need to be clarified. The example code from http://blog.andreaskahler.com/2009/06/creating-icosphere-mesh-in-code.html uses recursion to increase the resolution, so the number of vertices increases quite fast. How's your code doing that? ciao, Torsten.
GS
Guenther Sohler
Sun, Jul 26, 2015 4:55 PM

Hi Paul,

Did not realize that this type sphere already has a name, however, my

shape is not based on an icosaeder and its not recursive.

Only disadvantage is ,that final number of vertices and triangles

orginally not known, this is why

successive "Realloc" is needed until done.

My Algorithm is very similar to the openscad one, however, the number of

circle points in each layer is calculated

individually.

The challenge then is to merge adjacent circles with triangles as there is

no relation in points

$fn could be used very easily. My Algorithm accepts a default triangles

size(which is fitted slightly)

The Amount of triangles can be adjusted quite smoothly by setting the

default triangle size.

Guenther


OpenSCAD mailing list

Hi Paul, Did not realize that this type sphere already has a name, however, my shape is not based on an icosaeder and its not recursive. Only disadvantage is ,that final number of vertices and triangles orginally not known, this is why successive "Realloc" is needed until done. My Algorithm is very similar to the openscad one, however, the number of circle points in each layer is calculated individually. The challenge then is to merge adjacent circles with triangles as there is no relation in points $fn could be used very easily. My Algorithm accepts a default triangles size(which is fitted slightly) The Amount of triangles can be adjusted quite smoothly by setting the default triangle size. Guenther > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
GS
Guenther Sohler
Sun, Jul 26, 2015 6:15 PM

Here are some of my code snippets ...

.. currently working with Cork datastructure , just to mention the correct

source ...

( https://github.com/gilbo/cork )

int addVertex(CorkTriMesh *mesh,uint *a_vertices, float *p)

{

    float *x;

    if(*a_vertices == mesh->n_vertices)

    {

            *a_vertices *= 2;

            x = new float[3* *a_vertices];

            memcpy(x,mesh->vertices, 3* *a_vertices*sizeof(float)/2);

            mesh->vertices = x;

    }

    mesh->vertices[mesh->n_vertices*3+0]=p[0];

    mesh->vertices[mesh->n_vertices*3+1]=p[1];

    mesh->vertices[mesh->n_vertices*3+2]=p[2];

    return mesh->n_vertices++;      

    

}

int addTriangle(CorkTriMesh *mesh,uint *a_triangles,int i1,int i2, int i3)

{

    uint *x;



    if(*a_triangles == mesh->n_triangles)

    {

            *a_triangles *= 2;

            x = new uint[3* *a_triangles];

            memcpy(x,mesh->triangles, 3* *a_triangles*sizeof(int)/2);

            mesh->triangles = x;

    }

    mesh->triangles[mesh->n_triangles*3+0]=i1;

    mesh->triangles[mesh->n_triangles*3+1]=i2;

    mesh->triangles[mesh->n_triangles*3+2]=i3;

    return mesh->n_triangles++;     

    

}

CorkTriMesh *Sphere(float r,int iterations)

{

//      SphereMesher *m = new SphereMesher(r);

//      return m->calcMesh(10,iterations);

    double s=10;

    double z,sr,vphi,hphi;

    double phiold_d,phinew_d;

    int oldind, newind;

    int vertsteps,horstepsnew,horstepsold=1;

    int i,j,dir;



    uint a_vertices = 10;

    uint a_triangles = 10;

    float p[3];

    int *circ_new=NULL;

    int *circ_old=NULL;



    CorkTriMesh *result;

    result = new CorkTriMesh();



    result->n_vertices = 0;

    result->n_triangles = 0;



    result->triangles = new uint[a_triangles * 3];

    result->vertices = new float[a_vertices * 3];

    vertsteps=ceil(M_PI*r/s);



    for(i=0;i<=vertsteps;i++)

    {

            vphi=M_PI*i/(double) vertsteps;

            z=-r*cos(vphi);

            sr=r*sin(vphi);



            horstepsnew = ceil(2*M_PI*sr/s);

            if(horstepsnew == 0) horstepsnew=1;



            circ_new = new int[horstepsnew];

            for(j=0;j<horstepsnew;j++)

            {

                    hphi=2*M_PI*j/(double) horstepsnew;

                    p[0]=sr*cos(hphi);

                    p[1]=sr*sin(hphi);

                    p[2]=z;

                    circ_new[j] = addVertex(result,&a_vertices,p);

            }



            if(circ_old != NULL)

            {

                    phiold_d= 2*M_PI/(double) horstepsold;

                    phinew_d= 2*M_PI/(double) horstepsnew;

                    oldind=0;

                    newind=0;

                    while(oldind < horstepsold || newind <

horstepsnew)

                    {

                            if(horstepsnew < horstepsold)

                            {

                                    if(phiold_d*(oldind+1) <

phinew_d*(newind+1)) dir=1;

                                            else dir=0;

                            }

                            else

                            {

                                    if(phiold_d*(oldind+1) <=

phinew_d*(newind+1)) dir=1;

                                            else dir=0;

                            }



                            if(dir == 1)

                            {

                                    if(horstepsold != 1)

                                    {

                                           

addTriangle(result,&a_triangles,

circ_old[(oldind+0)%horstepsold],

circ_old[(oldind+1)%horstepsold],

circ_new[(newind+0)%horstepsnew]);

                                    }

                                    oldind++;

                            }

                            else

                            {

                                    if(horstepsnew != 1)

                                    {

                                           

addTriangle(result,&a_triangles,

circ_old[(oldind+0)%horstepsold],

circ_new[(newind+1)%horstepsnew],

circ_new[(newind+0)%horstepsnew]);

                                    }

                                    newind++;

                            }



                    }

                    

                    free(circ_old);

            }

            circ_old = circ_new;

            horstepsold=horstepsnew;

    }



    free(circ_old);

    

    return result;

}

Guenther

Here are some of my code snippets ... .. currently working with Cork datastructure , just to mention the correct source ... ( https://github.com/gilbo/cork ) int addVertex(CorkTriMesh *mesh,uint *a_vertices, float *p) { float *x; if(*a_vertices == mesh->n_vertices) { *a_vertices *= 2; x = new float[3* *a_vertices]; memcpy(x,mesh->vertices, 3* *a_vertices*sizeof(float)/2); mesh->vertices = x; } mesh->vertices[mesh->n_vertices*3+0]=p[0]; mesh->vertices[mesh->n_vertices*3+1]=p[1]; mesh->vertices[mesh->n_vertices*3+2]=p[2]; return mesh->n_vertices++; } int addTriangle(CorkTriMesh *mesh,uint *a_triangles,int i1,int i2, int i3) { uint *x; if(*a_triangles == mesh->n_triangles) { *a_triangles *= 2; x = new uint[3* *a_triangles]; memcpy(x,mesh->triangles, 3* *a_triangles*sizeof(int)/2); mesh->triangles = x; } mesh->triangles[mesh->n_triangles*3+0]=i1; mesh->triangles[mesh->n_triangles*3+1]=i2; mesh->triangles[mesh->n_triangles*3+2]=i3; return mesh->n_triangles++; } CorkTriMesh *Sphere(float r,int iterations) { // SphereMesher *m = new SphereMesher(r); // return m->calcMesh(10,iterations); double s=10; double z,sr,vphi,hphi; double phiold_d,phinew_d; int oldind, newind; int vertsteps,horstepsnew,horstepsold=1; int i,j,dir; uint a_vertices = 10; uint a_triangles = 10; float p[3]; int *circ_new=NULL; int *circ_old=NULL; CorkTriMesh *result; result = new CorkTriMesh(); result->n_vertices = 0; result->n_triangles = 0; result->triangles = new uint[a_triangles * 3]; result->vertices = new float[a_vertices * 3]; vertsteps=ceil(M_PI*r/s); for(i=0;i<=vertsteps;i++) { vphi=M_PI*i/(double) vertsteps; z=-r*cos(vphi); sr=r*sin(vphi); horstepsnew = ceil(2*M_PI*sr/s); if(horstepsnew == 0) horstepsnew=1; circ_new = new int[horstepsnew]; for(j=0;j<horstepsnew;j++) { hphi=2*M_PI*j/(double) horstepsnew; p[0]=sr*cos(hphi); p[1]=sr*sin(hphi); p[2]=z; circ_new[j] = addVertex(result,&a_vertices,p); } if(circ_old != NULL) { phiold_d= 2*M_PI/(double) horstepsold; phinew_d= 2*M_PI/(double) horstepsnew; oldind=0; newind=0; while(oldind < horstepsold || newind < horstepsnew) { if(horstepsnew < horstepsold) { if(phiold_d*(oldind+1) < phinew_d*(newind+1)) dir=1; else dir=0; } else { if(phiold_d*(oldind+1) <= phinew_d*(newind+1)) dir=1; else dir=0; } if(dir == 1) { if(horstepsold != 1) { addTriangle(result,&a_triangles, circ_old[(oldind+0)%horstepsold], circ_old[(oldind+1)%horstepsold], circ_new[(newind+0)%horstepsnew]); } oldind++; } else { if(horstepsnew != 1) { addTriangle(result,&a_triangles, circ_old[(oldind+0)%horstepsold], circ_new[(newind+1)%horstepsnew], circ_new[(newind+0)%horstepsnew]); } newind++; } } free(circ_old); } circ_old = circ_new; horstepsold=horstepsnew; } free(circ_old); return result; } Guenther
DM
doug moen
Sun, Jul 26, 2015 7:23 PM

I looked at sphere10.stl, and as you say, it has "almost constant point
density", which is not the same as the maximally constant point density and
maximal symmetry that you get from a geodesic sphere (called an "isosphere"
in Blender). Sphere10.stl is irregular, and not very symmetrical: some of
the facets appear to be equilateral triangles, but some of them are
non-equilateral triangles, and some of them are squares.

I'd rather have the real thing: an OpenSCAD primitive that constructs a
true geodesic sphere.

As a point of terminology, I don't much like "icosphere" because it's
Blender specific. The proper and more well known name for the shape (and
the name used by Wikipedia) is "geodesic sphere".

On 26 July 2015 at 10:35, Guenther Sohler mail@guenther-sohler.net wrote:

Hi Group,

I have realized, that the exising implementation of spheres have higher

vertex densities

at the polar region due the method how its implemented.

So I have created a fast algorithm to create an almost constant point

density all over its surface.

See some samples:

If this is interesting, I can provide a c sample such that it can be

integrated into openscad.

Guenther


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

I looked at sphere10.stl, and as you say, it has "almost constant point density", which is not the same as the maximally constant point density and maximal symmetry that you get from a geodesic sphere (called an "isosphere" in Blender). Sphere10.stl is irregular, and not very symmetrical: some of the facets appear to be equilateral triangles, but some of them are non-equilateral triangles, and some of them are squares. I'd rather have the real thing: an OpenSCAD primitive that constructs a true geodesic sphere. As a point of terminology, I don't much like "icosphere" because it's Blender specific. The proper and more well known name for the shape (and the name used by Wikipedia) is "geodesic sphere". On 26 July 2015 at 10:35, Guenther Sohler <mail@guenther-sohler.net> wrote: > > > Hi Group, > > > > I have realized, that the exising implementation of spheres have higher > > vertex densities > > at the polar region due the method how its implemented. > > > > So I have created a fast algorithm to create an almost constant point > > density all over its surface. > > See some samples: > > > > If this is interesting, I can provide a c sample such that it can be > > integrated into openscad. > > > > Guenther > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
GS
Guenther Sohler
Sun, Jul 26, 2015 8:05 PM

Hi Doug,

this is why I added two STL files: sphere10.stl, result50.stl

sphere10 represents a sphere with few details(like you create a sphere

with $fn=5)

result50.stl looks much better, the triangle size is much smaller compared

to the sphere radius.

Admittedly the algorithm does not create perfect symmetry but the idea

here was to have  more regular

point density around the sphere

Guenther

Hi Doug, this is why I added two STL files: sphere10.stl, result50.stl sphere10 represents a sphere with few details(like you create a sphere with $fn=5) result50.stl looks much better, the triangle size is much smaller compared to the sphere radius. Admittedly the algorithm does not create perfect symmetry but the idea here was to have more regular point density around the sphere Guenther
DM
doug moen
Sun, Jul 26, 2015 8:45 PM

Sphere10.stl has 32 facets, and it is no where near as good as an
icosahedron at approximating a sphere, even though the icosahedron has only
20 sides. The icosahedron is a platonic solid, so it has perfect symmetry.

What I don't understand is why your solids are better than geodesic spheres
as sphere approximations.

On 26 July 2015 at 16:05, Guenther Sohler mail@guenther-sohler.net wrote:

Hi Doug,

this is why I added two STL files: sphere10.stl, result50.stl

sphere10 represents a sphere with few details(like you create a sphere

with $fn=5)

result50.stl looks much better, the triangle size is much smaller compared

to the sphere radius.

Admittedly the algorithm does not create perfect symmetry but the idea

here was to have  more regular

point density around the sphere

Guenther

Sphere10.stl has 32 facets, and it is no where near as good as an icosahedron at approximating a sphere, even though the icosahedron has only 20 sides. The icosahedron is a platonic solid, so it has perfect symmetry. What I don't understand is why your solids are better than geodesic spheres as sphere approximations. On 26 July 2015 at 16:05, Guenther Sohler <mail@guenther-sohler.net> wrote: > > Hi Doug, > > > > this is why I added two STL files: sphere10.stl, result50.stl > > > > sphere10 represents a sphere with few details(like you create a sphere > > with $fn=5) > > result50.stl looks much better, the triangle size is much smaller compared > > to the sphere radius. > > > > Admittedly the algorithm does not create perfect symmetry but the idea > > here was to have more regular > > point density around the sphere > > > > Guenther > > > > > > > > > >
YA
Yona Appletree
Sun, Jul 26, 2015 11:22 PM

For reference, I've created (and posted to this list before) a utility I
wrote in OpenSCAD for arbitrary geodesic icosahedral sections, including
whole spheres and domes. It's available here:
https://gist.github.com/Yona-Appletree/a03bc32a5c5ca6886e38

It would, of course, be neat to see geodesic spheres included in the
core code. This could be used as an inspiration.

Note that I only wrote the geodesic slicing code, the rest is based on a
geodesic library found on thingiverse.

  • Yona

doug moen mailto:doug@moens.org
July 26, 2015 at 16:45
Sphere10.stl has 32 facets, and it is no where near as good as an
icosahedron at approximating a sphere, even though the icosahedron has
only 20 sides. The icosahedron is a platonic solid, so it has perfect
symmetry.

What I don't understand is why your solids are better than geodesic
spheres as sphere approximations.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Guenther Sohler mailto:mail@guenther-sohler.net
July 26, 2015 at 16:05
Hi Doug,

this is why I added two STL files: sphere10.stl, result50.stl

sphere10 represents a sphere with few details(like you create a sphere

with $fn=5)

result50.stl looks much better, the triangle size is much smaller compared

to the sphere radius.

Admittedly the algorithm does not create perfect symmetry but the idea

here was to have more regular

point density around the sphere

Guenther


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
doug moen mailto:doug@moens.org
July 26, 2015 at 15:23
I looked at sphere10.stl, and as you say, it has "almost constant
point density", which is not the same as the maximally constant point
density and maximal symmetry that you get from a geodesic sphere
(called an "isosphere" in Blender). Sphere10.stl is irregular, and not
very symmetrical: some of the facets appear to be equilateral
triangles, but some of them are non-equilateral triangles, and some of
them are squares.

I'd rather have the real thing: an OpenSCAD primitive that constructs
a true geodesic sphere.

As a point of terminology, I don't much like "icosphere" because it's
Blender specific. The proper and more well known name for the shape
(and the name used by Wikipedia) is "geodesic sphere".


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Guenther Sohler mailto:mail@guenther-sohler.net
July 26, 2015 at 10:35

Hi Group,

I have realized, that the exising implementation of spheres have higher

vertex densities

at the polar region due the method how its implemented.

So I have created a fast algorithm to create an almost constant point

density all over its surface.

See some samples:

If this is interesting, I can provide a c sample such that it can be

integrated into openscad.

Guenther


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

For reference, I've created (and posted to this list before) a utility I wrote in OpenSCAD for arbitrary geodesic icosahedral sections, including whole spheres and domes. It's available here: https://gist.github.com/Yona-Appletree/a03bc32a5c5ca6886e38 It would, of course, be neat to see geodesic spheres included in the core code. This could be used as an inspiration. Note that I only wrote the geodesic slicing code, the rest is based on a geodesic library found on thingiverse. - Yona > doug moen <mailto:doug@moens.org> > July 26, 2015 at 16:45 > Sphere10.stl has 32 facets, and it is no where near as good as an > icosahedron at approximating a sphere, even though the icosahedron has > only 20 sides. The icosahedron is a platonic solid, so it has perfect > symmetry. > > What I don't understand is why your solids are better than geodesic > spheres as sphere approximations. > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > Guenther Sohler <mailto:mail@guenther-sohler.net> > July 26, 2015 at 16:05 > Hi Doug, > > > > this is why I added two STL files: sphere10.stl, result50.stl > > > > sphere10 represents a sphere with few details(like you create a sphere > > with $fn=5) > > result50.stl looks much better, the triangle size is much smaller compared > > to the sphere radius. > > > > Admittedly the algorithm does not create perfect symmetry but the idea > > here was to have more regular > > point density around the sphere > > > > Guenther > > > > > > > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > doug moen <mailto:doug@moens.org> > July 26, 2015 at 15:23 > I looked at sphere10.stl, and as you say, it has "almost constant > point density", which is not the same as the maximally constant point > density and maximal symmetry that you get from a geodesic sphere > (called an "isosphere" in Blender). Sphere10.stl is irregular, and not > very symmetrical: some of the facets appear to be equilateral > triangles, but some of them are non-equilateral triangles, and some of > them are squares. > > I'd rather have the real thing: an OpenSCAD primitive that constructs > a true geodesic sphere. > > As a point of terminology, I don't much like "icosphere" because it's > Blender specific. The proper and more well known name for the shape > (and the name used by Wikipedia) is "geodesic sphere". > > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > Guenther Sohler <mailto:mail@guenther-sohler.net> > July 26, 2015 at 10:35 > > Hi Group, > > > > I have realized, that the exising implementation of spheres have higher > > vertex densities > > at the polar region due the method how its implemented. > > > > So I have created a fast algorithm to create an almost constant point > > density all over its surface. > > See some samples: > > > > If this is interesting, I can provide a c sample such that it can be > > integrated into openscad. > > > > Guenther > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
M
MichaelAtOz
Mon, Jul 27, 2015 4:58 AM

+1 for symmetry. Currently you get different interfaces to a surface when you
rotate a sphere, needing manual adjustment sometimes.


Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/

View this message in context: http://forum.openscad.org/New-Algorithm-for-Spheres-tp13306p13317.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

+1 for symmetry. Currently you get different interfaces to a surface when you rotate a sphere, needing manual adjustment sometimes. ----- Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ -- View this message in context: http://forum.openscad.org/New-Algorithm-for-Spheres-tp13306p13317.html Sent from the OpenSCAD mailing list archive at Nabble.com.
J
Jamie_K
Tue, Apr 12, 2016 7:48 AM

Sorry for resurrecting an old post but I think it's relevant.  I've
constructed a geodesic equivalent to sphere() as a module in OpenSCAD.  The
algorithm is hardly original, recursively subdividing an icosahedron, but I
feel the implementation is relatively simple.  This code also respects $fn,
$fa, and $fs with the intent of being a drop-in replacement for those cases
when you want the geodesic sphere instead of the default.

Since subdivision always quadruples the number of facets and cuts edge
length in half, there is a fair bit of quantization when choosing the
subdivision level, but it's fairly straightforward: compute the log base 2
of the requested side length or angle compared to the icosahedron starting
point, and round up to the next integer so the subdivision will be at least
as fine as implied by $fn, or by the coarser of $fa, or $fs.

I've also put this on thinigverse here:
http://www.thingiverse.com/thing:1484333

I got started on this because Google didn't seem to find any easy-to-use
geodesics in OpenSCAD, and because it's fun!

-Jamie

http://forum.openscad.org/file/n17062/geodesic_sphere.png

--
View this message in context: http://forum.openscad.org/New-Algorithm-for-Spheres-tp13306p17062.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Sorry for resurrecting an old post but I think it's relevant. I've constructed a geodesic equivalent to sphere() as a module in OpenSCAD. The algorithm is hardly original, recursively subdividing an icosahedron, but I feel the implementation is relatively simple. This code also respects $fn, $fa, and $fs with the intent of being a drop-in replacement for those cases when you want the geodesic sphere instead of the default. Since subdivision always quadruples the number of facets and cuts edge length in half, there is a fair bit of quantization when choosing the subdivision level, but it's fairly straightforward: compute the log base 2 of the requested side length or angle compared to the icosahedron starting point, and round up to the next integer so the subdivision will be at least as fine as implied by $fn, or by the coarser of $fa, or $fs. I've also put this on thinigverse here: http://www.thingiverse.com/thing:1484333 I got started on this because Google didn't seem to find any easy-to-use geodesics in OpenSCAD, and because it's fun! -Jamie <http://forum.openscad.org/file/n17062/geodesic_sphere.png> -- View this message in context: http://forum.openscad.org/New-Algorithm-for-Spheres-tp13306p17062.html Sent from the OpenSCAD mailing list archive at Nabble.com.