@@ -196,7 +196,6 @@ public static Interpolator SteamHeatBoilerFuelUsageGalukpH()
196
196
public float CarBodyLengthM ;
197
197
public float CarCouplerFaceLengthM ;
198
198
public float DerailmentCoefficient ;
199
- public float CarAirHoseLengthM ;
200
199
201
200
public float MaxHandbrakeForceN ;
202
201
public float MaxBrakeForceN = 89e3f ;
@@ -251,8 +250,13 @@ public static Interpolator SteamHeatBoilerFuelUsageGalukpH()
251
250
252
251
public float FrontAirHoseHeightAdjustmentM ;
253
252
public float RearAirHoseHeightAdjustmentM ;
254
- public float FrontAirHoseAngleAdjustmentRad ;
255
- public float RearAirHoseAngleAdjustmentRad ;
253
+ public float FrontAirHoseYAngleAdjustmentRad ;
254
+ public float FrontAirHoseZAngleAdjustmentRad ;
255
+ public float RearAirHoseYAngleAdjustmentRad ;
256
+ public float RearAirHoseZAngleAdjustmentRad ;
257
+
258
+ public float CarAirHoseLengthM ;
259
+ public float CarAirHoseHorizontalLengthM ;
256
260
257
261
// Used to calculate Carriage Steam Heat Loss
258
262
public const float BogieHeightM = 1.06f ; // Height reduced by 1.06m to allow for bogies, etc
@@ -1322,21 +1326,26 @@ public void UpdateTrainDerailmentRisk()
1322
1326
}
1323
1327
}
1324
1328
1325
- // Calculate airhose angles and height
1326
- var rearairhoseheightadjustmentreferenceM = ( float ) Math . Sqrt ( ( float ) Math . Pow ( CarAirHoseLengthM , 2 ) - ( float ) Math . Pow ( CouplerDistanceThisCarM , 2 ) ) ;
1327
- var frontairhoseheightadjustmentreferenceM = ( float ) Math . Sqrt ( ( float ) Math . Pow ( CarAirHoseLengthM , 2 ) - ( float ) Math . Pow ( CouplerDistanceBehindCarM , 2 ) ) ;
1329
+ // Calculate airhose angles and height adjustment values for the air hose. Firstly the "rest point" is calculated, and then the real time point.
1330
+ // The height and angle variation are then calculated against "at rest" reference point. The air hose angle is used to rotate the hose in two directions, ie the Y and Z axis.
1331
+
1332
+ // Calculate height adjustment.
1333
+ var rearairhoseheightadjustmentreferenceM = ( float ) Math . Sqrt ( ( float ) Math . Pow ( CarAirHoseLengthM , 2 ) - ( float ) Math . Pow ( CarAirHoseHorizontalLengthM , 2 ) ) ;
1334
+ var frontairhoseheightadjustmentreferenceM = ( float ) Math . Sqrt ( ( float ) Math . Pow ( CarAirHoseLengthM , 2 ) - ( float ) Math . Pow ( CarBehind . CarAirHoseHorizontalLengthM , 2 ) ) ;
1328
1335
1329
- RearAirHoseHeightAdjustmentM = ( float ) Math . Sqrt ( ( float ) Math . Pow ( CarAirHoseLengthM , 2 ) - ( float ) Math . Pow ( ( CouplerDistanceThisCarM + CouplerSlackM / 2.0f ) , 2 ) ) ;
1330
- CarBehind . FrontAirHoseHeightAdjustmentM = ( float ) Math . Sqrt ( ( float ) Math . Pow ( CarAirHoseLengthM , 2 ) - ( float ) Math . Pow ( ( CouplerDistanceBehindCarM + CouplerSlackM / 2.0f ) , 2 ) ) ;
1336
+ // actual airhose height
1337
+ RearAirHoseHeightAdjustmentM = ( float ) Math . Sqrt ( ( float ) Math . Pow ( CarAirHoseLengthM , 2 ) - ( float ) Math . Pow ( ( CarAirHoseHorizontalLengthM + CouplerSlackM ) , 2 ) ) ;
1338
+ CarBehind . FrontAirHoseHeightAdjustmentM = ( float ) Math . Sqrt ( ( float ) Math . Pow ( CarAirHoseLengthM , 2 ) - ( float ) Math . Pow ( ( CarBehind . CarAirHoseHorizontalLengthM + CouplerSlackM ) , 2 ) ) ;
1331
1339
1332
1340
// refererence adjustment heights to rest position
1341
+ // If higher then rest position, then +ve adjustment
1333
1342
if ( RearAirHoseHeightAdjustmentM >= rearairhoseheightadjustmentreferenceM )
1334
1343
{
1335
1344
RearAirHoseHeightAdjustmentM -= rearairhoseheightadjustmentreferenceM ;
1336
1345
}
1337
- else
1346
+ else // if lower then the rest position, then -ve adjustment
1338
1347
{
1339
- RearAirHoseHeightAdjustmentM = rearairhoseheightadjustmentreferenceM - RearAirHoseHeightAdjustmentM ;
1348
+ RearAirHoseHeightAdjustmentM = ( rearairhoseheightadjustmentreferenceM - RearAirHoseHeightAdjustmentM ) ;
1340
1349
}
1341
1350
1342
1351
if ( CarBehind . FrontAirHoseHeightAdjustmentM >= frontairhoseheightadjustmentreferenceM )
@@ -1348,31 +1357,38 @@ public void UpdateTrainDerailmentRisk()
1348
1357
CarBehind . FrontAirHoseHeightAdjustmentM = frontairhoseheightadjustmentreferenceM - CarBehind . FrontAirHoseHeightAdjustmentM ;
1349
1358
}
1350
1359
1351
- var rearairhoseangleadjustmentreferenceRad = ( float ) Math . Cos ( CouplerDistanceThisCarM / CarAirHoseLengthM ) ;
1352
- var frontairhoseangleadjustmentreferenceRad = ( float ) Math . Cos ( CouplerDistanceBehindCarM / CarAirHoseLengthM ) ;
1360
+ // Calculate angle adjustments
1361
+ var rearAirhoseAngleAdjustmentReferenceRad = ( float ) Math . Asin ( CarAirHoseHorizontalLengthM / CarAirHoseLengthM ) ;
1362
+ var frontAirhoseAngleAdjustmentReferenceRad = ( float ) Math . Asin ( CarBehind . CarAirHoseHorizontalLengthM / CarAirHoseLengthM ) ;
1353
1363
1354
- RearAirHoseAngleAdjustmentRad = ( float ) Math . Cos ( ( CouplerDistanceThisCarM + CouplerSlackM / 2.0f ) / CarAirHoseLengthM ) ;
1355
- CarBehind . FrontAirHoseAngleAdjustmentRad = ( float ) Math . Cos ( ( CouplerDistanceBehindCarM + CouplerSlackM / 2.0f ) / CarAirHoseLengthM ) ;
1364
+ RearAirHoseZAngleAdjustmentRad = ( float ) Math . Asin ( ( CarAirHoseHorizontalLengthM + CouplerSlackM ) / CarAirHoseLengthM ) ;
1365
+ CarBehind . FrontAirHoseZAngleAdjustmentRad = ( float ) Math . Asin ( ( CarBehind . CarAirHoseHorizontalLengthM + CouplerSlackM ) / CarAirHoseLengthM ) ;
1356
1366
1357
1367
// refererence adjustment angles to rest position
1358
- if ( RearAirHoseAngleAdjustmentRad >= rearairhoseangleadjustmentreferenceRad )
1368
+ if ( RearAirHoseZAngleAdjustmentRad >= rearAirhoseAngleAdjustmentReferenceRad )
1359
1369
{
1360
- RearAirHoseAngleAdjustmentRad -= rearairhoseangleadjustmentreferenceRad ;
1370
+ RearAirHoseZAngleAdjustmentRad -= rearAirhoseAngleAdjustmentReferenceRad ;
1361
1371
}
1362
1372
else
1363
1373
{
1364
- RearAirHoseAngleAdjustmentRad = rearairhoseangleadjustmentreferenceRad - RearAirHoseAngleAdjustmentRad ;
1374
+ RearAirHoseZAngleAdjustmentRad = ( rearAirhoseAngleAdjustmentReferenceRad - RearAirHoseZAngleAdjustmentRad ) ;
1365
1375
}
1366
1376
1367
- if ( CarBehind . FrontAirHoseAngleAdjustmentRad >= frontairhoseangleadjustmentreferenceRad )
1377
+ // The Y axis angle adjustment should be the same as the z axis
1378
+ RearAirHoseYAngleAdjustmentRad = RearAirHoseZAngleAdjustmentRad ;
1379
+
1380
+ if ( CarBehind . FrontAirHoseZAngleAdjustmentRad >= frontAirhoseAngleAdjustmentReferenceRad )
1368
1381
{
1369
- CarBehind . FrontAirHoseAngleAdjustmentRad -= frontairhoseangleadjustmentreferenceRad ;
1382
+ CarBehind . FrontAirHoseZAngleAdjustmentRad -= frontAirhoseAngleAdjustmentReferenceRad ;
1370
1383
}
1371
1384
else
1372
1385
{
1373
- CarBehind . FrontAirHoseAngleAdjustmentRad = frontairhoseangleadjustmentreferenceRad - CarBehind . FrontAirHoseAngleAdjustmentRad ;
1386
+ CarBehind . FrontAirHoseZAngleAdjustmentRad = ( frontAirhoseAngleAdjustmentReferenceRad - CarBehind . FrontAirHoseZAngleAdjustmentRad ) ;
1374
1387
}
1375
1388
1389
+ // The Y axis angle adjustment should be the same as the z axis
1390
+ CarBehind . FrontAirHoseYAngleAdjustmentRad = CarBehind . FrontAirHoseZAngleAdjustmentRad ;
1391
+
1376
1392
}
1377
1393
1378
1394
// Train will derail if lateral forces on the train exceed the vertical forces holding the train on the railway track.
@@ -1385,14 +1401,13 @@ public void UpdateTrainDerailmentRisk()
1385
1401
if ( IsPlayerTrain )
1386
1402
{
1387
1403
WagonCouplerAngleDerailRad = Math . Abs ( WagonRearCouplerAngleRad ) ;
1388
- var numWheels = WagonNumAxles * 2 ;
1389
-
1390
- // Trace.TraceInformation("Wagon Values - CarID {0} Axles {1} Bogies {2} Wheels {3}", CarID, WagonNumAxles, WagonNumBogies, numWheels);
1404
+ var numAxles = LocoNumDrvAxles + WagonNumAxles ;
1405
+ var numWheels = numAxles * 2 ;
1391
1406
1392
1407
if ( CurrentCurveRadius != 0 )
1393
1408
{
1394
1409
var A = MassKG * GravitationalAccelerationMpS2 / numWheels ;
1395
- var B1 = ( MassKG / WagonNumAxles ) * ( float ) Math . Pow ( Math . Abs ( SpeedMpS ) , 2 ) / CurrentCurveRadius ;
1410
+ var B1 = ( MassKG / numAxles ) * ( float ) Math . Pow ( Math . Abs ( SpeedMpS ) , 2 ) / CurrentCurveRadius ;
1396
1411
var B2 = GravitationalAccelerationMpS2 * ( float ) Math . Cos ( SuperElevationAngleRad ) ;
1397
1412
var B3 = CentreOfGravityM . Y / TrackGaugeM ;
1398
1413
@@ -1404,7 +1419,7 @@ public void UpdateTrainDerailmentRisk()
1404
1419
if ( CarAhead != null )
1405
1420
{
1406
1421
var AA1 = CarAhead . CouplerForceU * ( float ) Math . Sin ( WagonCouplerAngleDerailRad ) / WagonNumBogies ;
1407
- var BB1 = MassKG / WagonNumAxles ;
1422
+ var BB1 = MassKG / numAxles ;
1408
1423
var BB2 = ( float ) Math . Pow ( Math . Abs ( SpeedMpS ) , 2 ) / CurrentCurveRadius ;
1409
1424
var BB3 = GravitationalAccelerationMpS2 * ( float ) Math . Sin ( SuperElevationAngleRad ) ;
1410
1425
0 commit comments