public static void InverseRelations() { Assert.Equal(1.2f, Me.FromMi(Me.ToMi(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, Me.FromKiloM(Me.ToKiloM(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, Me.FromYd(Me.ToYd(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, Me.FromFt(Me.ToFt(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, Me.FromIn(Me.ToIn(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, Me2.FromFt2(Me2.ToFt2(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, Me2.FromIn2(Me2.ToIn2(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, Me3.FromFt3(Me3.ToFt3(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, Me3.FromIn3(Me3.ToIn3(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, MpS.FromMpH(MpS.ToMpH(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, MpS.FromKpH(MpS.ToKpH(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, Kg.FromLb(Kg.ToLb(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, Kg.FromTUS(Kg.ToTUS(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, Kg.FromTUK(Kg.ToTUK(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, Kg.FromTonne(Kg.ToTonne(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, N.FromLbf(N.ToLbf(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, KgpS.FromLbpH(KgpS.ToLbpH(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, W.FromKW(W.ToKW(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, W.FromHp(W.ToHp(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, W.FromBTUpS(W.ToBTUpS(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, KPa.FromPSI(KPa.ToPSI(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, KPa.FromInHg(KPa.ToInHg(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, KPa.FromBar(KPa.ToBar(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, KPa.FromKgfpCm2(KPa.ToKgfpCm2(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, Bar.FromKPa(Bar.ToKPa(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, Bar.FromPSI(Bar.ToPSI(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, Bar.FromInHg(Bar.ToInHg(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, Bar.FromKgfpCm2(Bar.ToKgfpCm2(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, BarpS.FromPSIpS(BarpS.ToPSIpS(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, KJpKg.FromBTUpLb(KJpKg.ToBTUpLb(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, L.FromGUK(L.ToGUK(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, L.FromGUS(L.ToGUS(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, pS.FrompM(pS.TopM(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, pS.FrompH(pS.TopH(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, S.FromM(S.ToM(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, S.FromH(S.ToH(1.2f)), RequestedAccuracy); Assert.Equal(1.2f, C.FromF(C.ToF(1.2f)), RequestedAccuracy); Assert.Equal(12f, C.FromK(C.ToK(12f)), RequestedAccuracy); // we loose accuracy because of the large 273.15 }
void CreateTargetSpeeds(List <PlanningTarget> speedTargets) { var speedTargetText = new List <TextPrimitive>(speedTargets.Count); var speedTargetTextures = new List <LocatedTexture>(speedTargets.Count); int ld = 0; for (int i = 1; i < speedTargets.Count; i++) { bool overlap = false; for (int j = 1; j < speedTargets.Count; j++) { if (i != j && CheckTargetOverlap(speedTargets[i], speedTargets[j])) { overlap = true; break; } } if (overlap) { continue; } PlanningTarget cur = speedTargets[i]; PlanningTarget prev = speedTargets[ld]; if (cur.DistanceToTrainM < 0) { continue; } ld = i; bool im = cur.Equals(IndicationMarkerTarget); if (cur.DistanceToTrainM > MaxViewingDistanceM) { break; } int a = GetPlanningHeight(cur.DistanceToTrainM) - 15; string text = ((int)MpS.ToKpH(cur.TargetSpeedMpS)).ToString(); if (im || prev.TargetSpeedMpS > cur.TargetSpeedMpS || cur.TargetSpeedMpS == 0) { speedTargetText.Add(new TextPrimitive(new Point(25, a - 2), im ? ColorYellow : ColorGrey, text, FontTargetSpeed)); speedTargetTextures.Add(new LocatedTexture(im ? YellowSpeedReductionTexture : SpeedReductionTexture, 4, a + 7 - 10)); } else { speedTargetText.Add(new TextPrimitive(new Point(25, a - 2 - (int)FontHeightTargetSpeed), ColorGrey, text, FontTargetSpeed)); speedTargetTextures.Add(new LocatedTexture(SpeedIncreaseTexture, 4, a - 7 - 10)); } if (cur.TargetSpeedMpS == 0) { break; } } SpeedTargetText = speedTargetText; SpeedTargetTextures = speedTargetTextures; }
public CircularSpeedGaugeControl(int width, int height, float maxSpeedMpS, WindowManager owner) : base(0, 0, width, height) { CircularSpeedGauge = new CircularSpeedGauge( width, height, owner.Viewer.MilepostUnitsMetric ? (int)MpS.ToKpH(maxSpeedMpS) : (int)MpS.ToMpH(maxSpeedMpS), owner.Viewer.MilepostUnitsMetric, true, (int)MpS.ToKpH(maxSpeedMpS) == 240 || (int)MpS.ToKpH(maxSpeedMpS) == 260, 0, (MSTSLocomotive)owner.Viewer.PlayerLocomotive, owner.Viewer ); }
public static void MultiUnitConversions() { Assert.Equal(1.2f, MpS.FromMpS(MpS.FromKpH(1.2f), true), RequestedAccuracy); Assert.Equal(1.2f, MpS.FromMpS(MpS.FromMpH(1.2f), false), RequestedAccuracy); Assert.Equal(1.2f, MpS.ToMpS(MpS.ToKpH(1.2f), true), RequestedAccuracy); Assert.Equal(1.2f, MpS.ToMpS(MpS.ToMpH(1.2f), false), RequestedAccuracy); Assert.Equal(1.2f, KPa.FromKPa(1.2f, PressureUnit.KPa), RequestedAccuracy); Assert.Equal(1.2f, KPa.FromBar(KPa.FromKPa(1.2f, PressureUnit.Bar)), RequestedAccuracy); Assert.Equal(1.2f, KPa.FromInHg(KPa.FromKPa(1.2f, PressureUnit.InHg)), RequestedAccuracy); Assert.Equal(1.2f, KPa.FromKgfpCm2(KPa.FromKPa(1.2f, PressureUnit.KgfpCm2)), RequestedAccuracy); Assert.Equal(1.2f, KPa.FromPSI(KPa.FromKPa(1.2f, PressureUnit.PSI)), RequestedAccuracy); Assert.Throws <ArgumentOutOfRangeException>(() => KPa.FromKPa(1.2f, PressureUnit.None)); Assert.Equal(1.2f, KPa.ToKPa(1.2f, PressureUnit.KPa), RequestedAccuracy); Assert.Equal(1.2f, KPa.ToBar(KPa.ToKPa(1.2f, PressureUnit.Bar)), RequestedAccuracy); Assert.Equal(1.2f, KPa.ToInHg(KPa.ToKPa(1.2f, PressureUnit.InHg)), RequestedAccuracy); Assert.Equal(1.2f, KPa.ToKgfpCm2(KPa.ToKPa(1.2f, PressureUnit.KgfpCm2)), RequestedAccuracy); Assert.Equal(1.2f, KPa.ToPSI(KPa.ToKPa(1.2f, PressureUnit.PSI)), RequestedAccuracy); Assert.Throws <ArgumentOutOfRangeException>(() => KPa.ToKPa(1.2f, PressureUnit.None)); }