LUA Vectors, Radians, Degrees

willissteve0

New member
Joined
Aug 17, 2008
Messages
7
Reaction score
0
Points
0
Hi Chaps,

I am looking through lua scripting at the moment and putting together some simple scripts to try and get a feel for the system orbiter uses.

I am trying to decipher the output of the pitch angle function and respective bank and yaw functions.

the output is a number like 1.03045677 and so on depending on the attitude of the vessel. In the documentation it says the that the output is [rad] now is that radians or a vector?

Also the documentation says that that function is in relation to the local horizon which if I am orbiting Earth I would assume would be relative to the horizon of Earth?

I know a little about vectors from Blender but and know that a vector is based on a direction and a magnitude so does any one know any good tutorials or posts on how we convert these figures into a more understandable unit like degrees or radians?

I apologize if this has already been covered in a past thread I did search but didn't find anything relative.

I would have thought this would be a common query or maybe I am a little slow?

Kind Regards

Steve
 
The number you get is in radians and that is just another way to describe angles. To get the angle in degrees just multiply the number by 180/PI or the constant DEG (as defined in oapi_init.lua) and you get 59.04°.

The funktion v:get_pitch() is relative to the horizon, so if you are orbiting the earth in a highly elliptical orbit it will not become 0 in the prograde direction.
 
I am trying to decipher the output of the pitch angle function and respective bank and yaw functions.

the output is a number like 1.03045677 and so on depending on the attitude of the vessel. In the documentation it says the that the output is [rad] now is that radians or a vector?

Why do you think [rad] has something to do with vector? AFAIK, if it is only one scalar value that you get, it is not a vector in a usual 3D euclidean metric, where it should at least consist of 3 scalar values.

You can easily convert radians into degrees by means of simple proportional transformations like so:

  1. Convert the radian value to a fraction of the unit circle by dividing it through the radian value for a full unit circle (aka circumference of a circle with radius 1 giving a diameter of 2): frac = rad / (2 * PI)
  2. Convert the fraction of the unit circle to degrees by multiplying it with 360: deg = frac * 360
  3. Make the formula easier by means of simplifying the constants: deg = rad * 360 / (2 * PI) = rad * 180 / PI = rad * CONST
  4. The CONST in the above step is given in Orbiter's API headers as "DEG" (OrbiterAPI.h, line 54), so you can simply get degrees from radian values by means of multiplying the later with DEG.
The sign of the returned value is not that intuitive, though. It depends on the coordinate system that is used by Orbiter, and that is traditionally left-handed. The best way is to try it out and see what direction is what sign. AFAIK, positive pitch is climbing and negative pitch is sinking attitude, respectively.


Hope that helps,
Face
 
Thanks guys I assumed it was radians but have confused my self with vectors, there are so many different components in orbiter to consider it all becomes blurry to me and math is not a strong point for me!

Thank you!

I now have some understanding of what I am looking at!
 
Back
Top