# Sphere point to circle point

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

## Recommended Posts

I have a vector which can point to any coordinate on the top half of a unit sphere. The vector location is generated from accelerometer data. I am trying to project the position into a circle on a plane. Problem: I naively used a simple projection onto the x,y plane. As the vector approaches the x,y plane the distance traveled on the sphere surface does not correspond to the distance traveled on the x,y plane. My rusty math skills are showing. What I would like to do is project these points to a 'flattened' sphere. It would be nice if the point distance distribution was linear. For some reason I am coming up empty. I end up converting to cartesian which I do not want. Any pointers would be very helpful. Edit:<bad idea removed> [Edited by - smc on May 3, 2010 9:13:02 PM]

##### Share on other sites
I don't have a solution for you, but here's an idea that might be a little closer to what you're looking for than what you have now. (Note: all code examples are off the top and my head and untested.)

First, convert the point on the hemisphere to spherical coordinates:
float theta = 0;float l = sqrt(x * x + y * y);if (l > epsilon) {    theta = atan2(y, x);}float phi = pi_over_2 - atan2(z, l);
Map phi to the range [0, 1]:
float t = phi / pi_over_2;
Generate the final x, y position using a polar coordinate conversion:
circle_x = cos(theta) * t;circle_y = sin(theta) * t;
Anyway, that's what first comes to mind, but maybe someone else can offer a better solution.

[Edit: Fixed error in pseudocode.]

[Edited by - jyk on May 4, 2010 12:40:06 PM]

##### Share on other sites
Thank you. This works very good. Mapping to PI_OVER_2 is all I needed to change.

##### Share on other sites
Quote:
 Mapping to PI_OVER_2 is all I needed to change.
Oops, fixed - not sure what I was thinking there :-|

1. 1
Rutin
54
2. 2
3. 3
4. 4
5. 5

• 10
• 28
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633412
• Total Posts
3011734
• ### Who's Online (See full list)

There are no registered users currently online

×