Why is the definition of Spherical coordinates in Julia strange

Hey,
I want to transform a point in a cartesian coordinate system to a spherical one.
I am using the Package CoordinateTransformations.
As I made my first steps with SphericalFromCartesian I noticed that, when writing
transf = SphericalFromCartesian()
transf(SVector(1.,0.,0.))
i receive: Spherical(r=1.0, θ=0.0 rad, ϕ=0.0 rad).
In Addition the angles are defined in complementary ranges as usual.
My Question is:
Is there a transformation that follows the usual convention. (positive z-axis sets θ=0.0, ϕ=0.0)?

Hi there - from looking at the package source code it seems that a slightly non-standard spherical coordinate system is being used. If you are used to r, theta0, phi0 (where theta0 is the angle between the cartesian vector and the positive z axis, and phi0 is the rotation around the z axis) then you can map from the package output to this system with theta0 = pi/2 - phi and phi0 = theta (or you could write your own cartesian to spherical conversion function, its just a few lines of code).

But I think the answer to your question seems to be no - I couldn’t see a transformation function in this package that does exactly what you want.

1 Like

That sounds in line with how I was taught spherical coordinates. Just thought I’d interject that it’s not “strange”, it’s just another convention.

3 Likes

For reference, this has been discussed in Document that for spherical coordinates theta is going from x to y and phi is going from xy-plane to z · Issue #25 · JuliaGeometry/CoordinateTransformations.jl · GitHub (which is considered a prerequisite for v1.0).

The subject was also partially addressed by https://github.com/JuliaGeometry/CoordinateTransformations.jl/pull/68, and has been mentioned in Add Alternative Spherical angle conventions · Issue #73 · JuliaGeometry/CoordinateTransformations.jl · GitHub.

1 Like

Thank you all for the answers. I only saw definitions equal to the wikipedia entry till now, that is why I thought that it is the (only) common convention.