Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void __fastcall TVehicle::ProcessFrame()
- {
- Gather_All_INFO();
- AIRLIERON_LEFT->Frame_tick();
- AIRLIERON_RIGHT->Frame_tick();
- ELEVATOR_LEFT->Frame_tick();
- ELEVATOR_RIGHT->Frame_tick();
- RUDDER_LEFT->Frame_tick();
- RUDDER_RIGHT->Frame_tick();
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- double l;
- timin->stopTimer();
- l = timin->getElapsedTime();
- float dt = float(l); //get elapsed time in seconds
- timin->startTimer();
- if (dt <=0 ) return;
- float kc = VectorLength(vel);
- float squareSpeed = kc*kc;
- float elevationangle = ELEVATOR_LEFT->GetAngle(); //result is percentage of elevation //*17.5 is the max degree that elevator can reach
- float elevator_drag_force = 0.90f * ((dens * squareSpeed )/ 2.0f) * Abs(elevationangle) * 2.0f*13.2040f;
- float leverlen = 8.50f;
- float alphaangularity = (dt*((leverlen * elevator_drag_force) * sin( (elevationangle*(17.50f+ 90.0f) )*imopi) ) )/ (mass * leverlen*leverlen);// elevator_drag_force*elevator_drag_force);
- alphaangularity = RadToDeg(alphaangularity);
- float angvel = alphaangularity*dt;
- YPRangle.pitch(cos(angvel*imopi),sin(angvel*imopi));
- YPRangle.DoRotation();
- ANGLE_PITCH = ANGLE_PITCH + angvel;
- // Callbackangvel = angvel;
- float Front_force = Throttle_to_force( Throttle ); //thrust force val
- float Q = eGForce * mass; // weight force val
- ThrustForce_vec = YPRangle.rf; //thrust force direction
- ThrustForce_vec = ThrustForce_vec * Front_force;
- GForce_vec = triplesingletoT3DPOINT(0.0,-1.0f,0.0f);
- GForce_vec = GForce_vec * Q; //weight force vector
- if (pos.y <= 0.0 ) GForce_vec = zero; //:Y
- // Cl = 2 * pi * pitch angle (in radians)
- // L = .5 * Cl * air_density * V^2 * A
- //
- // The angle between the chord line and the flight direction is called the angle of attack
- //so angle of attack is the angle between vel vector and thrust force vector.
- float AngleOfAttack = AngleBetweenVectors(vel,ThrustForce_vec);
- float tmpangle = RadToDeg(AngleOfAttack);
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- DragForce_vec = reverse_point(vel);
- DragForce_vec = Normalize( DragForce_vec );
- i_drag_force = DragForce_vec;
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- DragForce_vec = DragForce_vec * (0.080f * ((dens * squareSpeed)/2.0f) * absnf(cos(tmpangle*imopi))*3.6f);
- i_drag_force = i_drag_force * (1.180f*((dens * squareSpeed)/2.0f)* absnf(sin(tmpangle*imopi))*14.0f);
- DragForce_vec = DragForce_vec + i_drag_force;
- //The lift derived from the aerofoil increases as increases. Surprisingly, the lift increases linearly
- //with up to about 10â15 . For many aerofoils, even with an angle of attack of 0 the aerofoil
- //generates some positive lift force. The lift generated by an aerofoil is given by the well-known
- //equation:
- //lift d
- //Although lift cannot be measured directly in flight, in steady-state conditions, with an aircraft
- //flying straight-and-level, the lift must be equal to the mass of the aircraft, giving
- //mg = 1/2ĎV 2sCL
- //CL = 2mg
- //ĎsV 2
- LiftCoeff = 0.0050f + sin(AngleOfAttack) / 2.0f;
- float LiftForce = 0.50f * LiftCoeff * dens * squareSpeed * 38.0f;// <--- LIFT AREA
- LiftForce_vec.x = YPRangle.AIR_MATRIX[4];
- LiftForce_vec.y = YPRangle.AIR_MATRIX[5];
- LiftForce_vec.z = YPRangle.AIR_MATRIX[6];
- LiftForce_vec = LiftForce_vec * LiftForce;
- result_force = GForce_vec + ThrustForce_vec + DragForce_vec + LiftForce_vec;
- Acceleration = result_force / mass;
- t3dpoint V0;
- t3dpoint deltaV;
- V0 = vel;
- pos = pos + (vel * dt);
- vel = vel + (Acceleration * dt);
- if (dt == 0.0) V = 0; else
- V = n3ddistance(pos,old) / dt;
- V = 1.943844490f * V;
- old = pos;
- CAMERA->object_pos = pos;
- CAMERA->object_dir = YPRangle.rf;
- CAMERA->object_right = YPRangle.rr;
- CAMERA->object_up = YPRangle.ru;
- if (CAMERA->view_mode == 3) {
- CAMERA->object_dir = triplesingletoT3DPOINT(YPRangle.AIR_MATRIX[8], YPRangle.AIR_MATRIX[9],
- YPRangle.AIR_MATRIX[10]);
- CAMERA->object_right = triplesingletoT3DPOINT(YPRangle.AIR_MATRIX[0], YPRangle.AIR_MATRIX[1],
- YPRangle.AIR_MATRIX[2]);
- CAMERA->object_up = triplesingletoT3DPOINT(YPRangle.AIR_MATRIX[4], YPRangle.AIR_MATRIX[5],
- YPRangle.AIR_MATRIX[6]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement