Solved

# How to make a sphere

Posted on 2008-06-19
7,002 Views
I want to make a sphere mesh. I want the sphere to be a collection of symetrical flat faces. The is, the sphere is made up of some number of polygons, all of which are the same size.

Please give a really good explantional (mathmatical) about how this is done.

thanks,
Matthew
0
Question by:mattososky
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 10
• 7
• 7
• +2

LVL 27

Accepted Solution

d-glitch earned 150 total points
ID: 21826478
What you are asking may not be possible.

There are the Platonic Solid (regular polyhedra)
http://mathworld.wolfram.com/PlatonicSolid.html

The most spherical is probably the duodecahedron (12 pentagons)

Then there are the Archimedean Solids (semi regular)
http://mathworld.wolfram.com/ArchimedeanSolid.html

The most spherical is probably the soccer ball, but it uses two different polygons.
0

LVL 27

Expert Comment

ID: 21826512
The Soccer Ball is properly called a Truncated Icosahedron
http://mathworld.wolfram.com/TruncatedIcosahedron.html

You can approximate a sphere with other polygons (triangles for exampe), but you can not guarantee that they will be the same size or shape.  In fact, you can guarantee that they won't be.
0

LVL 27

Expert Comment

ID: 21826561
Take a look at the Geodesic Dome:
http://mathworld.wolfram.com/GeodesicDome.html

How close an approximation to you need??
0

LVL 84

Assisted Solution

ozo earned 150 total points
ID: 21826580
0

Author Comment

ID: 21826693
It would be really convienent if all the faces were the same. Since that's apprentent not possible, the goal would be to limite the variation and number of faces as much as possible. Using the 'soccer-ball' method, it is possible to use the two shapes, a pentagon and hexagon without variying the face size, and using any number of faces?
0

LVL 27

Expert Comment

ID: 21826870
No.  You can't add more faces to the soccer ball.

You can add faces to a geodesic dome, but not an arbitrary number.

What are you trying to do??
0

Author Comment

ID: 21826916
programming a scene where I am representing a planet. I want to be able to move for and away from the planet and have a good representation of varying terrain.

The real trick is the transition between being far enough out that the suface of the sphere has no relief, and coming to the point where it starts to. The logical way I see to handle this is to create a spehere made up of large number of flat surfaces, each of which has its own relief pattern. When the camera is close enough to an individual surface the relief of that surface, and a nunder of the surrounding ones, will become visible, this will act as a smooth transition to the surface of the planet.

In order to do this, I need to be able to break the surface of this planet up into roughy equal sections that are mapped.
0

LVL 27

Expert Comment

ID: 21826956
Going back to geodesic domes:

Take the first triangulation of the duodecahedron:

I believe when you can replace each pentagon with five identical triangles.
So the sphere can be covered with 60 identical triangles.
The triangles are indentical, but isosceles not equilateral.

So in the next step, when you replace each triangle with three smaller triangles, they will not be identical.  You will need 180 triangles, but only two different shapes.

It gets worse from there, but that is quite a good approximation to a sphere.

Does it have to be better than that??
0

LVL 4

Expert Comment

ID: 21826974
Hi

A question: What engine are you using?
If you're using OpenGL you can use MipMaps to achieve this kind of effect with gluBuild2DMipmaps, and you prefer, you could use gluSphere to generate the mapping coords automatically...

Bye
0

Author Comment

ID: 21826992
the duodecahedron will not work. It's way too far from sphereical.

I need to formula which allows me to stipulate a variable number of surfaces which make up the sphere.

The geodesical dome might work, except the sufaces seem to be highly variable in size, which will not work either.
0

Author Comment

ID: 21826998
I do not want a api specific solution, nor do I want to achieve the effect with texturing.
0

LVL 4

Assisted Solution

anmalaver earned 100 total points
ID: 21827026
Ok...

So try using geodesic dome, and if you want to use different detail levels, i suggest you to use Octrees, to achieve a good performance.

http://www.gamedev.net/reference/articles/article1485.asp
http://en.wikipedia.org/wiki/Octree
0

LVL 27

Expert Comment

ID: 21827139
You have a sphere.  You know how big it is.

So you can find the area:   A = 4 * Pi * rÂ²

You know how many faces you want: Call it n.
So take N equilateral triangles (or squares, or pentagons, or octogons) each with area  A/n.

Start pasting them on the sphere.  They won't fit perfectly.
When you're done, you'll have to tweak everything.
You will probably wind up with a lot of different shapes.
0

Author Comment

ID: 21827160
what do you mean, 'alot of different shapes'?  You specify using the ~ N equilateral triangles (or squares, or pentagons, or octogons) each with area  A/n.

this method might over strictly using a slight overlap, if I use a sufficant number of faces. I'll have to try it.
0

LVL 84

Expert Comment

ID: 21829966
starting with a triangles from an icosahedron like
[
[[0,-1,\$p],[0,1,\$p],[\$p,0,1]],
[[0,-1,\$p],[0,1,\$p],[\$p,0,-1]],
[[0,-1,-\$p],[0,1,-\$p],[-\$p,0,1]],
[[0,-1,-\$p],[0,1,-\$p],[-\$p,0,-1]],

[[-1,\$p,0],[1,\$p,0],[0,1\$,p]],
[[-1,\$p,0],[1,\$p,0],[0,-1,\$p]],
[[-1,-\$p,0],[1,-\$p,0],[0,1,-\$p]],
[[-1,-\$p,0],[1,-\$p,0],[0,-1,-\$p]],

[[\$p,0,-1],[\$p,0,1],[1,\$p,0]],
[[\$p,0,-1],[\$p,0,1],[-1,\$p,0]],
[[-\$p,0,-1],[-\$p,0,1],[1,-\$p,0]],
[[-\$p,0,-1],[-\$p,0,1],[-1,-\$p,0]],

[[0,1,\$p],[1,\$p,0],[\$p,0,1]],
[[0,1,-\$p],[1,\$p,0],[\$p,0,-1]],
[[0,-1,\$p],[1,-\$p,0],[\$p,0,1]],
[[0,-1,-\$p],[1,-\$p,0],[\$p,0,-1]],
[[0,1,\$p],[-1,\$p,0],[-\$p,0,1]],
[[0,1,-\$p],[-1,\$p,0],[-\$p,0,-1]],
[[0,-1,\$p],[-1,-\$p,0],[-\$p,0,1]],
[[0,-1,-\$p],[-1,-\$p,0],[-\$p,0,-1]],
]
where
\$p=(1+sqrt 5)/2;
you can subdivide them triangles with vertices at
\$p = \$p0*sin((1-\$t0)*\$w)+\$p1*sin((1-\$t1)*\$w)+\$p2*sin((1-\$t2)*\$w);
\$p = \$p/sqrt(\$p Â· \$p);
where \$w = arccos((1+sqrt 5)/sqrt(20+8*sqrt 5));
for 3 t values of the form
(\$t0,\$t1,\$t2) = (i/n,j/n,(n-i-j)/n))
(\$t0,\$t1,\$t2) = (i+1)/n,j/n,(n-i-j-1)/n)
(\$t0,\$t1,\$t2) = (i/n,(j+1)/n,(n-i-j-1)/n)
where 0 <= i+j < n,
or
(\$t0,\$t1,\$t2) = (i/n,j/n,(n-i-j)/n))
(\$t0,\$t1,\$t2) = (i-1)/n,j/n,(n-i-j+1)/n)
(\$t0,\$t1,\$t2) = (i/n,(j-1)/n,(n-i-j+1)/n)
where 0 < i+j <= n
and (\$p0,\$p1,\$p2) = one of the above triangles

0

LVL 27

Expert Comment

ID: 21834665
Here is a more organized way to cover the sphere:

You have a sphere.  You know how big it is.
So you can find the area:   A = 4 * Pi * rÂ²

You know how many faces you want: Call it n.
So take N squares with area  A/n.

The edge dimension of each square is  s = sqrt( A/n).

Put a belt of squares around the equator.

You will need approximately   K  =  nint( 2 * Pi * r / s)  squares.

Adjust the dimensions slightly so that they fit and have the same area.

Work your way toward the poles.  You will need approximately K rows.

Because of symmetry, you will only need approx K/2 distinct shapes.
Most of the shapes will be spherical trapezoids.

When you get near the polar cap, you can switch to either a single regular polygon or set of triangles (pie slices).
0

Author Comment

ID: 21834804
d-glitch, this is the way most sphere mesh creating programs work, when you say you will only have k/2 shapes, this is true. But for a well defined sphere, it would be well into the hunders.

Again, one patter would be best (I realize not possible); two patters is very doable, at three we are getting into looking for a completely different way of accomplishing this. Having 10's of different shapes (or more) is not an option.
0

LVL 84

Expert Comment

ID: 21834911
> I need to be able to break the surface of this planet up into roughy equal sections
How roughly equal to they need to be?
Would the triangles generated by http:#a21829966 be close enough?
If not it may be possible to tweak them to be a little closer.
Would you prefer to allow a slight distortion of the sphere to make the triangle
areas slightly closer?
0

Author Comment

ID: 21834964
(ozo) they need to be sections that I can map definitions to. If every one of them is difference (or lots of them a difference, then I need alot of definitions and thats not going to work.

I am still considering your technical post. I can't just look at that and understand what you saying, I'm going to need to plug that into code. May take a little while but i'll get to it.

Maybe another way to state the problem would be this. Is it possible to break up the sphere, not into a group a flat polgons, but a group of polygons which represents part of the curvature.  A hemisphere would be an example of this. How far down can that concept be taken?
0

LVL 84

Expert Comment

ID: 21835017
0

LVL 84

Expert Comment

ID: 21835129
here's a close to uniform tesselation
http://public.lanl.gov/ringler/files/2001.11.01.EOS.pdf
0

Author Comment

ID: 21835294
The concept of the  Dodecahedral Sphere looks very promising. Please give me some time to consider it.
0

LVL 84

Expert Comment

ID: 21835416
0

LVL 22

Assisted Solution

ID: 21846857
Just start with any platonic solid (cube is easy), then recursively tessellate the faces until you have the approximation you want.
0

LVL 22

Expert Comment

ID: 21846873
After tesselation, all the faces will be congruent isoceles triangles.  However, I'm not sure if that meets your 'symmetrical' requirement.
0

LVL 84

Expert Comment

ID: 21848132
after tessellation, the faces will be only approximately congruent.
0

LVL 22

Expert Comment

ID: 21848221
Wait, you're right.  When an isosceles triangle is tesselated, you get 2 congruent triangles and another triangle different from the first two.
0

Author Comment

ID: 21848465
What  a pain this is. While some of these solutions definately fit the bill of the original problem I proposed, the solution will only really work if there the polygons that make up the surface of the sphere are similar in shape and orientation.

I think I'm going to try a difference approach. I will construct a algorithm that build a sphere mesh in the traditional method, as a series of elipsodial rectacngles with a triangle fan at both poles. This is not what I really wanted, but I think it will be easier to map the elipsodial rectangles to a 'map' than to try to map triangles of different orientations to a map.

Everyone who contributed to this solution will get credit.
Thanks!
0

Author Closing Comment

ID: 31468967
Thanks for the input!
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

### Suggested Solutions

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a Gâ€¦
How to Win a Jar of Candy Corn: A Scientific Approach! I love mathematics. If you love mathematics also, you may enjoy this tip on how to use math to win your own jar of candy corn and to impress your friends. As I said, I love math, but I guâ€¦
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaacâ€¦
###### Suggested Courses
Course of the Month7 days, 21 hours left to enroll