I was wondering if there was any one in here that could tell me if this code could be done better or faster. Take a look.
Code:
void VectorAngles( const float *forward, float *angles )
{
float tmp, yaw, pitch;
if (forward[1] == 0 && forward[0] == 0)
{
yaw = 0;
if (forward[2] > 0)
pitch = 90.0;
else
pitch = 270.0;
}
else
{
yaw = (atan2f(forward[1], forward[0]) * 57.3f);
if (yaw < 0) yaw += 360.0;
tmp = sqrt (forward[0]*forward[0] + forward[1]*forward[1]);
pitch = (atan2f(forward[2], tmp) * 57.3f);
}
angles[0] = pitch;
angles[1] = yaw;
angles[2] = 0;
}