below is a function that (assuming a bullet impact) is intended to determine if a character was shot from in front or behind.
This is my solution:
1. Calculate length of vectors
2. Calculate the dot product between the two
3. plugin cosine formula to figure out the angle between both vectors
If all you need is whether cosAngle is positive or not ... then all you need is whether dotProduct is positive or not - you can avoid actually working out those two square roots.
lastchance is right! You only need to check if dot product is greater than zero making the code that more efficient.
Does this mean the fault is in my testing?
Maybe, since like I said, your code was correct.
If you are making a FPS though, this probably isn't what you want since the bullet can hit you outside your Fov yet it would be detected as a frontal hit (see the picture bellow). And maybe that's why you though it was incorrect?
1 2 3 4
\ fov / _B
\ / _/
\ /_/
~~~~A~~~~
Perhaps you should elaborate a bit more on what exactly you're trying to do?