Sign in to follow this  

Converting Cartesian to Spherical coordinate

This topic is 2789 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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);


Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 2789 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this