||Here is a better algorithm for finding a signed angle between two line segments with a common starting point where the angle is measured counter-clockwise from 0 to +/- pi.
double sX, sY; //the common starting point
double aX, aY, bX, bY; //the two points radiating from sX,sY
//using C# Math.Atan2(y,x) method:
double dRad1 = Math.Atan2(aY-sY,aX-sX);
double dRad2 = Math.Atan2(bY-sY,bX-sX);
double dRad = dRad2 - dRad1;
note: angles > pi are shown as (pi - angle)