Hello, I need some help with my flight simulator, I have encountered the first problem which I know I will not be able to do myself.
I need to be able to take user input to alter the yaw, pitch and roll aspects of an aircraft's rotation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
YAW += virtualy * sin(ROLL * (PI/180));
PITCH += virtualy * cos(ROLL * (PI/180)); ///problem line...
ROLL += virtualx;
///virtualx and virtualy are altered by key presses,
///left key -> virtualx-- | right key -> virtualx++
///down key -> virtualy-- | up key -> virtualy++
thrustx = sin(YAW * (PI/180)) * cos(PITCH * (PI/180));
thrusty = sin(PITCH * (PI/180));
thrustz = cos(YAW * (PI/180)) * cos(PITCH * (PI/180));
force_x = thrustx;// + form_dragx;// /*+ gravity*/ + liftx; //would be +=
// in reality, but for testing just =
force_y = thrusty;// + form_dragy;// /*+ gravity*/ + lifty;
force_z = thrustz;// + form_dragz;// /*+ gravity*/ + liftz;
x += 0.01 * force_x;
y += 0.01 * force_y;
z += 0.01 * force_z;
|
From this code snippet, you can see that the first three lines are useless. I have been playing around with being able to control the yaw, pitch and roll angles, but have not gotten anywhere. The thrust vectors take the YAW and PITCH variables and work very nicely. So my problem extends from taking user input, as shown by the virtualy and virtualx variables, which then must alter the YAW< PITCH and ROLL variables.
I need help this time. Please can I have a reply, I am under a lot of pressure, and I have no previous experience with anything on this level, but once I have the small code snippet it is a closed operation and I do not have to be concerned with it any more.
It looks as though eigen might be the solution, as referenced here:
http://stackoverflow.com/questions/21412169/creating-a-rotation-matrix-with-pitch-yaw-roll-using-eigen. Please can somebody explain, it is such a small thing to do, but would make my life a lot easier.