Closed domokato closed 8 years ago
If I got it right this can only happen when both relative position and relative velocity are 0, i.e. when the two agents have the same position and velocity.
If so, shouldn't we return true
?
Anything dot (0,0) will evaluate to 0, so it doesn't matter what relative position is
Although I suppose if the agents are already colliding we will want to return true
as you said...how would you suggest we fix this?
Well, this behavior is collision avoidance, meaning that its target is to prevent collisions by reacting to collision course not to ongoing collisions.
Also when you use a physics engine rigid bodies won't overlap, so the issue does not arise.
As things stand, I think that your solution is more than acceptable.
I've just replaced the isNaN()
invocation with the faster check relativeSpeed2 == 0
which is logically equivalent in this particular situation.
From these two lines:
0/0 = NaN