I was recently looking up how to create simple bot to the game and there are 2 methods to do that 1 is to calculate pitch and yaw using atan2 and sin for example
but there's also another method how peoples calculate it and my question is how it even work ?
code:
void CalcAngle(float *src, float *dst, float *angles)
{
double delta[3] = {(src[0] - dst[0]), (src[1] - dst[1]), (src[2] - dst[2])};
int x = 0;
int y = 1;
int z = 2;
float hyp = delta[x] * delta[x] + delta[y] * delta[y];
angles[0] = asinf(delta[z] / hyp) * 180 / pi;
angles[1] = atanf(delta[y] / delta[x]) * 180 / pi;
if(angles[0] > 0.0)
{
angles[1] += 180;
}
}
and my imagination how peoples are doing that
If someone knows what's going on with this code, can you explain to me how it calculates valid values. For example, it can't calculate 3rd and 2nd quadrant angles, so how it even works for others? and why they are calculating the adjacent of triangle with opposite instead of opposite with hypotenuse ? I wouldn't ask if this code would be a single case, but I already saw it in many cases.