*
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class EnginePowerCurve : Curve
|
||||
{
|
||||
public float maxPower = 150000; //in Watts
|
||||
public float rpmAtMaxPower = 8000;
|
||||
|
||||
public float k_p1 = 1;
|
||||
public float k_p2 = 1;
|
||||
public float k_p3 = 1;
|
||||
|
||||
public override float Sample(float arg) {
|
||||
var o_max = rpmAtMaxPower;
|
||||
double o_e = arg;
|
||||
|
||||
var p = new double[4];
|
||||
p[0] = 0;
|
||||
p[1] = maxPower / o_max * k_p1;
|
||||
p[2] = maxPower / (o_max * o_max) * k_p2;
|
||||
p[3] = -maxPower / (o_max * o_max * o_max) * k_p3;
|
||||
|
||||
double Pe = 0.0;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
Pe += p[i] * Math.Pow(o_e, i);
|
||||
}
|
||||
|
||||
var t = MathEx.Torque(Pe, MathEx.RpmToRadS * (arg + 0.000001));
|
||||
return (float)t;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user