major rework
This commit is contained in:
30
Car simulation/Core/Physics/PhysicsUtil.cs
Normal file
30
Car simulation/Core/Physics/PhysicsUtil.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
namespace Car_simulation.Core.Physics
|
||||
{
|
||||
public static class PhysicsUtil
|
||||
{
|
||||
public const float G = 9.81f;
|
||||
public const float AirDensity = 1.225f;
|
||||
public const float RAD_PER_SEC_TO_RPM = 60f / (2f * MathF.PI);
|
||||
public const float RPM_TO_RAD_PER_SEC = (2f * MathF.PI) / 60f;
|
||||
|
||||
public static float Lerp(float a, float b, float t)
|
||||
{
|
||||
t = Math.Clamp(t, 0f, 1f);
|
||||
return a + (b - a) * t;
|
||||
}
|
||||
|
||||
public static float RPMToOmega(float rpm) => rpm * MathF.PI * 2f / 60f;
|
||||
public static float OmegaToRPM(float omega) => omega * 60f / (2f * MathF.PI);
|
||||
|
||||
public static float CalculateRotationalEnergy(float inertia, float omega)
|
||||
{
|
||||
return 0.5f * inertia * omega * omega;
|
||||
}
|
||||
|
||||
public static float CalculateOmegaFromEnergy(float energy, float inertia)
|
||||
{
|
||||
if (energy <= 0) return 0;
|
||||
return MathF.Sqrt(2f * energy / inertia);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user