Search code examples
pythonmap-projections

project spherical coordinates into cube python


Given a sphere radius of 1 and center at (0,0,0,), I have a list of xyz points in spherical coordinates of the form:

[-0.31828382 -0.6678262   0.67283251] # between -1 and 1

what would be the way to get their projected coordinates on a containing cube of same size?


Solution

  • You need to project this vector until one of the components first intercepts the cube boundary. Since your boundaries are -1 and +1, this is simple.

    The component with the largest magnitude is the third one, 0.672... Divide each component by that magnitude, and you have your interception point:

    [-0.31828382, -0.6678262, 0.67283251]
    [-0.47305060, -0.9925594, 1.0]
    

    Can you take it from there?