function [a1, a2, a3] = LawOfCosines(L1, L2, L3)

% function [a1, a2, a3] = LawOfCosines(L1, L2, L3)
%
% L1, L2, and L3 are length of the sides of a triangle, and the
% outputs a1, a2, and a3 are the angles of the triangle, each
% labeled with respect to the side exactly opposite this angle.
% See also diagram below:
%
%         L3
%  a1 ---------- a2
%     \        /
%      \      /
%       \    / L1
%    L2  \  /
%         \/
%         a3

% Below is the "Law of Cosines". Angles are of course in RADIANS.
a1 = acos((-L1.^2 + L2.^2 + L3.^2)./(2*L2.*L3));
a2 = acos((-L2.^2 + L3.^2 + L1.^2)./(2*L3.*L1));
a3 = acos((-L3.^2 + L1.^2 + L2.^2)./(2*L1.*L2));