java - Angle between two points -
For example, I have points A and B, for example, there is a need to get an angle between the two points on the flat I
For example, here is an image:
monastery. Dangrej (Mutt (Math (Point BC - point), Math. BAS (Point BX - PointX));
This calls the inverse tangent function to find the angle based on the length of the opposite angle triangle and the length of adjacent sides. However, if you should add this statement:
if (! (PointAX == pointBX || pointAY == pointBY) {angle = Math.toDegrees (Math.atan (Math.abs ( Pointb-point), Math.bas (point bx-pointx)); }
Otherwise you can create an exception because the angle is 90 or 0 degrees, if the tone function breaks.
pointAX
and dot bx
are the x coordinates of the points, while pointAY
and pointBY
numbers KY coordinates.
This function gets the full value of the difference between the coordinates (hence the opposite of the right-angle triangle formed from two points and the length of adjacent sides) and then acts inversely on them, which angle Searches
Comments
Post a Comment