Hello experts!
I have 4 vector3:
Vector3 posFront = PositionBlocks.front.GetPosition();
Vector3 posRear = PositionBlocks.rear.GetPosition();
Vector3 posLeft = PositionBlocks.left.GetPosition();
Vector3 posRight = PositionBlocks.right.GetPosition();
posFront is the nose.
posRear is the tail.
posLeft is the left wing tip.
posRight is the right wing tip.
These vector3 are global coordinates.
At the moment I just try to get the pitch angle (up/down).
I have this code:
const int X = 0;
const int Y = 1;
const int Z = 2;
Vector3 dir = Vector3.Subtract(posFront, posRear);
double x = dir.GetDim(X);
double y = dir.GetDim(Y);
double z = dir.GetDim(Z);
double angle = Math.Atan2(z, Math.Sqrt(y * y + x * x)) * 180.0 / Math.PI;
Logger.log(angle.ToString());
But this gives me a range of:
0 to 90, back to 0, then to -90 and back to 0
What I need is a range from -180 to 180.
I hope someone can help me
Thanks