Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to project a point on to a sphere

If i have a point (x,y,z) how to project it on to a sphere(x0,y0,z0,radius) (on its surface). My input will be the coordinates of point and sphere. The output should be the coordinates of the projected point on sphere.

Just convert from cartesian to spherical coordinates?

like image 366
George Avatar asked Mar 07 '12 15:03

George


1 Answers

For the simplest projection (along the line connecting the point to the center of the sphere):

  1. Write the point in a coordinate system centered at the center of the sphere (x0,y0,z0):

    P = (x',y',z') = (x - x0, y - y0, z - z0)

  2. Compute the length of this vector:

    |P| = sqrt(x'^2 + y'^2 + z'^2)

  3. Scale the vector so that it has length equal to the radius of the sphere:

    Q = (radius/|P|)*P

  4. And change back to your original coordinate system to get the projection:

    R = Q + (x0,y0,z0)

like image 95
Stephen Canon Avatar answered Sep 18 '22 09:09

Stephen Canon