int l1x = x2 - x1;
int l1y = y2 - y1;
int l2x = x3 - x1;
int l2y = y3 - y1;
float tan1 = (float)l1y/(float)l1x;
float tan2 = (float)l2y/(float)l2x;
double ang1 = Math.atan(tan1);
double ang2 = Math.atan(tan2);

This will fail because Math.atan(tangent) does not know which quadrant the line is in and returns angles that only span 180 degrees (-pi/2 to +pi/2 radians). Thus your answer might be off by 180 degrees depending on how the individual angles were rounded.

A more accurate answer would be given by using the alternate
methods Math.atan2(l1y, l1x) and Math.atan2(l2y, l2x) which
avoid the division and can return an answer accurate throughout
360 degrees (output range is -pi to +pi radians).

                       ...jim

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to