angle function
assume p1(x1, y1) is the center, the angle of the line between p1 and p2 rotates from the vertical Y axis line of the coordinates
Implementation
double angle(num x1, num y1, num x2, num y2) {
final sx = x1 - x2;
final sy = y1 - y2;
final dx = sx.abs();
final dy = sy.abs();
final d = math.sqrt(dx * dx + dy * dy);
double angle = (math.asin(dy / d) / math.pi * 180);
if (x2 >= x1) {
if (y2 >= y1) {
angle = 90 + angle;
} else {
angle = 90 - angle;
}
} else {
if (y2 >= y1) {
angle = -(90 + angle);
} else {
angle = -(90 - angle);
}
}
return angle;
}