Skip to content

Instantly share code, notes, and snippets.

@mayakraft
Created November 30, 2011 02:20
Show Gist options
  • Save mayakraft/1407698 to your computer and use it in GitHub Desktop.
Save mayakraft/1407698 to your computer and use it in GitHub Desktop.
3D coordinates and related functions for the platonic solids
// the 5 platonic solids
//
// + point coordinates
// + the related drawing functions
// + a rotate in 3D function, around the origin
//
// written for Processing (processing.org)
int xCenter = // center of polyhedra
int yCenter = // center of polyhedra
int r = // radius of polyhedra(approximately in pixels)
float phi = (float)(1+Math.sqrt(5))/2;
float sqrt3 = (float)Math.sqrt(3);
tetrahedronX[0] = 1/sqrt3; tetrahedronY[0] = 1/sqrt3; tetrahedronZ[0] = 1/sqrt3;
tetrahedronX[1] = -1/sqrt3; tetrahedronY[1] = 1/sqrt3; tetrahedronZ[1] = -1/sqrt3;
tetrahedronX[2] = -1/sqrt3; tetrahedronY[2] = -1/sqrt3; tetrahedronZ[2] = 1/sqrt3;
tetrahedronX[3] = 1/sqrt3; tetrahedronY[3] = -1/sqrt3; tetrahedronZ[3] = -1/sqrt3;
octahedronX[0] = 0; octahedronY[0] = 1; octahedronZ[0] = 0;
octahedronX[1] = 1; octahedronY[1] = 0; octahedronZ[1] = 0;
octahedronX[2] = 0; octahedronY[2] = 0; octahedronZ[2] = 1;
octahedronX[3] = -1; octahedronY[3] = 0; octahedronZ[3] = 0;
octahedronX[4] = 0; octahedronY[4] = 0; octahedronZ[4] = -1;
octahedronX[5] = 0; octahedronY[5] = -1; octahedronZ[5] = 0;
hexahedronX[0] = 1/sqrt3; hexahedronY[0] = 1/sqrt3; hexahedronZ[0] = 1/sqrt3;
hexahedronX[1] = -1/sqrt3; hexahedronY[1] = 1/sqrt3; hexahedronZ[1] = 1/sqrt3;
hexahedronX[2] = 1/sqrt3; hexahedronY[2] = 1/sqrt3; hexahedronZ[2] = -1/sqrt3;
hexahedronX[3] = -1/sqrt3; hexahedronY[3] = 1/sqrt3; hexahedronZ[3] = -1/sqrt3;
hexahedronX[4] = 1/sqrt3; hexahedronY[4] = -1/sqrt3; hexahedronZ[4] = 1/sqrt3;
hexahedronX[5] = -1/sqrt3; hexahedronY[5] = -1/sqrt3; hexahedronZ[5] = 1/sqrt3;
hexahedronX[6] = 1/sqrt3; hexahedronY[6] = -1/sqrt3; hexahedronZ[6] = -1/sqrt3;
hexahedronX[7] = -1/sqrt3; hexahedronY[7] = -1/sqrt3; hexahedronZ[7] = -1/sqrt3;
icosahedronX[0] = (float)(-1/Math.sqrt(phi*phi+1)); icosahedronY[0] = (float)(1*phi/Math.sqrt(phi*phi+1)); icosahedronZ[0] = 0;
icosahedronX[1] = (float)(1/Math.sqrt(phi*phi+1)); icosahedronY[1] = (float)(1*phi/Math.sqrt(phi*phi+1)); icosahedronZ[1] = 0;
icosahedronX[2] = (float)(-1/Math.sqrt(phi*phi+1)); icosahedronY[2] = (float)(-1*phi/Math.sqrt(phi*phi+1)); icosahedronZ[2] = 0;
icosahedronX[3] = (float)(1/Math.sqrt(phi*phi+1)); icosahedronY[3] = (float)(-1*phi/Math.sqrt(phi*phi+1)); icosahedronZ[3] = 0;
icosahedronX[4] = 0; icosahedronY[4] = (float)(1/Math.sqrt(phi*phi+1)); icosahedronZ[4] = (float)(1*phi/Math.sqrt(phi*phi+1));
icosahedronX[5] = 0; icosahedronY[5] = (float)(-1/Math.sqrt(phi*phi+1)); icosahedronZ[5] = (float)(1*phi/Math.sqrt(phi*phi+1));
icosahedronX[6] = 0; icosahedronY[6] = (float)(1/Math.sqrt(phi*phi+1)); icosahedronZ[6] = (float)(-1*phi/Math.sqrt(phi*phi+1));
icosahedronX[7] = 0; icosahedronY[7] = (float)(-1/Math.sqrt(phi*phi+1)); icosahedronZ[7] = (float)(-1*phi/Math.sqrt(phi*phi+1));
icosahedronX[8] = (float)(1*phi/Math.sqrt(phi*phi+1)); icosahedronY[8] = 0; icosahedronZ[8] = (float)(1/Math.sqrt(phi*phi+1));
icosahedronX[9] = (float)(1*phi/Math.sqrt(phi*phi+1)); icosahedronY[9] = 0; icosahedronZ[9] = (float)(-1/Math.sqrt(phi*phi+1));
icosahedronX[10] = (float)(-1*phi/Math.sqrt(phi*phi+1)); icosahedronY[10] = 0; icosahedronZ[10] = (float)(1/Math.sqrt(phi*phi+1));
icosahedronX[11] = (float)(-1*phi/Math.sqrt(phi*phi+1)); icosahedronY[11] = 0; icosahedronZ[11] = (float)(-1/Math.sqrt(phi*phi+1));
dodecahedronX[0] = 1/sqrt3; dodecahedronY[0] = 1/sqrt3; dodecahedronZ[0] = 1/sqrt3;
dodecahedronX[1] = 1/sqrt3; dodecahedronY[1] = 1/sqrt3; dodecahedronZ[1] = -1/sqrt3;
dodecahedronX[2] = 1/sqrt3; dodecahedronY[2] = -1/sqrt3; dodecahedronZ[2] = 1/sqrt3;
dodecahedronX[3] = 1/sqrt3; dodecahedronY[3] = -1/sqrt3; dodecahedronZ[3] = -1/sqrt3;
dodecahedronX[4] = -1/sqrt3; dodecahedronY[4] = 1/sqrt3; dodecahedronZ[4] = 1/sqrt3;
dodecahedronX[5] = -1/sqrt3; dodecahedronY[5] = 1/sqrt3; dodecahedronZ[5] = -1/sqrt3;
dodecahedronX[6] = -1/sqrt3; dodecahedronY[6] = -1/sqrt3; dodecahedronZ[6] = 1/sqrt3;
dodecahedronX[7] = -1/sqrt3; dodecahedronY[7] = -1/sqrt3; dodecahedronZ[7] = -1/sqrt3;
dodecahedronX[8] = 0; dodecahedronY[8] = 1/(phi*sqrt3); dodecahedronZ[8] = phi/sqrt3;
dodecahedronX[9] = 0; dodecahedronY[9] = 1/(phi*sqrt3); dodecahedronZ[9] = -phi/sqrt3;
dodecahedronX[10] = 0; dodecahedronY[10] = -1/(phi*sqrt3); dodecahedronZ[10] = phi/sqrt3;
dodecahedronX[11] = 0; dodecahedronY[11] = -1/(phi*sqrt3); dodecahedronZ[11] = -phi/sqrt3;
dodecahedronX[12] = phi/sqrt3; dodecahedronY[12] = 0; dodecahedronZ[12] = 1/(phi*sqrt3);
dodecahedronX[13] = phi/sqrt3; dodecahedronY[13] = 0; dodecahedronZ[13] = -1/(phi*sqrt3);
dodecahedronX[14] = -phi/sqrt3; dodecahedronY[14] = 0; dodecahedronZ[14] = 1/(phi*sqrt3);
dodecahedronX[15] = -phi/sqrt3; dodecahedronY[15] = 0; dodecahedronZ[15] = -1/(phi*sqrt3);
dodecahedronX[16] = 1/(phi*sqrt3); dodecahedronY[16] = phi/sqrt3; dodecahedronZ[16] = 0;
dodecahedronX[17] = 1/(phi*sqrt3); dodecahedronY[17] = -phi/sqrt3; dodecahedronZ[17] = 0;
dodecahedronX[18] = -1/(phi*sqrt3); dodecahedronY[18] = phi/sqrt3; dodecahedronZ[18] = 0;
dodecahedronX[19] = -1/(phi*sqrt3); dodecahedronY[19] = -phi/sqrt3; dodecahedronZ[19] = 0;
void drawTetrahedron(){
line(xCenter+r*tetrahedronX[0],yCenter+r*tetrahedronY[0], xCenter+r*tetrahedronX[1],yCenter+r*tetrahedronY[1]);
line(xCenter+r*tetrahedronX[1],yCenter+r*tetrahedronY[1], xCenter+r*tetrahedronX[2],yCenter+r*tetrahedronY[2]);
line(xCenter+r*tetrahedronX[2],yCenter+r*tetrahedronY[2], xCenter+r*tetrahedronX[0],yCenter+r*tetrahedronY[0]);
line(xCenter+r*tetrahedronX[0],yCenter+r*tetrahedronY[0], xCenter+r*tetrahedronX[3],yCenter+r*tetrahedronY[3]);
line(xCenter+r*tetrahedronX[3],yCenter+r*tetrahedronY[3], xCenter+r*tetrahedronX[1],yCenter+r*tetrahedronY[1]);
line(xCenter+r*tetrahedronX[2],yCenter+r*tetrahedronY[2], xCenter+r*tetrahedronX[3],yCenter+r*tetrahedronY[3]);
}
void drawOctahedron(){
line(xCenter+r*octahedronX[0],yCenter+r*octahedronY[0], xCenter+r*octahedronX[1],yCenter+r*octahedronY[1]);
line(xCenter+r*octahedronX[1],yCenter+r*octahedronY[1], xCenter+r*octahedronX[2],yCenter+r*octahedronY[2]);
line(xCenter+r*octahedronX[2],yCenter+r*octahedronY[2], xCenter+r*octahedronX[0],yCenter+r*octahedronY[0]);
line(xCenter+r*octahedronX[0],yCenter+r*octahedronY[0], xCenter+r*octahedronX[3],yCenter+r*octahedronY[3]);
line(xCenter+r*octahedronX[3],yCenter+r*octahedronY[3], xCenter+r*octahedronX[4],yCenter+r*octahedronY[4]);
line(xCenter+r*octahedronX[4],yCenter+r*octahedronY[4], xCenter+r*octahedronX[0],yCenter+r*octahedronY[0]);
line(xCenter+r*octahedronX[5],yCenter+r*octahedronY[5], xCenter+r*octahedronX[4],yCenter+r*octahedronY[4]);
line(xCenter+r*octahedronX[4],yCenter+r*octahedronY[4], xCenter+r*octahedronX[1],yCenter+r*octahedronY[1]);
line(xCenter+r*octahedronX[1],yCenter+r*octahedronY[1], xCenter+r*octahedronX[5],yCenter+r*octahedronY[5]);
line(xCenter+r*octahedronX[5],yCenter+r*octahedronY[5], xCenter+r*octahedronX[2],yCenter+r*octahedronY[2]);
line(xCenter+r*octahedronX[2],yCenter+r*octahedronY[2], xCenter+r*octahedronX[3],yCenter+r*octahedronY[3]);
line(xCenter+r*octahedronX[3],yCenter+r*octahedronY[3], xCenter+r*octahedronX[5],yCenter+r*octahedronY[5]);
}
void drawHexahedron(){
line(xCenter+r*hexahedronX[0],yCenter+r*hexahedronY[0], xCenter+r*hexahedronX[1],yCenter+r*hexahedronY[1]);
line(xCenter+r*hexahedronX[1],yCenter+r*hexahedronY[1], xCenter+r*hexahedronX[3],yCenter+r*hexahedronY[3]);
line(xCenter+r*hexahedronX[3],yCenter+r*hexahedronY[3], xCenter+r*hexahedronX[2],yCenter+r*hexahedronY[2]);
line(xCenter+r*hexahedronX[2],yCenter+r*hexahedronY[2], xCenter+r*hexahedronX[0],yCenter+r*hexahedronY[0]);
line(xCenter+r*hexahedronX[0],yCenter+r*hexahedronY[0], xCenter+r*hexahedronX[4],yCenter+r*hexahedronY[4]);
line(xCenter+r*hexahedronX[4],yCenter+r*hexahedronY[4], xCenter+r*hexahedronX[5],yCenter+r*hexahedronY[5]);
line(xCenter+r*hexahedronX[5],yCenter+r*hexahedronY[5], xCenter+r*hexahedronX[7],yCenter+r*hexahedronY[7]);
line(xCenter+r*hexahedronX[7],yCenter+r*hexahedronY[7], xCenter+r*hexahedronX[6],yCenter+r*hexahedronY[6]);
line(xCenter+r*hexahedronX[6],yCenter+r*hexahedronY[6], xCenter+r*hexahedronX[4],yCenter+r*hexahedronY[4]);
line(xCenter+r*hexahedronX[1],yCenter+r*hexahedronY[1], xCenter+r*hexahedronX[5],yCenter+r*hexahedronY[5]);
line(xCenter+r*hexahedronX[3],yCenter+r*hexahedronY[3], xCenter+r*hexahedronX[7],yCenter+r*hexahedronY[7]);
line(xCenter+r*hexahedronX[2],yCenter+r*hexahedronY[2], xCenter+r*hexahedronX[6],yCenter+r*hexahedronY[6]);
}
void drawIcosahedron(){
line(xCenter+r*icosahedronX[1],yCenter+r*icosahedronY[1], xCenter+r*icosahedronX[8],yCenter+r*icosahedronY[8]);
line(xCenter+r*icosahedronX[8],yCenter+r*icosahedronY[8], xCenter+r*icosahedronX[4],yCenter+r*icosahedronY[4]);
line(xCenter+r*icosahedronX[4],yCenter+r*icosahedronY[4], xCenter+r*icosahedronX[5],yCenter+r*icosahedronY[5]);
line(xCenter+r*icosahedronX[5],yCenter+r*icosahedronY[5], xCenter+r*icosahedronX[10],yCenter+r*icosahedronY[10]);
line(xCenter+r*icosahedronX[10],yCenter+r*icosahedronY[10], xCenter+r*icosahedronX[2],yCenter+r*icosahedronY[2]);
line(xCenter+r*icosahedronX[2],yCenter+r*icosahedronY[2], xCenter+r*icosahedronX[11],yCenter+r*icosahedronY[11]);
line(xCenter+r*icosahedronX[11],yCenter+r*icosahedronY[11], xCenter+r*icosahedronX[7],yCenter+r*icosahedronY[7]);
line(xCenter+r*icosahedronX[7],yCenter+r*icosahedronY[7], xCenter+r*icosahedronX[6],yCenter+r*icosahedronY[6]);
line(xCenter+r*icosahedronX[6],yCenter+r*icosahedronY[6], xCenter+r*icosahedronX[9],yCenter+r*icosahedronY[9]);
line(xCenter+r*icosahedronX[9],yCenter+r*icosahedronY[9], xCenter+r*icosahedronX[1],yCenter+r*icosahedronY[1]);
line(xCenter+r*icosahedronX[1],yCenter+r*icosahedronY[1], xCenter+r*icosahedronX[4],yCenter+r*icosahedronY[4]);
line(xCenter+r*icosahedronX[4],yCenter+r*icosahedronY[4], xCenter+r*icosahedronX[10],yCenter+r*icosahedronY[10]);
line(xCenter+r*icosahedronX[10],yCenter+r*icosahedronY[10], xCenter+r*icosahedronX[11],yCenter+r*icosahedronY[11]);
line(xCenter+r*icosahedronX[11],yCenter+r*icosahedronY[11], xCenter+r*icosahedronX[6],yCenter+r*icosahedronY[6]);
line(xCenter+r*icosahedronX[6],yCenter+r*icosahedronY[6], xCenter+r*icosahedronX[1],yCenter+r*icosahedronY[1]);
line(xCenter+r*icosahedronX[1],yCenter+r*icosahedronY[1], xCenter+r*icosahedronX[0],yCenter+r*icosahedronY[0]);
line(xCenter+r*icosahedronX[0],yCenter+r*icosahedronY[0], xCenter+r*icosahedronX[4],yCenter+r*icosahedronY[4]);
line(xCenter+r*icosahedronX[10],yCenter+r*icosahedronY[10], xCenter+r*icosahedronX[0],yCenter+r*icosahedronY[0]);
line(xCenter+r*icosahedronX[0],yCenter+r*icosahedronY[0], xCenter+r*icosahedronX[11],yCenter+r*icosahedronY[11]);
line(xCenter+r*icosahedronX[6],yCenter+r*icosahedronY[6], xCenter+r*icosahedronX[0],yCenter+r*icosahedronY[0]);
line(xCenter+r*icosahedronX[8],yCenter+r*icosahedronY[8], xCenter+r*icosahedronX[5],yCenter+r*icosahedronY[5]);
line(xCenter+r*icosahedronX[5],yCenter+r*icosahedronY[5], xCenter+r*icosahedronX[2],yCenter+r*icosahedronY[2]);
line(xCenter+r*icosahedronX[2],yCenter+r*icosahedronY[2], xCenter+r*icosahedronX[7],yCenter+r*icosahedronY[7]);
line(xCenter+r*icosahedronX[7],yCenter+r*icosahedronY[7], xCenter+r*icosahedronX[9],yCenter+r*icosahedronY[9]);
line(xCenter+r*icosahedronX[9],yCenter+r*icosahedronY[9], xCenter+r*icosahedronX[8],yCenter+r*icosahedronY[8]);
line(xCenter+r*icosahedronX[8],yCenter+r*icosahedronY[8], xCenter+r*icosahedronX[3],yCenter+r*icosahedronY[3]);
line(xCenter+r*icosahedronX[3],yCenter+r*icosahedronY[3], xCenter+r*icosahedronX[5],yCenter+r*icosahedronY[5]);
line(xCenter+r*icosahedronX[2],yCenter+r*icosahedronY[2], xCenter+r*icosahedronX[3],yCenter+r*icosahedronY[3]);
line(xCenter+r*icosahedronX[3],yCenter+r*icosahedronY[3], xCenter+r*icosahedronX[7],yCenter+r*icosahedronY[7]);
line(xCenter+r*icosahedronX[9],yCenter+r*icosahedronY[9], xCenter+r*icosahedronX[3],yCenter+r*icosahedronY[3]);
line(xCenter+r*icosahedronX[3],yCenter+r*icosahedronY[3], xCenter+r*icosahedronX[8],yCenter+r*icosahedronY[8]);
}
void drawDodecahedron(){
line(xCenter+r*dodecahedronX[0],yCenter+r*dodecahedronY[0], xCenter+r*dodecahedronX[12],yCenter+r*dodecahedronY[12]);
line(xCenter+r*dodecahedronX[12],yCenter+r*dodecahedronY[12], xCenter+r*dodecahedronX[13],yCenter+r*dodecahedronY[13]);
line(xCenter+r*dodecahedronX[13],yCenter+r*dodecahedronY[13], xCenter+r*dodecahedronX[1],yCenter+r*dodecahedronY[1]);
line(xCenter+r*dodecahedronX[1],yCenter+r*dodecahedronY[1], xCenter+r*dodecahedronX[16],yCenter+r*dodecahedronY[16]);
line(xCenter+r*dodecahedronX[16],yCenter+r*dodecahedronY[16], xCenter+r*dodecahedronX[0],yCenter+r*dodecahedronY[0]);
line(xCenter+r*dodecahedronX[16],yCenter+r*dodecahedronY[16], xCenter+r*dodecahedronX[18],yCenter+r*dodecahedronY[18]);
line(xCenter+r*dodecahedronX[18],yCenter+r*dodecahedronY[18], xCenter+r*dodecahedronX[4],yCenter+r*dodecahedronY[4]);
line(xCenter+r*dodecahedronX[4],yCenter+r*dodecahedronY[4], xCenter+r*dodecahedronX[8],yCenter+r*dodecahedronY[8]);
line(xCenter+r*dodecahedronX[12],yCenter+r*dodecahedronY[12], xCenter+r*dodecahedronX[2],yCenter+r*dodecahedronY[2]);
line(xCenter+r*dodecahedronX[2],yCenter+r*dodecahedronY[2], xCenter+r*dodecahedronX[17],yCenter+r*dodecahedronY[17]);
line(xCenter+r*dodecahedronX[17],yCenter+r*dodecahedronY[17], xCenter+r*dodecahedronX[3],yCenter+r*dodecahedronY[3]);
line(xCenter+r*dodecahedronX[3],yCenter+r*dodecahedronY[3], xCenter+r*dodecahedronX[13],yCenter+r*dodecahedronY[13]);
line(xCenter+r*dodecahedronX[0],yCenter+r*dodecahedronY[0], xCenter+r*dodecahedronX[8],yCenter+r*dodecahedronY[8]);
line(xCenter+r*dodecahedronX[8],yCenter+r*dodecahedronY[8], xCenter+r*dodecahedronX[10],yCenter+r*dodecahedronY[10]);
line(xCenter+r*dodecahedronX[10],yCenter+r*dodecahedronY[10], xCenter+r*dodecahedronX[2],yCenter+r*dodecahedronY[2]);
line(xCenter+r*dodecahedronX[1],yCenter+r*dodecahedronY[1], xCenter+r*dodecahedronX[9],yCenter+r*dodecahedronY[9]);
line(xCenter+r*dodecahedronX[9],yCenter+r*dodecahedronY[9], xCenter+r*dodecahedronX[11],yCenter+r*dodecahedronY[11]);
line(xCenter+r*dodecahedronX[11],yCenter+r*dodecahedronY[11], xCenter+r*dodecahedronX[3],yCenter+r*dodecahedronY[3]);
line(xCenter+r*dodecahedronX[11],yCenter+r*dodecahedronY[11], xCenter+r*dodecahedronX[7],yCenter+r*dodecahedronY[7]);
line(xCenter+r*dodecahedronX[7],yCenter+r*dodecahedronY[7], xCenter+r*dodecahedronX[19],yCenter+r*dodecahedronY[19]);
line(xCenter+r*dodecahedronX[10],yCenter+r*dodecahedronY[10], xCenter+r*dodecahedronX[6],yCenter+r*dodecahedronY[6]);
line(xCenter+r*dodecahedronX[6],yCenter+r*dodecahedronY[6], xCenter+r*dodecahedronX[19],yCenter+r*dodecahedronY[19]);
line(xCenter+r*dodecahedronX[19],yCenter+r*dodecahedronY[19], xCenter+r*dodecahedronX[17],yCenter+r*dodecahedronY[17]);
line(xCenter+r*dodecahedronX[18],yCenter+r*dodecahedronY[18], xCenter+r*dodecahedronX[5],yCenter+r*dodecahedronY[5]);
line(xCenter+r*dodecahedronX[5],yCenter+r*dodecahedronY[5], xCenter+r*dodecahedronX[9],yCenter+r*dodecahedronY[9]);
line(xCenter+r*dodecahedronX[5],yCenter+r*dodecahedronY[5], xCenter+r*dodecahedronX[15],yCenter+r*dodecahedronY[15]);
line(xCenter+r*dodecahedronX[15],yCenter+r*dodecahedronY[15], xCenter+r*dodecahedronX[7],yCenter+r*dodecahedronY[7]);
line(xCenter+r*dodecahedronX[15],yCenter+r*dodecahedronY[15], xCenter+r*dodecahedronX[14],yCenter+r*dodecahedronY[14]);
line(xCenter+r*dodecahedronX[14],yCenter+r*dodecahedronY[14], xCenter+r*dodecahedronX[4],yCenter+r*dodecahedronY[4]);
line(xCenter+r*dodecahedronX[14],yCenter+r*dodecahedronY[14], xCenter+r*dodecahedronX[6],yCenter+r*dodecahedronY[6]);
}
void rotatePoints(float[] pointsX, //
float[] pointsY, // 3 arrays of coordinates: X, Y, and Z
float[] pointsZ, //
float increment, // angle of rotation (in radians)
char axis) //axis: x=0,y=1,z=2
{
float angle;
float rad;
if(axis=='X' || axis == 'x'){
for(j=0;j<pointsX.length;j++){
rad = (float)Math.sqrt(pointsZ[j]*pointsZ[j]+pointsY[j]*pointsY[j]);
angle=(float)Math.atan2(pointsZ[j],pointsY[j]);
angle+=increment;
pointsZ[j] = (float)( rad*Math.sin(angle) );
pointsY[j] = (float)( rad*Math.cos(angle) );
}
}
else if(axis=='Y' || axis=='y'){
for(j=0;j<pointsY.length;j++){
rad = (float)Math.sqrt(pointsZ[j]*pointsZ[j]+pointsX[j]*pointsX[j]);
angle=(float)Math.atan2(pointsZ[j],pointsX[j]);
angle+=increment;
pointsZ[j] = (float)( rad*Math.sin(angle) );
pointsX[j] = (float)( rad*Math.cos(angle) );
}
}
else if(axis=='Z' || axis == 'z'){
for(j=0;j<pointsZ.length;j++){
rad = (float)Math.sqrt(pointsX[j]*pointsX[j]+pointsY[j]*pointsY[j]);
angle=(float)Math.atan2(pointsY[j],pointsX[j]);
angle+=increment;
pointsY[j] = (float)( rad*Math.sin(angle) );
pointsX[j] = (float)( rad*Math.cos(angle) );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment