Skip to content

Instantly share code, notes, and snippets.

@mvdoc
Created May 20, 2015 15:14
Show Gist options
  • Save mvdoc/8f8ea5a421b4ba09b0bf to your computer and use it in GitHub Desktop.
Save mvdoc/8f8ea5a421b4ba09b0bf to your computer and use it in GitHub Desktop.
def appendSpherical_np(xyz):
ptsnew = np.hstack((xyz, np.zeros(xyz.shape)))
xy = xyz[:,0]**2 + xyz[:,1]**2
ptsnew[:,3] = np.sqrt(xy + xyz[:,2]**2)
ptsnew[:,4] = np.arctan2(np.sqrt(xy), xyz[:,2]) # for elevation angle defined from Z-axis down
#ptsnew[:,4] = np.arctan2(xyz[:,2], np.sqrt(xy)) # for elevation angle defined from XY-plane up
ptsnew[:,5] = np.arctan2(xyz[:,1], xyz[:,0])
return ptsnew
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment