This is going to be difficult to describe, as I have no real concept of this sort of physics, so please bear with me. If this is too much or beyond the scope of this website, I apologize.
I am making a simple-ish driving simulator and I need a formula that I can use to determine the rotation of the vehicle for every frame. If the car's rotation is 90.0 degrees and the wheels are pointing 20.0 degrees to the right, that should mean I can use a simple polar offset to send it a distance of a toward 70.0 (90.0 - 20.0). This does not work when the car is not moving, or when the air resistance is large, like when the car is turning at high speeds, and I am not sure how I should be dealing with such factors. What I have works for now, but I need a more accurate solution.
What I have
What I have barely turns the car at low speeds, and allows it to turn on a dime at high speeds. This is the algorithm that I am currently using in pseudo-code.
if (vehicle.engineCurrentRPM > vehicle.engineMaxRPM) vehicle.engineCurrentRPM = vehicle.engineMaxRPM;
if (vehicle.engineCurrentRPM < -vehicle.engineMaxRPM) vehicle.engineCurrentRPM = -vehicle.engineMaxRPM; // This allows it to go full speed in reverse, which I can fix myself.
// The engineMaxRPM is from a Bugatti Veyron and is equal to 6000.0.
// That is 600.0 lower than the redline, and I did that on purpose.
vehicle.engineCurrentTorque = (vehicle.engineCurrentRPM * (922.0 / 2200.0));
// A simple formula that approximates the torque-rpm relationship. I only include this because torque _might_ be relevant.
differentialRatio = 4.0;
drag = 0.39;
gearRatio = 3.64;
grip = 1.0;
wheelRadius = (2.0 * 0.0254);
// 20 inch wheels converted to meters and set to 10%. I don't know why this is necessary, but it seems to be in all of the formulas I have seen
weight = 1995.806; // 4400 pounds * 0.453592 to get kilograms.
power = (vehicle.engineCurrentTorque * vehicle.engineCurrentRPM) / 5252.0; // HP = Torque x RPM ÷ 5252
// The variable "power" is unused, but there if you need it.
airResistance = 0.05 * (1.0 - drag);
tWheels = vehicle.engineCurrentTorque * gearRatio * differentialRatio;
f = (tWheels / wheelRadius);
vehicle.acceleration = (f / weight) * grip;
vehicle.object.rotation.z -= vehicle.wheelAngle * vehicle.acceleration * time;
float angle = vehicle.rotation.z;
angle *= M_PI; // The pi constant.
angle /= 180.0;
vehicle.velocity.x -= vehicle->acceleration * sin(angle) * time;
// The world is upside-down for some reason, so subtracting is necessary. This will be fixed!
vehicle.velocity.y += vehicle->acceleration * cos(angle) * time;
vehicle.velocity.z += 0.0;
vehicle.position.x += vehicle.velocity.x;
vehicle.position.y += vehicle.velocity.y;
vehicle.position.z += vehicle.velocity.z;
vehicle.velocity.x *= (1.0 - airResistance);
vehicle.velocity.y *= (1.0 - airResistance);
vehicle.velocity.z *= (1.0 - airResistance);