# Tetrahedron in a unit sphere

• Nov 18th 2007, 06:54 AM
daemon2004
Tetrahedron in a unit sphere
Hi everyone, i'm in need of help with a certain aspect of my project, hopefully someone has some suggestions:

Im doing a mesh morphing program for two arbitrary genus0 meshes, i'm using the method of Marc Alexa for implementation.

However i am stuck on a certain part which says:

'Choose a random regular tetrahedron with vertices on the unit sphere'.

Ive been searching for a few days now to find out how to construct a regular tetrahedron which fits exactly (more or less) inside a unit sphere.

From what i have read, i need to have a 'circumscribed' tetrahedron', which has the sphere going outside through all the vertices in the tetrahedron.

But i am having great difficulty programming this as i cannot work out how to determine how big the tetrahedron should be so that the vertices are on the surface of the sphere.

Any help or suggestions would be greatly appreciated.

Many Thanks
Dan
• Nov 18th 2007, 08:56 AM
Plato
Are you looking for the circumradius?
• Nov 20th 2007, 10:28 AM
daemon2004
Hi there,

Thanks. I already came across that page however, it was useful for understanding tetrehedron but was hard to think of implementing it. I've actually finished a class now that will generate a regular tetrahedron for a unit sphere, ill post it on here later.

:)
• Nov 21st 2007, 07:31 AM
daemon2004
For anyone thats interested:

public
class Tetrahedron {

/*
The standard equation for points on a sphere will be used:
x = r * cos(theta) * cos(phi)
y = r * sin(theta) * cos(phi)
z = r * sin(phi)
x^2 + y^2 + z^2 = 1 for the unit sphere

The angle theta goes around the equator 0 to 360 degrees, 0 to 2Pi
The angle phi goes from north pole 90 to -90 degrees, Pi/2 to -Pi/2
Radians = Pi * (angle_in_degrees) / 180

*/

public ArrayList<GL_Vertex> verts = new ArrayList();
public ArrayList<GL_Triangle> tris = new ArrayList();

doublePi = 3.141592653589793238462643383279502884197;
doublephiaa = -19.471220333; /* the phi angle needed for generation */

public Tetrahedron(){

for(int i = 0; i<4; i++)
{
GL_Vertex v =
new GL_Vertex();
}

double r = 1.0; /* any radius in which the polyhedron is inscribed */

double phia = Pi*phiaa/180.0; /* 1 set of three points */

double the120 = Pi*120.0/180.0;
double the = 0.0;

verts.get(0).pos.x = (float) 0.0;
verts.get(0).pos.y = (float) 0.0;
verts.get(0).pos.z = (float) r;

for(int i=1; i<4; i++)
{

verts.get(i).pos.x =(float) (r*Math.cos(the)*Math.cos(phia));
verts.get(i).pos.y =(float) (r*Math.sin(the)*Math.cos(phia));
verts.get(i).pos.z =(float) (r*Math.sin(phia));
the = the+the120;
}

for(int i=0; i<4; i++){
System.
out.println(verts.get(i).toString());
}

GL_Triangle tri0 =
new GL_Triangle(verts.get(0), verts.get(1), verts.get(2));
GL_Triangle tri1 =
new GL_Triangle(verts.get(0), verts.get(2), verts.get(3));
GL_Triangle tri2 =
new GL_Triangle(verts.get(0), verts.get(3), verts.get(1));
GL_Triangle tri3 =
new GL_Triangle(verts.get(1), verts.get(2), verts.get(3));

/* map vertices to 4 faces */

//polygon(0,1,2);

//polygon(0,2,3);

//polygon(0,3,1);

//polygon(1,2,3);

//Length of every edge 1.6329932 */

}
}

Based on algorithm from : Regular Polyhedron Generators