I'm trying to do an arrow that points to a certain position but the problem is that when I do an angle with the vectors he can't make the difference between west and east because it's 90° in both. How can I make the west negative or add it 180° to make the difference between them ?
My code:
double angle = 0;
Vector a = (targetLoc).toVector().subtract(player.getLocation().toVector()).normalize();
Vector b = player.getLocation().getDirection();
angle = Math.acos(a.dot(b));
angle = Math.toDegrees(angle);
targetLoc is the position I want to point
For example when the coordinates are at 90° from the vision from the player the angle is 90° in west side and on est side or when the coordinates are at 45° from the vision from the player the angle is 45° in west side and on est side.
I want only to use the x and z plan not the y.
Here is what I have done thank you for your help
Vector a = (targetLoc).toVector().subtract(player.getLocation().toVector()).normalize();
Vector b = player.getLocation().getDirection();
angle = Math.acos(a.dot(b));
angle = Math.toDegrees(angle);
if(a.getX()*b.getZ() - a.getZ()*b.getX() < 0) {
angle = -angle;
}