This is an extension to the original topic:
http://www.fsdeveloper.com/forum/showthread.php?t=11906
I am interested in programing the flight of the user aircraft to match an ai aircraft such that it occupies the same space, wiht the same pitch, roll and yaw with a given tolerance, on a visual frame by frame basis.
Help is needed to write the maths to do this. Foiter wrote: "Whatever you do with your aircraf the easiest and the most efficient way to compute its velocities is to use simple vector algebra. I assume your goal is to hold user craft at a certain minimal distance to the AI craft following AI craft's orientation. As you already noticed the most reasonable way to do that is to make your computations in the body reference sistem. So, the first and foremost thing to achive is to make your aircraft to follow the AI craft's orientation. If you want to make it intuitively clear avoiding quaternions, than I'd suggest to compute cross product of both aircraft's attitude vectors and normalize it. This will give you the rotation for the pitch and yaw. The roll rotation can be computed using scalar product of both Bank vectors. As long as you resolve this task you can proceed with the distance calculation. BTW, for the test purposes I suggest to use Slew mode."
From a smoothness point of view, simply copying the roll, pitch and yaw from the AI aircraft to the user aircraft was a very effective method. However that does not sound like the right thing to do achieve the altitude and position coordinates.
I'm afraid even simple vector algebra is beyond me, school days are a long time ago for me now. Perhaps if you were able to write a formula in terms of FSX simulation variables, I could implement that.
Thanks
Simon
http://www.fsdeveloper.com/forum/showthread.php?t=11906
I am interested in programing the flight of the user aircraft to match an ai aircraft such that it occupies the same space, wiht the same pitch, roll and yaw with a given tolerance, on a visual frame by frame basis.
Help is needed to write the maths to do this. Foiter wrote: "Whatever you do with your aircraf the easiest and the most efficient way to compute its velocities is to use simple vector algebra. I assume your goal is to hold user craft at a certain minimal distance to the AI craft following AI craft's orientation. As you already noticed the most reasonable way to do that is to make your computations in the body reference sistem. So, the first and foremost thing to achive is to make your aircraft to follow the AI craft's orientation. If you want to make it intuitively clear avoiding quaternions, than I'd suggest to compute cross product of both aircraft's attitude vectors and normalize it. This will give you the rotation for the pitch and yaw. The roll rotation can be computed using scalar product of both Bank vectors. As long as you resolve this task you can proceed with the distance calculation. BTW, for the test purposes I suggest to use Slew mode."
From a smoothness point of view, simply copying the roll, pitch and yaw from the AI aircraft to the user aircraft was a very effective method. However that does not sound like the right thing to do achieve the altitude and position coordinates.
I'm afraid even simple vector algebra is beyond me, school days are a long time ago for me now. Perhaps if you were able to write a formula in terms of FSX simulation variables, I could implement that.
Thanks
Simon

