Jump to content
• Advertisement

# icosphere formula

This topic is 4818 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

##### Share on other sites
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.

#### Share this 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

##### Share on other sites
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...

#### Share this 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

##### Share on other sites
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.

#### Share this post

##### Share on other sites
That's a cool document. Thx.

#### Share this post

##### Share on other sites
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

##### 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

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

##### Share on other sites
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.

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5
• Advertisement

• 18
• 20
• 13
• 14
• 9
• ### Forum Statistics

• Total Topics
633366
• Total Posts
3011527
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!