I'm currently trying to convert given Cartesian coordinates (x,y,z) to spherical coordinates (r, theta, phi) using the ParaView Calculator-Filter, where theta is the polar angle and phi the azimuthal angle. This I want to do over a domain of a quarter-sphere:
(r in [r_inn, r_out], theta in [0, pi], phi in [0, 2pi].
So far I defined the following result variables that give the expected results:
r = sqrt(coordsX^2 + coordsY^2 + coordsZ^2)
theta = acos(coordsZ/r)
For the azimuthal vector I'm aware that I would have to take care of the quadrant of (x,y) when using
phi = atan(y/x).
This usually is achieved using an extra function like atan2 in C. Such a function does not seem to be supplied by the Calculator Filter or the Python Calculator Filter.
Is there any easy way to implementing something like the atan2 using the graphical interface?
Any comments are much appreciated, thanks!
UPDATE:
After Neil Twist pointed out, that in the Python Calculator the inverse tangent function can be called as arctan2(y, x), I'm now facing the problem that I can't access the coordinates of a cell via the variables coordsX/Y/Z, that are available in the simple Calculator filter.
Now, the question is: How can I access the cell coordinates in the Python calculator?