#### Archived

This topic is now archived and is closed to further replies.

# Un-Rotating

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

## Recommended Posts

I am using Euler rotations to find a vector based upon two coordinates (x,y) witch define a point on the outside of a sphere with size 1, (position on the bent plain). My problem comes in when I have the vector and need to retrive the coordinates, here is my function for getting the vector I would appriciate a modification that does the revearse

vector3f M_GetSpherePoint(unsigned int Stacks,unsigned int Slices,float Size, float x, float y)
{
vector3f ret={
cos(y*(pi/(Slices/2)))*Size*sin(x*(pi/(Stacks/2))),
sin(y*(pi/(Slices/2)))*Size,
cos(y*(pi/(Slices/2)))*Size*cos(x*(pi/(Stacks/2)))
};
return ret;
}


Thanks! ~SPH EDIT: Note, This function allows for spheres of sizes other than 1, this can be omitted in a reverse function as the vector will be normalised. [edited by - ShmeeBegek on March 30, 2003 10:58:32 AM] [edited by - ShmeeBegek on March 30, 2003 10:58:57 AM]

##### Share on other sites
Basically you just need to use a little algebra to solve for x and y.

void GetSphereCoords( UINT stacks, UINT slices, vector3f v, float size, float &x, float &y){     y = slices * asin(v[1]/size)/ (2 * PI);     x = stacks * asin(v[0]/size/cos(2*PI*y/slices)) / (2*PI);}

The difference between us and a computer is that, the computer is blindingly stupid, but it is capable of being stupid many, many million times a second.

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633703
• Total Posts
3013455
×