Code covered by the BSD License  

Highlights from
Oblique Spherical Triangle toolbox

image thumbnail
from Oblique Spherical Triangle toolbox by Rody Oldenhuis
solves the general oblique spherical triangle

asa(A, B, c)
function [C1, a1, b1, C2, a2, b2] = asa(A, B, c)
%ASA   gives both solutions to the angle-side-angle problem, in radians.
%
%   ASA(A, B, c) returns the missing values C, a, b. It uses the
%   four-quadrant arccosine function ACOS2 to determine these values.
%
%   See also ACOS2, ASAD.

% Rody P.S. Oldenhuis
% Delft University of Technology
% Last edited: 23/Feb/2009
    
    % first solution 
    % NOTE: normal acos (in stead of acos2) is indeed correct.
    C1 = acos( -cos(A).*cos(B) + sin(A).*sin(B).*cos(c));
    a1 = acos( (cos(A) + cos(B).*cos(C1))./(sin(B).*sin(C1)));
    b1 = acos( (cos(B) + cos(A).*cos(C1))./(sin(A).*sin(C1)));
    
    % second solution
    C2 = 2*pi - C1;
    a2 = mod((a1 + pi), 2*pi);
    b2 = mod((b1 + pi), 2*pi);

end

Contact us at files@mathworks.com