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();
verts.add(v);
}
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));
tris.add(0, tri0);
tris.add(1, tri1);
tris.add(2, tri2);
tris.add(3, tri3);
/* 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