getDegrees
public float getDegrees(Point a, Point b) { float ax = a.x;// a.index % 3;
float ay = a.y;// a.index / 3;
float bx = b.x;// b.index % 3;
float by = b.y;// b.index / 3;
float degrees = 0; if (bx == ax) // y轴相等 90度或270 { if (by > ay) // 在y轴的下边 90 {
degrees = 90;
} else if (by < ay) // 在y轴的上边 270 {
degrees = 270;
}
} else if (by == ay) // y轴相等 0度或180 { if (bx > ax) // 在y轴的下边 90 {
degrees = 0;
} else if (bx < ax) // 在y轴的上边 270 {
degrees = 180;
}
} else { if (bx > ax) // 在y轴的右边 270~90 { if (by > ay) // 在y轴的下边 0 - 90 {
degrees = 0;
degrees = degrees + switchDegrees(Math.abs(by - ay),
Math.abs(bx - ax));
} else if (by < ay) // 在y轴的上边 270~0 {
degrees = 360;
degrees = degrees - switchDegrees(Math.abs(by - ay),
Math.abs(bx - ax));
}
} else if (bx < ax) // 在y轴的左边 90~270 { if (by > ay) // 在y轴的下边 180 ~ 270 {
degrees = 90;
degrees = degrees + switchDegrees(Math.abs(bx - ax),
Math.abs(by - ay));
} else if (by < ay) // 在y轴的上边 90 ~ 180 {
degrees = 270;
degrees = degrees - switchDegrees(Math.abs(bx - ax),
Math.abs(by - ay));
}
}
} return degrees;
}