I need to calculate the angle in degrees between two points, with a fixed point that is connected with the given two points by a line.
Here is an image that illustrates what I need:
Here is what I have tried so far:
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));
}
It's pointless to say that it doesn't provide the correct answer.