Java triangle find side length and angle

insert image description here

Code

//计算三条边

double a = Math.sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2- y3));

double b = Math.sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3));

double c = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));

//计算三个角

double A = Math.toDegrees(Math.acos((a * a - b * b - c * c) / (-2 * b * c)));

double B = Math.toDegrees(Math.acos((b * b - a * a - c * c) / (-2 * a * c)));

double C = Math.toDegrees(Math.acos((c * c - a * a - b * b) / (-2 * a * b)));

Guess you like

Origin blog.csdn.net/qq_36580022/article/details/128476557