Atan2 problem
BlitzMax Forums/BlitzMax Programming/Atan2 problem
| ||
Hi, I have up to 200 enemies who need to rotate to point in the direction they are travelling. This game is targetted to run on a P2-450 and above, therefore would Atan2 be very expensive? Are there alternatives to finding the rotation based on 2 coordinates, or failing that, I am able to provide a movement vector vx,vy. |
| ||
You could just normalize the 2d movement vector then rotate the object accordingly. I believe you can use sin and cosine on the normalized component to find the angle. |
| ||
Ok here's something that might help. You store the x and y speeds in the vector and normalize to find the direction vector. Hope it helps. |
| ||
Very helpful, thanks :) And quite clever... |
| ||
This game is targetted to run on a P2-450 and above, therefore would Atan2 be very expensive? Nope. |