SphericalCoordinates

Author: Bérenger.

Description
This a class to manipulate an object's position with spherical coordinates instead of cartesian coordinates (Vector3). This is heavily based upon this implementation : http://blog.nobel-joergensen.com/2010/10/22/spherical-coordinates-in-unity/. Here is the description given there : Spherical coordinate system is an alternative coordinate system, where two orthogonale coordinate axis define the world space in 3D.

The zenith axis points upwards and the azimuth axis points to the side. To define a point in this system the following is needed:

* Radius: the distance from the origin to the point * Elevation angle: the angle between the plane (with zenith axis as normal) and the line from the origin to the point * Polar angle: the rotation around the zenith axis

Elevation angle and polar angles are basically the same as latitude and longitude. Note that a point specified in spherical coordinates may not be unique. The spherical coordinate system I’ll be looking at, is the one where the zenith axis equals the Y axis and the azimuth axis equals the X axis.

All angles are in radians.

Usage
Once the instance is created, you can manipulate it through the Rotate functions or the Translate functions. Here is an example for a camera script :