Public Group

# What's going on here?

This topic is 5227 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Here's a bit of code in my program that makes an alien sprite rotate in the direction of the player, wherever he moves on screen: bltfx.nRotationAngle = -((atan2((playerx - alienx),(playery - alieny)) * 5700)); I had to keep trying different values for the "* 5700" bit, till it rotated correctly. Can somebody explain what that number is? I'm using GapiDraw to rotate the sprite by the way and I believe the rotationAngle takes radians. Is 5700 converting from degrees to radians?? I'm a bit confused, as you can tell! :)

##### Share on other sites
The correct use of atan2 is atan2(Y,X),and it returns the angle in radians.

##### Share on other sites
I think you're using degrees in your program, not radians. By multplying by 5700, you're sort-of converting from radians to degrees.

To convert from radians to degrees, multiply by 180 and divide by pi. What you're doing is similar. You're multiplying by 17907 (almost 18000) and dividing by pi. (17907/pi ~~ 5700). That will give you an angle 100 times too large, but since angles are modulo 360, that is no problem.

Basically, any multiple of 180/pi ~~ 57 will work.

##### Share on other sites
Ah...gotya! Coolness, that's exactly what I needed to know!

Many thanks!

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633708
• Total Posts
3013468
×