public static Lut PowerToTorque(Lut torque, int detalization = 100) { torque.UpdateBoundingBox(); var startFrom = torque.MinX; var limit = torque.MaxX; var result = new Lut(); var previousTorquePoint = 0; var previousRpm = 0d; for (var i = 0; i <= detalization; i++) { var rpm = detalization == 0 ? limit : (limit - startFrom) * i / detalization + startFrom; for (var j = previousTorquePoint; j < torque.Count; j++) { var p = torque[j]; if (p.X > rpm) { previousTorquePoint = j > 0 ? j - 1 : 0; break; } if ((i == 0 || p.X > previousRpm) && p.X < rpm) { result.Add(new LutPoint(p.X, PowerToTorque(p.Y, p.X))); } } result.Add(new LutPoint(rpm, PowerToTorque(torque.InterpolateLinear(rpm), rpm))); previousRpm = rpm; } return(Result(result)); }
private static Lut Result(Lut v) { v = v.Optimize(); v.UpdateBoundingBox(); return(v); }