Skip to main content
edited tags
Link
DMGregory
  • 141k
  • 23
  • 258
  • 401
added 289 characters in body
Source Link
K2xL
  • 111
  • 4

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;

force.add(velocityDirection.multiply(drag));
force.add(airPlaneNoseDirection.multiply(thrust);
force.add(Vector(0,lift,0);
force.add(Vector(0,gravity,0);

velocity.add(force);

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.

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;

force.add(velocityDirection.multiply(drag));
force.add(airPlaneNoseDirection.multiply(thrust);
force.add(Vector(0,lift,0);
force.add(Vector(0,gravity,0);

velocity.add(force);

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

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;

force.add(velocityDirection.multiply(drag));
force.add(airPlaneNoseDirection.multiply(thrust);
force.add(Vector(0,lift,0);
force.add(Vector(0,gravity,0);

velocity.add(force);

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.

added 22 characters in body
Source Link
K2xL
  • 111
  • 4

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.x;y;
airPlaneRoll = plane.rotation.z;

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

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

thrust = X;

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

gravity = X;

force.add(velocityDirection.multiply(drag));
force.add(airPlaneNoseDirection.multiply(thrust);
force.add(Vector(0,lift,0);
force.add(Vector(0,gravity,0); 

velocity.add(force);

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

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.x;
airPlaneRoll = plane.rotation.z;

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

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

thrust = X;

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

gravity = X;

force.add(velocityDirection.multiply(drag));
force.add(airPlaneNoseDirection.multiply(thrust);
force.add(Vector(0,lift,0);
force.add(Vector(0,gravity,0);

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

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;

force.add(velocityDirection.multiply(drag));
force.add(airPlaneNoseDirection.multiply(thrust);
force.add(Vector(0,lift,0);
force.add(Vector(0,gravity,0); 

velocity.add(force);

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

Source Link
K2xL
  • 111
  • 4
Loading