# Spherical coord systems

1. Oct 31, 2007

### Twinbee

What forum is most appropriate when discussing spherical coordinate systems?

Anyway, I have a couple of questions I hope someone can help with. I've gone the extra mile to draw graphics so that it's easier to understand. (http://www.skytopia.com/stuff/sphere.png).

Normally, the system of spherical coords rotates around the Z and Y axis. That picture shows a unit sphere. So the white blob is the point at Zrot=45 degrees rotation, and the blue blob is Zrot=45 & Yrot=45 (the blue blob is actually 'behind' the sphere. Back to cartesian, this means that (Zrot=45 & Yrot=45) is converted to X=0.5 Y=0.707 Z=0.5.

However, instead I want the 'Y rotation' to rotate not to the blue blob, but to the red one. This would give coords of X=0.57735... Y=0.57735... Z=0.57735... or the 'true' corner of the sphere, if such a thing could be said. Basically, the Y rotation is rotating on a special diagonal axis to achieve this.

What system of spherical coords is this called? And how do I adapt the following function, to convert the old system into this new one, so that it returns 0.57735 for x, y & z, instead of returning 0.5, 0.707 & 0.5 respectively?
Code (Text):

xyz polarToXYZ(polar3d n) {
xyz loc;
loc.z = n.r * cos(n.zang)*sin(n.yang);   // zang=z angle, yang=y angle, r=radius
loc.y = n.r * sin(n.zang);
loc.x = n.r * cos(n.zang)*cos(n.yang);
return loc;
}

Second question.
Now for a new, but I think brilliant spherical coord system I thought of - I wonder if it has a name. Basically, instead of representing an angle by the Z and Y rotation, how about if we represent the spherical angle with a single angle + a distance it travels around at that angle? For example, we start at the yellow dot, and use:

specialangle=0 & distance=0.25 (this would go in the direction behind the green central dot at the back of the sphere - 0.25 is used to show that it goes 25% around the sphere).
specialangle=0 & distance=0.5 (this would go in the same direction, but end up at the left of the sphere in the diagram)
specialangle=90 & distance=0.25 (this would end up at the top of the sphere)
specialangle=180 & distance=0.25 (this would end up in the centre front of the sphere - on the green dot in fact).
specialangle=270 & distance=0.25 (bottom of sphere)
specialangle=45 & distance=0.125 (this would end up at the red dot!!)

I'd love to know the name of this coord system - it has nice properties the others lack, including easily being able to 'shrink' or 'enlarge' an angle.

Last edited: Oct 31, 2007
2. Oct 31, 2007

### dodo

I think this is a misconception of yours. As you have probably noticed already, if your second rotation is around the Y axis, a Zrot=90 would make that second rotation useless.

For more information about spherical systems, you can check these links at Wikipedia and Wolfram MathWorld, but this is nothing that you could've got by googling yourself.

These links describe first a Zrot (similar to Longitude, if the Earth was a sphere), and then an "angle from the Z axis", that is, the deviation from the vertical. In many cases (perhaps yours) it might be more useful to consider the second angle as "elevation", the rise from the "horizon" (or "equator") towards the vertical Z axis (similar to latitude), instead of from the vertical downwards (called "colatitude", or 90 - latitude), which is what the links describe.

The formulas are pretty much the same you have, only the angles have been interpreted differently. Given a Zrot and an Elevation,
x = r . cos(Elev) . cos(Zrot)
y = r . cos(Elev) . sin(Zrot)
z = sin(Elev)​

The reason you don't get x,y,z all equal 0.57735... for the "corner" point, is that the corner point is not at angles 45, 45. To visualize this, imagine the unit sphere inscribed in a unit cube. The corner point you want is, naturally, the projection of a corner of the cube onto the sphere. But while the Zrot angle is 45, the elevation is not.

You get the Zrot=45 by travelling along a "base circle", or the "equator"; ths corresponds, in the cube, to an horizontal cross-section, which is a square, and the corner of the square is indeed at 45 degrees. But if you want now to move up, in an angle from the "ground" towards the Z axis (what I called "Elevation"), in the cube this corresponds to a cross-section which is rectangular: imagine the rectangle whose 4 corners are +1,+1,-1 and +1,+1,+1, and then the corners at the opposite diagonal, -1,-1,-1 and -1,-1,+1. This rectangle has height 1 but width sqrt(2). The elevation angle is then arctan(1 / sqrt(2)) = 35.26438968..., and applyng the formulas to this elevation and a Zrot=45, you will get x,y,z all equal to the value you want.

As for your second question, what you called "distance" is a second angle, which you just normalized by dividing it by 360, so that an angle of 360 (a full turn) corresponds to an angle of 1 in your system. You can add the same thing to the formulas for your first question, if this is useful to you. But you will always need a third number, the radius; the description on your second question travels only around the unit sphere.

Hope this helps.

3. Nov 1, 2007

### ferman

Twinbee,
If you like spherical coordinates perhaps you would visit, when you have spare time, my works on radial coordinates:
Thank you.

4. Nov 1, 2007

### Twinbee

Hi Dodo,

Quite right - it would just rotate 'on the spot', not moving at all. I'm presuming this is how the standard "spherical coord system" (e.g described at Wikipedia) works.

Correct again. To obtain 0.57735 for all three, you would need to rotate the z angle by about 35.25 degrees instead of 45, and follow that with y angle by 45 as usual.

However, what I'm talking about is (possibly a new) coordinate system where reaching the 'true corner' IS obtained by 45 on the Z, and 45 on the special tilted axis. I know this probably isn't known as "the" spherical coord system, but it must be something similar, and I'd like to know if it has a name, and if possible, the math / function code.

Yes, I guess you're right. I figured that myself too. I was just trying to help clarify things by equating it with the standard 2D polar coordinate system (except the 'distance' in our case is obviously not a true euclidean distance). I would still like to know the name of this 'new' coordinate system, and if possible, the math / function so that I can use it in my code.

True. Yes, I'm just worrying about the angle for now.

ferman, is your radial coord system similar to either of my two 'new' coordinate systems? If not, then can you give example XYZ inputs and outputs in your system?

Last edited: Nov 1, 2007
5. Nov 2, 2007

### ferman

Certainly my system of coordinates is not similar to yours.
My system of coordinates doesn't use Cartesian parameters XYZ, but radial parameters O (horizontal) H (vertical) that are measured starting from a position Oo.
From this position Oo the situation O and H depend on the angular speed Wo and Wh that we give to the coordinate O and H and of the time t during we apply the angular speeds in Wo and Wh.
My intention was alone that you can have knowledge of the existence of this type of coordinated radial.

6. Nov 4, 2007

### Chris Hillman

You seem to actually be talking about some problem involving representation of rotations, as in a course on "robot motion" or "computer vision" (do you know about the quaternionic representation ?), which would probably fit under the mathematical heading of "Lie groups", so it would go in the "Differential Geometry" forum.

As for coordinate charts on n-spheres, such as
$$ds^2 = \cos(r)^2 \, dz^2 + dr^2 + \sin(r)^2 \, d\phi^2, \; -\pi < z, \, \phi < \pi, \; 0 < r < \pi/2$$
discussion of these would again go to "Differential Geometry" forum.