Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Try to find the Angle Of Attack of my airplane

Author
Message
Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 10th Feb 2013 19:08 Edited at: 10th Feb 2013 19:42
Hi all again,
I am trying to design an "angle of attack" routine for my game!
It's not propely an easy thing but I reached some results but just in theory.
From theory the angle of attack is the angle between the wing chord line and the relative wind (the direction of the air particles hitting the airplane - In my example, to let the thing more easy, the Angle of attack is:
The angle between the wing chord line and the airplane direction.

Take a look to the attached pic!.

There are 4 "film" about :
1)the simply flight path
this is just to let you understand the scheme logic.

2)the direction angle
This is the angle between the direction line and the horizontal line.
Calculating this angle I can know the aircraft flight direction.

3)the pitch angle
Just the pitch angle, I already find this value.

4)the difference between direction angle and pitch angle.
I have the direction of the airplane and I have the pitch angle so I could get the Angle of attack angle!..



Here I am! So peoples, do you think this theory is correct?
Have you some easy way to find the Angle of attack?
And most important of all how I can find the direction angle? Vector?

From my attached pic you can see how I imagine this code:
EXAMPLE:
My airplane is flying in a determinate direction so
every 1 second a little cube will born from the center of the airplane.
This little cube is stopped, no velocity; now I store the XYZ position of this cube.
So, after 1 second will born another little cube and I will to store his XYZ position as the first cube.

Now I can (with your help ) make a line joining the two cubes.
So after that I should to check the direction of the flight...
I hope you can understand what I mean using my attached pic.

What do you think about all that?
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 11th Feb 2013 00:09
I have no idea what a wing chord line is.

Quote: "I have the direction of the airplane "

Quote: "And most important of all how I can find the direction angle?"

Umm, thought you just said you already had it?


Oh ok, the picture makes A LOT more sense.

If you have 2 cubes (A and B), then B-A will give you the direction vector from A to B.

If this is in 2D (like the picture demonstrates) then finding the angle between the two cubes is simple, use atanfull(). If you want an angle for 3D purposes, it gets a bit trickier.

"You're not going crazy. You're going sane in a crazy world!" ~Tick
Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 11th Feb 2013 09:22
Hi Phaelax, my pic is 2D just to make the understanding easier.
My game is 3D but the logic behind the "angle of attack" is a 2D logic.

Then, in any 3D direction my plane will flies I will always need to know just the angle between the horizon line and the airplane vertical direction, as in the attached pic.

Now, what I need is a little example code that let me to :

1)store XYZ little cubes coords(from now I call these cubes STEP CUBES)

2)Make an imaginary math line joining the last cube to the center of the airplane (my bad vectors knowledge stop me hard here)

3)To find the direction angle as in my attached picture.
So find the angle between a horizon line and the line joining the cube with the airplane.
Morcilla
23
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 16th Feb 2013 16:09 Edited at: 16th Feb 2013 16:09
Hi Alduce,

Please let me help a bit.
I think you must change the current approach.
You cannot rely on cubes or objects properties, like position, to obtain any variables, or at least I'll try to avoid that as much as possible.

Instead of that, I would calculate the speed with some maths, and position the airplane each frame according to those calculus.
Create Vx, Vy, Vz float variables and increment them according to the airplane acceleration (engine power), and substract any drag forces.

Then each frame just use the velocity to calculate the current xyz position of the plane, but again use float variables like PX, Py, Pz, and then perform something like,

Position Object airplane, Px, Py, Pz.

About the angle of attack, follow the same approach.
The value of the AOA is just the angle of the speed vector with the airplane nose vector.
The if you turn up the airplane nose (pitch up) then first calculate how much it is going to move based on the user input, and do something like

Pitch Object Up airplane, Airplane_Local_Angle_Y

The AOA would be the angle between Vx,Vy,Vz and Airplane_Local_Angle_X, Airplane_Local_Angle_Y, Airplane_Local_Angle_Z

You don't need any objects to do this, objects are where you place them and in the way you turned them

Hope that helps

Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 17th Feb 2013 09:46
Hi Morcilla and thank you for help.
In your examples you are using some commands as:

Position Object airplane, Px, Py, Pz
and
Pitch Object Up airplane, Airplane_Local_Angle_Y

but there is a big problem about: my airplane moves and spins and change his 3D position with external physic forces and not just using the DBPro commands you advice.
I never act on my airplane using these commands but just exploiting the physical engine and some aerodynamic math formulas.

From this peculiarity I need to find my AOA ,ROLL,PITCH and YAW variables using some tricks as (for example) putting the cubes and finding the direction angle as in my attached pic.
Over that I am already really far over my real math knowledge so even more I am forced to use the simplest and rudimentary ways to find the solutions I am searching for..
Le Verdier
14
Years of Service
User Offline
Joined: 10th Jan 2012
Location: In the mosh-pit
Posted: 17th Feb 2013 11:41
Hi, me again...

You will have to drop the angle approach, and use vectors...
If i anderstand well, the AOA is the angle between the wing chord line and relative wind, and these things are vectors.
The relative wind is the linear velocity of the plane transposed in the plane space..
So here are the steps:
-Get The airplane linear velocity vector. I think there is commands to do this in dark dynamic (In darkphysics, it's PHY GET RIGID BODY LINEAR VELOCITY X/Y/Z())
-Get the plane rotation matrix(Already done!!!)
-Transpose this rotation matrix(command: DX MAT TRANSPOSE())
-Transform the LV vector with this matrix(Command: DXVEC3 TRANSFORM())
-Reverse the vector and project it on the Y/Z plane
-AOA=Atanfull(V.Z, V.Y) considering the chord line can be identified as the Z axis vector (0, 0, 1)

I agree, this looks more complicated than works with 2 angles...
A bout the 2 last steps, its depends of how its implemented so it difficult to give precise code...

About vectors, I also advise you this tutorial:


Alduce
23
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 17th Feb 2013 12:31 Edited at: 17th Feb 2013 12:34
Hi Le Verdier, is always a pleasure to read your posts; always really useful.

Thank you to give me a step by step way to make an "angle of attack" code; from today to tomorrow I will test it.
Since now my method seems to work (It's hard to believe for me too.. but seems to work since now...) but you know better than me that in the math matter only the perfection work perfect and I know my method is a bit "strange" and maybe I will find some damn situations where my AOA will be wrong.
So I really would to entrust to your knowledge (that is thousand times more solid than mine) to make these complex math calculations.

Test time! wait for news please!

PS: Thank you for the vectors tutorial, I need it desperately!

Login to post a reply

Server time is: 2026-07-08 02:16:13
Your offset time is: 2026-07-08 02:16:13