我需要计算两点之间的角度度数,用一个固定点与给定的两点连线。计算两点之间的夹角 - java
这里是一个形象,说明了什么,我需要:
这里是我到目前为止已经试过:
public static float GetAngleOfLineBetweenTwoPoints(float x1, float x2, float y1, float y2) {
float xDiff = x2 - x1;
float yDiff = y2 - y1;
return (float) (Math.atan2(yDiff, xDiff) * (180/Math.PI));
}
这是毫无意义地说,它不提供正确答案。
你甚至不考虑“原产地”点的坐标目前,对不对? – qqilihq 2014-09-27 16:20:31
你的定点是什么?你还需要那个点 – 2014-09-27 16:20:32
加第三点(如@getlost提到)并使用矢量角公式:http://www.vitutor.com/geometry/vec/angle_vectors.html – maskacovnik 2014-09-27 16:22:36