icosphere formula

Started by
8 comments, last by Kalidor 18 years, 7 months ago
I have searched unsuccessfully for a formula to generate icospheres procedurally, so I was wondering if someone here knew one or where to find one. Essentially, I'd like the function to take a form like: Icosphere(float pos_x, float pos_y, float pos_z, float radius, int subdivisions); I can create them using a modeling program (Blender) and import them into my program, but I would really prefer to create them procedurally like this, so any help is appreciated.
Advertisement
There was a thread on different ways to tessellate a sphere in the math forum a while back. If I understand correctly, 'icosphere' refers to the 'start with an icosahedron and subdivide recursively' method. I've posted code for this on the forum in the last couple of months, but I'd have to dig around for it. Don't have time now, but if any of this sounds useful to you I could try to find the thread and/or code later today.
Maybe you are having problems with Google because it is spelled icosasphere and not icosphere?

Icosasphere has 20-sides, 12-vertices. Vertices are described by:
(+- 1, 0, +-t), (0, +-t, +-1), and (+-t, +-1, 0)
where t = (sqrt(5)-1)/2, the golden ratio.
JakeM,

I'd like to know where you got the vertex coordinates for that thing. I've been googling for 20min now with no luck. Hopefully such a resource would have vertex coordinates for other shapes too...
Are you sure you've got the name correct? I've never heard of an icosphere, but I have heard of an icosahedron, i.e. a polyhedron of 20 faces.

If you can follow the mathematics, this page provides a nice, technical explanation. There's also Wikipedia which, as usual, is a little easier to understand but consequently less thorough.
I think 'icosphere' is blender's term for a sphere constructed from an icosahedron. This document describes how to construct meshes for icosahedrons and other Platonic solids.
That's a cool document. Thx.
well, here'se the code i use (i found the basic formula on this forum, then played around with the a,b values - that's why they're so weird)
GLfloat A = 52.0f / 33.0f;GLfloat B = (26.0f / 28.0f);    (...)          new cBTNode( radius * V3d( 0, A, B ).Normalize() );    cPlanetQTNode::btr->Insert( radius * V3d( 0, A,-B ).Normalize() );    cPlanetQTNode::btr->Insert( radius * V3d( 0,-A, B ).Normalize() );    cPlanetQTNode::btr->Insert( radius * V3d( 0,-A,-B ).Normalize() );    cPlanetQTNode::btr->Insert( radius * V3d( A, B, 0 ).Normalize() );    cPlanetQTNode::btr->Insert( radius * V3d( A,-B, 0 ).Normalize() );    cPlanetQTNode::btr->Insert( radius * V3d(-A, B, 0 ).Normalize() );    cPlanetQTNode::btr->Insert( radius * V3d(-A,-B, 0 ).Normalize() );    cPlanetQTNode::btr->Insert( radius * V3d( B, 0, A ).Normalize() );    cPlanetQTNode::btr->Insert( radius * V3d( B, 0,-A ).Normalize() );    cPlanetQTNode::btr->Insert( radius * V3d(-B, 0, A ).Normalize() );    cPlanetQTNode::btr->Insert( radius * V3d(-B, 0,-A ).Normalize() );


demo
i included some src files if you're interested in the subdivision itself, though it isn't clean / nice code by any standard :)... the code also links the triangles with it's neighbours on every subdivision level, as i initialy hoped to use it for some sort of visibility algorithm, but never got around to doing that.

-
g.
screenshot: http://strony.aster.pl/gzesio/blog/terr1.jpg
demo: http://strony.aster.pl/gzesio/blog/terr.zip
(click around, try

and [v] to change the viewing angle... there'se a lot of other things in there too... (some sort of physics simulation: (r)un, (n)ew point (q) select, (c) connect 2 selected points...

g.

I'm surprised no one has posted Paul Bourke's site yet. That's a good one for all sorts of stuff, including geometry.

EDIT: Here's his Platonic Solids page, but I highly recommend the rest of his site as well.

This topic is closed to new replies.

Advertisement