Sign in to follow this  
smc

Sphere point to circle point

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


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


Link to post
Share on other sites

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