python - Hyper-spherical Coordinates Implementation -


does know of well-tested, reliable implementation of hyper-spherical coordinates, converting cartesian vectors spherical angles? i'd prefer python can translate if necessary.

in other words, opposite of this question.

before tell me it's trivial implement, here implementation (for 5 dimensional space):

def theta(x):    n = 5    x = np.array(x)    tofill = np.array([0.0, 0.0, 0.0, 0.0])    r_array = np.sqrt( np.array( [ sum( [xj**2 xj in x[i+1:]] ) in range(0,n-1) ] ) )    k in range(0,n-2):        tofill[k] = np.arctan2( r_array[k] , x[k] )     tofill[n-2] = 2 * np.arctan2( x[n-1] , ( x[n-2] + np.sqrt(x[n-1]**2 + x[n-2]**2) ) )     return tofill 

note care angles, not radius. implementation here.

it seems work, i'm getting odd results in simulations (which think may due method, though haven't found problem directly yet). if can see boundary condition issues here, please let me know.


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -