• Create Account

Banner advertising on our site currently available from just \$5!

# Calculating angles of rotation

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

21 replies to this topic

### #21deftware  Prime Members   -  Reputation: 1532

Like
0Likes
Like

Posted 03 November 2012 - 09:52 AM

There seems to be a general lack of trig know-how on this thread..
I wrote this function for an aimbot known as 'ViperG' in a file that's dated june 24th, 2001
I've commented it and adjusted it a bit. You might need to swap some things, but this should help you understand the jist of what you're trying to accomplish..

[source lang="cpp"]#define RAD2DEG (180 / 3.141592654)void VectorAngles( float *vector, float *angles ){ float tmp, yaw, pitch; if (!vector[0] && !vector[1]) // no horizontal length { if (vector[2] > 0) // straight up pitch = 90; else pitch = -90; // straight down yaw = 0; // can't discern a heading with xy of zero } else { yaw = (atan2(vector[1], vector[0]) * RAD2DEG); if (yaw < 0) // set yaw between 0-360 yaw += 360; // get horizontal length of vector tmp = sqrt (vector[0]*vector[0] + vector[1]*vector[1]); // use horizontal length and vector[z] to get pitch pitch = (atan2(vector[2], tmp) * RAD2DEG); } angles[0] = pitch; angles[1] = yaw; angles[2] = 0;}[/source]

To use this function you'd do

[source lang="cpp"]...float vector[3], angles[3];// set your vector hereVectorAngles(vector, angles);// angles now contains yaw/pitch euler interpretation of vector.....[/source]
Let me know if you have any further questions..

### #22Alessandro  Members   -  Reputation: 301

Like
0Likes
Like

Posted 03 November 2012 - 10:09 AM

Thanks a lot, I'm going to try this as well!

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS