Converting Cartesian to Spherical coordinate

Started by
1 comment, last by szecs 13 years, 11 months ago
OK so i'm pretty sure this is right but before i write a whole bunch more i want to confirm. ok so i think this should give me a duplicate icosahedron that is half as big (well extends away from the middle half as far). note: Asm is for Zenith angle and Theta is for Azimuth (i mixed Zenith and Azimuth of a bit) vertices's to make icosahedron
 
const GLfloat P1[] =    {0.0f, 1.0f, G_RATIO};
const GLfloat P2[] =	{0.0f,-1.0f, G_RATIO};
const GLfloat P3[] =	{ 0.0f,-1.0f, -G_RATIO};
const GLfloat P4[] =	{0.0f, 1.0f, -G_RATIO};
const GLfloat P5[] =	{1.0f,G_RATIO, 0.0f};
const GLfloat P6[] =	{ -1.0f,G_RATIO, 0.0f};
const GLfloat P7[] =	{ -1.0f, -G_RATIO, 0.0f};
const GLfloat P8[] =	{1.0f,-G_RATIO, 0.0f};
const GLfloat P9[] =	{ G_RATIO,0.0f, 1.0f};
const GLfloat P10[] =	{ -G_RATIO, 0.0f, 1.0f};
const GLfloat P11[] =	{-G_RATIO,0.0f, - 1.0f};
const GLfloat P12[] =	{ G_RATIO,0.0f, -1.0f};


vertices's to fill

  GLfloat P1[3]; 
 GLfloat P2[3];
 GLfloat P3[3]; 
 GLfloat P4[3];
 GLfloat P5[3];
 GLfloat P6[3];
 GLfloat P7[3];
 GLfloat P8[3];
 GLfloat P9[3];
 GLfloat P10[3];
 GLfloat P11[3];
 GLfloat P12[3];


OK here is where my question is. if i repeat this process for all 12 vertices will i get what i want.

  r = sqrt(pow(P1[0],2)+pow(P1[1],2)+ pow(P1[2],2));
         theta = acos(((P1[2])/(sqrt(pow(P1[0],2)+pow(P1[1],2)+pow(P1[2],2)))));
         Asm = atan2(P1[0],P1[1]);
         r = r/2;
         RP1[0] = r*sin(theta)*cos(Asm);
         RP1[1] = r*sin(theta)*cos(Asm);
         RP1[2] = r*cos(theta);


Advertisement
OK so this didn't work at all but there was a nice pattern to it. all RP points somehow wound (seemingly, just at a glance) being coplanar. i have no clue what i did wrong could someone please help me.
Another thread?

You are making this thing waaaaay too complicated.

BTW you could just multiply every coordinates with 0.5, I have no idea why are you making it so complicated.

This topic is closed to new replies.

Advertisement