Jump to content
  • Advertisement

Archived

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

ShmeeBegek

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.

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

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 this post


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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!