Skip to content

Commit 786a44e

Browse files
committed
Improve utility of verbose logging, expand capabilities of automatic friction calculation
1 parent 5bdba4f commit 786a44e

File tree

3 files changed

+105
-42
lines changed

3 files changed

+105
-42
lines changed

Source/Documentation/Manual/physics.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ or the 1992 CN equation (for roller and low bearings). If given a supported
8585
vehicle weight and number of axles. Likewise, if the C coefficient is missing it
8686
is automatically calculated from the ``ORTSWagonFrontalArea`` and
8787
``ORTSDavisDragConstant`` values (or defaults, if those are missing).
88-
While the auto-calculated results will be reasonable in many cases, manual
89-
entry of ORTSDavis coefficients is still preferred for rolling stock that
90-
was not studied in the original Davis or CN experiments, such as steam
91-
locomotives, multiple units, and high speed trains.
88+
While the auto-calculated results will be reasonable for standard rolling stock,
89+
manual entry of ORTSDavis coefficients is still preferred for more complicated
90+
rolling stock such as steam locomotives, multiple units, high speed trains,
91+
articulated units, and anything studied in experiments other than Davis.
9292

9393
.. index::
9494
single: ORTSMergeSpeed

Source/Orts.Common/Conversions.cs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,23 +260,23 @@ public static class NpM
260260
/// <summary>
261261
/// Resistance conversions from and to Newtons/metre/sec
262262
/// </summary>
263-
public static class NpMpS
263+
public static class NSpM
264264
{
265265
/// <summary>Convert from pounds per mph to newtons per meter per second</summary>
266-
public static float FromLbpMpH(float lbfPerMpH) { return lbfPerMpH * 9.9503884f; }
266+
public static float FromLbfpMpH(float lbfPerMpH) { return lbfPerMpH * 9.9503884f; }
267267
/// <summary>Convert from newtons per meter per second to pounds per mph</summary>
268-
public static float ToLbpMpH(float nPerMpS) { return nPerMpS / 9.9503884f; }
268+
public static float ToLbfpMpH(float nPerMpS) { return nPerMpS / 9.9503884f; }
269269
}
270270

271271
/// <summary>
272272
/// Resistance conversions from and to Newtons/metre^2/sec^2
273273
/// </summary>
274-
public static class NpMpS2
274+
public static class NSSpMM
275275
{
276276
/// <summary>Convert from pounds per mph^2 to newtons per mps^2</summary>
277-
public static float FromLbpMpH2(float lbfPerMpH2) { return lbfPerMpH2 * 22.2583849f; }
277+
public static float FromLbfpMpH2(float lbfPerMpH2) { return lbfPerMpH2 * 22.2583849f; }
278278
/// <summary>Convert from newtons per mps^2 to pounds per mph^2</summary>
279-
public static float ToLbpMpH2(float nPerMpS2) { return nPerMpS2 / 22.2583849f; }
279+
public static float ToLbfpMpH2(float nPerMpS2) { return nPerMpS2 / 22.2583849f; }
280280
}
281281

282282
/// <summary>
@@ -591,8 +591,12 @@ public static class FormatStrings
591591
public static string f = Catalog.GetString("°F");
592592
public static string n = Catalog.GetString("N");
593593
public static string kN = Catalog.GetString("kN");
594+
public static string nspm = Catalog.GetString("N/m/s");
595+
public static string nsspmm = Catalog.GetString("N/(m/s)²");
594596
public static string lbf = Catalog.GetString("lbf");
595597
public static string klbf = Catalog.GetString("klbf");
598+
public static string lbfpmph = Catalog.GetString("lbf/mph");
599+
public static string lbfpmph2 = Catalog.GetString("lbf/mph²");
596600
public static string deg = Catalog.GetString("°");
597601

598602
/// <summary>
@@ -804,6 +808,18 @@ public static string FormatLargeForce(float forceN, bool isMetric)
804808
return String.Format(CultureInfo.CurrentCulture, "{0:F1} {1}", force * 1e-3f, unit);
805809
}
806810

811+
public static string FormatLinearResistance(float resistanceNSpM, bool isMetric)
812+
{
813+
var resistance = isMetric ? resistanceNSpM : NSpM.ToLbfpMpH(resistanceNSpM);
814+
return String.Format(CultureInfo.CurrentCulture, isMetric ? "{0:F1} {1}" : "{0:F2} {2}", resistance, nspm, lbfpmph);
815+
}
816+
817+
public static string FormatQuadraticResistance(float resistanceNSSpMM, bool isMetric)
818+
{
819+
var resistance = isMetric ? resistanceNSSpMM : NSSpMM.ToLbfpMpH2(resistanceNSSpMM);
820+
return String.Format(CultureInfo.CurrentCulture, isMetric ? "{0:F3} {1}" : "{0:F4} {2}", resistance, nsspmm, lbfpmph2);
821+
}
822+
807823
public static string FormatTemperature(float temperatureC, bool isMetric, bool isDelta)
808824
{
809825
var temperature = isMetric ? temperatureC : isDelta ? C.ToDeltaF(temperatureC) : C.ToF(temperatureC);

0 commit comments

Comments
 (0)