Messing around with MEL again, I wanted to create a spiral path that wrapped around a sphere. Now I know how to create a 2d spiral (See previous post), and mapping this into 3 dimensions shouldn’t be too hard with handy polar coordinates.
The difference between 2d and 3d polar coordinates is an additional angle, phi, which defines the inclination of our point.
Unlike the 2d spiral where the radius increased by a fixed amount every 2pi radians, the radius on a spherical spiral remains constant; every single point will be mapped to a location on the surface of a sphere with a radius of r.
Previously, theta, went from 0 to xpi radians, where x was twice the number of revolutions our spiral went (a single revolution being 2pi).
This value of theta, together with the radius, r, defines completely a single point in 2d space, on an x\y plane, with theta being the angle around the origin.
Mapping this all onto a 3d sphere introduces the use of phi, which determines the declination of the point in 3d space, along an arc running from +z to -z (Note that for 3d polar coordinates z is considered vertical). The value of phi runs from +pi/2 (+z) to -pi/2), -z.

Spiral sphere created in MEL
This maps out to the spiral sphere shown above.
The code for this is not much more complex than for the 2d spiral: sphereSpiral.mel
Try altering the values for revolutions, resolutions and radius to get different effects.
