# Aircraft simulation

Trying to get a "semi" realistic aircraft simulator. I'm pulling my hair out because I just can't get the math right. I'm not looking for super realistic but want to at least get some effects like planes increasing speed as their nose is down and being able to stay in flight.

Pseudocode below from my calculateForces method

// All uses of X are different constants

force = new Vector(0,0,0)

airPlaneYaw = plane.rotation.x;
airPlanePitch = plane.rotation.y;
airPlaneRoll = plane.rotation.z;

velocityDirection = plane.velocity.normalize();
airPlaneNoseDirection = plane.getWorldDirection();
airPlaneSurfaceAgainstDirectionOfMotion = airPlaneNoseDirection.angleTo(velocityDirection)
airPlaneSpeed = plane.velocity.length();

drag = X*(speed**2) * sin(airPlaneSurfaceAgainstDirectionOfMotion); // I have a feeling this is wrong

thrust = X;

lift = X * (speed**2) * sin(airPlaneYaw); // I have a feeling this is wrong?

gravity = X;



Is this the right model for approaching this? Is my math incorrect? Am I missing any forces?

My plane seems to lose speed when turning even if thrust is constant and ends up falling down. Is that expected in real life? Very annoying in my game because the plane becomes harder to control. Do planes add thrust when turning? Also the plane seems to gain airspeed when nose is down.

• And, I think lift force should't be vertical. If so you will not get planes increasing speed as their nose is down. See LiftForce. May 7, 2022 at 7:22
• @Mangata that would be accurate if we knew that this question was in the context of the Unity game engine and that plane refers to a Transform component, but we can readily see that's not the case: Transform does not have a .velocity property or field or a .getWorldDirection() method. For K2xL: it would help to mention the context and coordinate system you're building this in, and how the behaviour of this code differs from what you want. May 7, 2022 at 12:51
• Working with threejs if that context helps. Will edit question with more details of behavior
– K2xL
May 7, 2022 at 22:38
• @Mangata How should lift force be applied? Should it be angle of the aircraft or should it be something else? For reference, i found this from NASA which I interpreted lift as a vertical force wright.nasa.gov/airplane/lifteq.html
– K2xL
May 8, 2022 at 0:10
• A fluid flowing around an object exerts a force on it. Lift is the component of this force that is perpendicular to the oncoming flow direction. Lift_(force) May 9, 2022 at 3:29