I have two vectors:
- One is a direction (the current agent direction)
- One is the goal (a point)
I want to steer left or right, depending on wich one of them has the lowest angle between it and the goal.
So, here’s what I’m doing:
[java]
Vector3f steer = direction.cross(Vector3f.UNIT_Y).normalize();
if (steer.angleBetween(goal.normalize()) < steer.negate().angleBetween(goal.normalize())) {
return steer;
else
return steer.negate();
[/java]
Can someone help me understand why is this wrong?
Edit:
Does the current location of the agent (the one who has a direction) matters here? (I think not, as the angles shouldn’t change)