PDA

Click to See Complete Forum and Search --> : How do I do a sphere with triangles?


Gen-X
May 29th, 2000, 08:05 AM
Here is what I want :

1. A Sphere
2. Comprising of Equilateral Triangle polygons

I am doing a "hobby" project in VB using Direct3D and wanted to represent the "world" using a 3D model. To do this however I need triangle polygons and I personally wanted them to be equaliateral (ie all 3 sides the same length, 60 degree angles between each).

Now I sat down and tried to work out how I would go about generating this sphere programatically and I tried many models to work out how it should work or should look.

Finally I came up with a method on how to do it :

Take a triangular pyramid, 4 sides with each side equilateral triangles. Now imagine that the very CENTRE of this object is the centre of the sphere and the 4 corners are exactly on the radius of that sphere.

If you take each of the 4 triangles and you split it into 4 triangles (Figure 1) and "raise" the 3 points of the new middle triangle such that each of these new points touch the radius of the sphere you are effectively "fleshing out" the surface so that the more times you do it the more it looks like a sphere and not a pyramid.


Figure 1 :

/\ /\
/ \ /__\
/ \ /\ /\
/______\ /__\/__\


By repeating this process with each remaining triangle I keep turning the "cut off" surfaces to a rounder surface more closely resembling the sphere.

Now what I would like to know is if anyone has any comments, ideas, critisisms or tips that would make this easier.

Is it the most effective method of generating a sphere using the conditions I require?

Is there an easy way of programatically doing this?

Do I need to brush up on anything more than geometry?

All comments welcome :)

Sam Finch
May 30th, 2000, 04:35 AM
I'm getting there, It's more graph theory than anything else, with a little bit of vector algebra thrown in.

the best way to look at it is if you have a collection of points on the sphere's surface, starting off with the four pyramid vertices, imagine them in a table like this

The ositions of each vertex shouldn't be too hard to work out, but Have them on a shpere centre 0,0,0 and radius 1.




| A B C D
A| X L L L
B| X X L L
C| X X X L
D| X X X X



The L represents a line between 2 connected verticies, a 0 will represent no line between verticies but at the moment each vertex is completley connected.


then what we do is add a new vertex for each L, we connect this to both the vericies at the end of the line and disconnect the line, our graph now looks like this



| A B C D ab ac ad bc bd cd
A| X 0 0 0 L L L 0 0 0
B| X X 0 0 L 0 0 L L 0
C| X X X 0 0 L 0 L 0 L
D| X X X X 0 0 L 0 L L
ab| X X X X X 0 0 0 0 0
ac| X X X X X X 0 0 0 0
ad| X X X X X X X 0 0 0
bc| X X X X X X X X 0 0
bd| X X X X X X X X X 0
cd| X X X X X X X X X X



we get the position of our new verticies by adding the coodrdinates of our own verticies and dividing by it's length.

and now we go through all our new points and connect them to any point that can be reached by going along exactly 2 lines. Your graph looks like this.



| A B C D ab ac ad bc bd cd
A| X 0 0 0 L L L 0 0 0
B| X X 0 0 L 0 0 L L 0
C| X X X 0 0 L 0 L 0 L
D| X X X X 0 0 L 0 L L
ab| X X X X X L L L L 0
ac| X X X X X X L L 0 L
ad| X X X X X X X 0 L L
bc| X X X X X X X X L L
bd| X X X X X X X X X L
cd| X X X X X X X X X X



And there we have step 2, now do the same again to get step 3 and keep going.

so we have all the lines that we need, the faces are any 3 points that are all interconnected.

I don't know if this is the fastest way of diong it, and you can do the coding yourself, given the huge amount of information we have to work out.

Hope this helps, Happy coding