0

I have the following coordinates stored in arrays that I want to convert into polar coordinates :

import numpy as np

R = 1.;
NcellB = 5;
xm = np.linspace(-R, R,NcellB);
ym = np.linspace(-R, R,NcellB);

Is there a simple and fast way to do it?

ynasroal
  • 27
  • 5
  • You can find an answer here https://stackoverflow.com/a/26757297/14280520. – lauriane.g Oct 22 '20 at 14:03
  • I saw this already, it is defined for a single couple (x, y). I was looking for a better way without having to use two for loops, which costs a bit in calculating time... – ynasroal Oct 22 '20 at 15:25
  • Both np.sqrt and np.arctan2 accept array as input, so no for loop is required. – cssstudent Mar 06 '23 at 02:54

0 Answers0