Maybe im just ignorant in this space still
It does not help that all discussions of this coordinate system talk of different orientations in each persons example instead of a unified mode. right hand left hand kdjfni3roiwjeff
In your link, z is the vertical axis. In 3js, y is the vertical axis. In my opinion this is the natural convention since every xy diagram uses y as the vertical axis. If z is added there is only room for this in the plain. Unless you exchange it for y. z is the depth value. In addition I prefer the spherical coordinates with the equator as reference and theta with -90 to +90 degrees instead of from the north pole 0 to south pole 180 degrees. But that is purely subjective.
On wiki the representation like in your link is described as inconsistent with the polar coordinates.
It depends heavily on the intended use. I also like to swap x and z because the camera is oriented in minus z by default. That looks like this, for example:
function SphericalToCartesian(r, theta, phi){
const x = r * Math.cos(theta) * Math.sin(phi);
const y = r * Math.sin(theta);
const z = r * Math.cos(theta) * Math.cos(phi);
return new THREE.Vector3(x, y, z);
}
// theta = 90
// +y -z phi = +/- 180
// | /
// | /
// phi = -90 -x ________|/________ +x phi = +90
// /|
// / |
// / |
// phi = 0 +z -y
// theta = -90
As a physicist, I am very mathematically inclined and I wonder why people like to swap y with z as soon as it becomes three-dimensional. I personally find this confusing. I think it’s logical that the z axis is in the plane.
If you want theta and phi to be swapped, then suggestions would be the right topic.
But z and y will certainly not be swapped and I think that’s a good thing because in my opinion it’s good and natural as it is.
Here’s a reason why I flipped the Y and Z axis: my game is a top-down game where the world is rendered in front of the camera rather than underneath it. This allows the world to just use X and Y coordinates (which I find more intuitive) and eliminates gimbal lock.
As for spherical coordinates, their conversion into Cartesian can be done with different sets of equations – it depends on the direction of axis and on angles (where is their origin and direction). So, for me the coordinates are not flipped – it is just that there are several possible sets.