SPHERICALANGLE Compute angle between points on the sphere.

   ALPHA = sphericalAngle(P1, P2, P3)
   Computes angle (P1, P2, P3), i.e. the angle, measured at point P2,
   between the direction (P2, P1) and the direction (P2, P3).
   The result is given in radians, between 0 and 2*PI.

   Points are given either as [x y z] (there will be normalized to lie on
   the unit sphere), or as [phi theta], with phi being the longitude in [0
   2*PI] and theta being the elevation on horizontal [-pi/2 pi/2].


   NOTE: 
   this is an 'oriented' version of the angle computation, that is, the
   result of sphericalAngle(P1, P2, P3) equals
   2*pi-sphericalAngle(P3,P2,P1). To have the more classical relation
   (with results given betwen 0 and PI), it suffices to take the minimum
   of angle and 2*pi-angle.
   
   Examples
     % Use inputs as cartesian coordinates   
     p1 = [0 1 0];
     p2 = [1 0 0];
     p3 = [0 0 1];
     alpha = sphericalAngle(p1, p2, p3)
     alpha =
         1.5708

     % Use inputs as spherical coordinates   
     sph1 = [.1 0];
     sph2 = [0 0];
     sph3 = [0 .1];
     alphas = sphericalAngle(sph1, sph2, sph3)
     alphas =
         1.5708
 

   See also:
   geom3d, angles3d, spheres, sph2cart

Package: matgeom