# Why is the definition of Spherical coordinates in Julia strange

**URL:** <https://discourse.julialang.org/t/why-is-the-definition-of-spherical-coordinates-in-julia-strange/63015>\
**Category:** New to Julia\
**Tags:** question, package\
**Created:** [June 16, 2021, 1:45pm UTC](https://discourse.julialang.org/t/why-is-the-definition-of-spherical-coordinates-in-julia-strange/63015 "2021-06-16T13:45:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dennis\_West](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@Dennis\_West](https://discourse.julialang.org/u/Dennis_West)\
**Post date:** [June 16, 2021, 1:45pm UTC](https://discourse.julialang.org/t/why-is-the-definition-of-spherical-coordinates-in-julia-strange/63015/1 "2021-06-16T13:45:38Z")

</div>

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)?

---

<div class="post-metadata">

**Author:** ![pixel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pixel/32/26437_2.png) [@pixel](https://discourse.julialang.org/u/pixel)\
**Post date:** [June 16, 2021, 5:01pm UTC](https://discourse.julialang.org/t/why-is-the-definition-of-spherical-coordinates-in-julia-strange/63015/2 "2021-06-16T17:01:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [June 16, 2021, 5:35pm UTC](https://discourse.julialang.org/t/why-is-the-definition-of-spherical-coordinates-in-julia-strange/63015/3 "2021-06-16T17:35:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![waldyrious](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/waldyrious/32/80_2.png) [@waldyrious](https://discourse.julialang.org/u/waldyrious)\
**Post date:** [June 16, 2021, 9:47pm UTC](https://discourse.julialang.org/t/why-is-the-definition-of-spherical-coordinates-in-julia-strange/63015/4 "2021-06-16T21:47:38Z")

</div>

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](https://github.com/JuliaGeometry/CoordinateTransformations.jl/issues/25) (which is considered a [prerequisite for v1.0](https://github.com/JuliaGeometry/CoordinateTransformations.jl/issues/56)).

The subject was also partially addressed by [https://github.com/JuliaGeometry/CoordinateTransformations.jl/pull/68](https://github.com/JuliaGeometry/CoordinateTransformations.jl/pull/68), and has been mentioned in [https://github.com/JuliaGeometry/CoordinateTransformations.jl/issues/73](https://github.com/JuliaGeometry/CoordinateTransformations.jl/issues/73).

---

<div class="post-metadata">

**Author:** ![Dennis\_West](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@Dennis\_West](https://discourse.julialang.org/u/Dennis_West)\
**Post date:** [June 17, 2021, 8:32am UTC](https://discourse.julialang.org/t/why-is-the-definition-of-spherical-coordinates-in-julia-strange/63015/5 "2021-06-17T08:32:02Z")

</div>

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.
