[SciPy-User] coordinate and vector transformations between cartesian and cylindrical coordinate system

Guillaume Gay guillaume at damcb.com
Mon Jul 12 10:46:33 EDT 2021


Hi Andreas?

What exactly do you have in mind? If your positions are stored as a (n, 
3) array of points, Cartesian to cylindrical is (for example):

|rho = np.linalg.norm(pos[:, :2], axis=1) theta = np.arctan2(pos[:, 1], 
pos[:, 0]) z = pos[:, 2] |

Conversely if you have three cylindrical coordinates (rho, theta, z), 
you can get the Cartesian with:

|x = pos[:, 0] * np.cos(pos[:, 1]) y = pos[:, 0] * np.sin(pos[:, 1]) z = 
pos[:, 2] |

Hope this helps,

Best regards,
Guillaume

On 12/07/2021 16:03, Schuldei, Andreas wrote:

> Hi,
>
>
> I am looking for ways to do coordinate and vector transformations 
> between cartesian and cylindrical coordinates. Scipy has 
> scipy.spatial.transform 
> <https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.transform.Rotation.__len__.html>, 
> but no ready (easy?) way to do the transformations I look for. Is 
> there a way to use spatial.transform for this that I don't see? 
> Transformations this common surely are done frequently, but I fail to 
> find examples that I can learn from or reuse.
>
>
> Kind regards,
>
>
> Andreas
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at python.org
> https://mail.python.org/mailman/listinfo/scipy-user

​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/scipy-user/attachments/20210712/bb56ab32/attachment.html>


More information about the SciPy-User mailing list