Log in to reply
 

How can i get the angle a plane makes under&above the horizontal?



  • Oh hey, i'm new here, and i don't know if this is the place to ask modding/programmign questions, but... here it goes.

    How can i get the angle a plane makes with the horizontal?? Like, if a lazer is nose diving, that would make about -60º or -70º let's say, if it is perfectly horizontal 0º, and if it is just moving upwards, 90º. How would i get that angle?

    I've started working on it before asking already, and i've got something like this:

    Vector3 velocity = chara.Velocity;
    double altitude = Math.Round(chara.HeightAboveGround, 2);
    double mag = Math.Round(Math.Sqrt(velocity.X * velocity.X + velocity.Y * velocity.Y + velocity.Z * velocity.Z), 2);

    double pitchAngle = Math.Acos(velocity.Z / mag) * 180 / Math.PI;

    if (pitchAngle < 90) pitchAngle = Math.Round(90 - pitchAngle, 2);
    else if (pitchAngle > 90) pitchAngle = -Math.Round(pitchAngle - 90, 2

    Kinda works, but... eh idk how correct this is..



  • Check out the Quaternion class in GTA Math, ever entity has access to this.


Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.