Sign in to follow this  

icosphere formula

This topic is 4483 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
screenshot: http://strony.aster.pl/gzesio/blog/terr1.jpg
demo: http://strony.aster.pl/gzesio/blog/terr.zip
(click around, try [p] 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.

Share this post


Link to post
Share on other sites

This topic is 4483 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this