Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate a subdivided icosahedron?

I've asked some questions here and seen this geometric shape mentioned a few times among other geodesic shapes, but I'm curious how exactly would I generate one about a point xyz?

like image 705
Tom J Nowell Avatar asked Feb 18 '09 13:02

Tom J Nowell


3 Answers

There's a tutorial here.

The essential idea is to start with an icosahedron (which has 20 triangular faces) and to repeatedly subdivide each triangular face into smaller triangles. At each stage, each new point is shifted radially so it is the correct distance from the centre.

The number of stages will determine how many triangles are generated and hence how close the resulting mesh will be to a sphere.

like image 57
Mark Pattison Avatar answered Nov 13 '22 12:11

Mark Pattison


Here is one reference that I've used for subdivided icosahedrons, based on the OpenGL Red Book. The BSD-licensed source code to my iPhone application Molecules contains code for generating simple icosahedrons and loading them into a vertex buffer object for OpenGL ES. I haven't yet incorporated subdivision to improve the quality of the rendering, but it's in my plans.

like image 42
Brad Larson Avatar answered Nov 13 '22 12:11

Brad Larson


To tesselate a sphere, most people sub-divide the points linearly, but that does not produce a rounded shape.

For a rounded tesselation, rotate the two points through a series of rotations.

  1. Rotate the second point around z (by the z angle of point 1) to 0
  2. Rotate the second point around y (by the y angle of point 1) to 0 (this logically puts point 1 at the north pole).
  3. Rotate the second point around z to 0 (this logically puts point 1 on the x/y plane, which now becomes a unit circle).
  4. Find the half-angle, compute x and y for the new 3rd point, point 3.
  5. Perform the counter-rotations in the reverse order for steps 3), 2) and 1) to position the 3rd point to its destination.

There are also some mathematical considerations for values near each of the near-0 locations, such as the north and south pole, and the right-most and left-most, and fore-most and aft-most positions, so check those first and perform an additional rotation by pi/4 (45 degrees) if they're at those locations. This prevents floating point math libraries from freaking out and producing wildly out-of-character values for atan2() and other trig functions.

Hope this helps! :-)

like image 32
Rick C. Hodgin Avatar answered Nov 13 '22 13:11

Rick C. Hodgin