@@ -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
@@ -1277,21 +1281,26 @@ public void UpdateTrainDerailmentRisk()
1277
1281
}
1278
1282
}
1279
1283
1280
- // Calculate airhose angles and height
1281
- var rearairhoseheightadjustmentreferenceM = ( float ) Math . Sqrt ( ( float ) Math . Pow ( CarAirHoseLengthM , 2 ) - ( float ) Math . Pow ( CouplerDistanceThisCarM , 2 ) ) ;
1282
- var frontairhoseheightadjustmentreferenceM = ( float ) Math . Sqrt ( ( float ) Math . Pow ( CarAirHoseLengthM , 2 ) - ( float ) Math . Pow ( CouplerDistanceBehindCarM , 2 ) ) ;
1284
+ // Calculate airhose angles and height adjustment values for the air hose. Firstly the "rest point" is calculated, and then the real time point.
1285
+ // 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.
1286
+
1287
+ // Calculate height adjustment.
1288
+ var rearairhoseheightadjustmentreferenceM = ( float ) Math . Sqrt ( ( float ) Math . Pow ( CarAirHoseLengthM , 2 ) - ( float ) Math . Pow ( CarAirHoseHorizontalLengthM , 2 ) ) ;
1289
+ var frontairhoseheightadjustmentreferenceM = ( float ) Math . Sqrt ( ( float ) Math . Pow ( CarAirHoseLengthM , 2 ) - ( float ) Math . Pow ( CarBehind . CarAirHoseHorizontalLengthM , 2 ) ) ;
1283
1290
1284
- RearAirHoseHeightAdjustmentM = ( float ) Math . Sqrt ( ( float ) Math . Pow ( CarAirHoseLengthM , 2 ) - ( float ) Math . Pow ( ( CouplerDistanceThisCarM + CouplerSlackM / 2.0f ) , 2 ) ) ;
1285
- CarBehind . FrontAirHoseHeightAdjustmentM = ( float ) Math . Sqrt ( ( float ) Math . Pow ( CarAirHoseLengthM , 2 ) - ( float ) Math . Pow ( ( CouplerDistanceBehindCarM + CouplerSlackM / 2.0f ) , 2 ) ) ;
1291
+ // actual airhose height
1292
+ RearAirHoseHeightAdjustmentM = ( float ) Math . Sqrt ( ( float ) Math . Pow ( CarAirHoseLengthM , 2 ) - ( float ) Math . Pow ( ( CarAirHoseHorizontalLengthM + CouplerSlackM ) , 2 ) ) ;
1293
+ CarBehind . FrontAirHoseHeightAdjustmentM = ( float ) Math . Sqrt ( ( float ) Math . Pow ( CarAirHoseLengthM , 2 ) - ( float ) Math . Pow ( ( CarBehind . CarAirHoseHorizontalLengthM + CouplerSlackM ) , 2 ) ) ;
1286
1294
1287
1295
// refererence adjustment heights to rest position
1296
+ // If higher then rest position, then +ve adjustment
1288
1297
if ( RearAirHoseHeightAdjustmentM >= rearairhoseheightadjustmentreferenceM )
1289
1298
{
1290
1299
RearAirHoseHeightAdjustmentM -= rearairhoseheightadjustmentreferenceM ;
1291
1300
}
1292
- else
1301
+ else // if lower then the rest position, then -ve adjustment
1293
1302
{
1294
- RearAirHoseHeightAdjustmentM = rearairhoseheightadjustmentreferenceM - RearAirHoseHeightAdjustmentM ;
1303
+ RearAirHoseHeightAdjustmentM = ( rearairhoseheightadjustmentreferenceM - RearAirHoseHeightAdjustmentM ) ;
1295
1304
}
1296
1305
1297
1306
if ( CarBehind . FrontAirHoseHeightAdjustmentM >= frontairhoseheightadjustmentreferenceM )
@@ -1303,31 +1312,38 @@ public void UpdateTrainDerailmentRisk()
1303
1312
CarBehind . FrontAirHoseHeightAdjustmentM = frontairhoseheightadjustmentreferenceM - CarBehind . FrontAirHoseHeightAdjustmentM ;
1304
1313
}
1305
1314
1306
- var rearairhoseangleadjustmentreferenceRad = ( float ) Math . Cos ( CouplerDistanceThisCarM / CarAirHoseLengthM ) ;
1307
- var frontairhoseangleadjustmentreferenceRad = ( float ) Math . Cos ( CouplerDistanceBehindCarM / CarAirHoseLengthM ) ;
1315
+ // Calculate angle adjustments
1316
+ var rearairhoseangleadjustmentreferenceRad = ( float ) Math . Asin ( CarAirHoseHorizontalLengthM / CarAirHoseLengthM ) ;
1317
+ var frontairhoseangleadjustmentreferenceRad = ( float ) Math . Asin ( CarBehind . CarAirHoseHorizontalLengthM / CarAirHoseLengthM ) ;
1308
1318
1309
- RearAirHoseAngleAdjustmentRad = ( float ) Math . Cos ( ( CouplerDistanceThisCarM + CouplerSlackM / 2.0f ) / CarAirHoseLengthM ) ;
1310
- CarBehind . FrontAirHoseAngleAdjustmentRad = ( float ) Math . Cos ( ( CouplerDistanceBehindCarM + CouplerSlackM / 2.0f ) / CarAirHoseLengthM ) ;
1319
+ RearAirHoseZAngleAdjustmentRad = ( float ) Math . Asin ( ( CarAirHoseHorizontalLengthM + CouplerSlackM ) / CarAirHoseLengthM ) ;
1320
+ CarBehind . FrontAirHoseZAngleAdjustmentRad = ( float ) Math . Asin ( ( CarBehind . CarAirHoseHorizontalLengthM + CouplerSlackM ) / CarAirHoseLengthM ) ;
1311
1321
1312
1322
// refererence adjustment angles to rest position
1313
- if ( RearAirHoseAngleAdjustmentRad >= rearairhoseangleadjustmentreferenceRad )
1323
+ if ( RearAirHoseZAngleAdjustmentRad >= rearairhoseangleadjustmentreferenceRad )
1314
1324
{
1315
- RearAirHoseAngleAdjustmentRad -= rearairhoseangleadjustmentreferenceRad ;
1325
+ RearAirHoseZAngleAdjustmentRad -= rearairhoseangleadjustmentreferenceRad ;
1316
1326
}
1317
1327
else
1318
1328
{
1319
- RearAirHoseAngleAdjustmentRad = rearairhoseangleadjustmentreferenceRad - RearAirHoseAngleAdjustmentRad ;
1329
+ RearAirHoseZAngleAdjustmentRad = ( rearairhoseangleadjustmentreferenceRad - RearAirHoseZAngleAdjustmentRad ) ;
1320
1330
}
1321
1331
1322
- if ( CarBehind . FrontAirHoseAngleAdjustmentRad >= frontairhoseangleadjustmentreferenceRad )
1332
+ // The Y axis angle adjustment should be the same as the z axis
1333
+ RearAirHoseYAngleAdjustmentRad = RearAirHoseZAngleAdjustmentRad ;
1334
+
1335
+ if ( CarBehind . FrontAirHoseZAngleAdjustmentRad >= frontairhoseangleadjustmentreferenceRad )
1323
1336
{
1324
- CarBehind . FrontAirHoseAngleAdjustmentRad -= frontairhoseangleadjustmentreferenceRad ;
1337
+ CarBehind . FrontAirHoseZAngleAdjustmentRad -= frontairhoseangleadjustmentreferenceRad ;
1325
1338
}
1326
1339
else
1327
1340
{
1328
- CarBehind . FrontAirHoseAngleAdjustmentRad = frontairhoseangleadjustmentreferenceRad - CarBehind . FrontAirHoseAngleAdjustmentRad ;
1341
+ CarBehind . FrontAirHoseZAngleAdjustmentRad = ( frontairhoseangleadjustmentreferenceRad - CarBehind . FrontAirHoseZAngleAdjustmentRad ) ;
1329
1342
}
1330
1343
1344
+ // The Y axis angle adjustment should be the same as the z axis
1345
+ CarBehind . FrontAirHoseYAngleAdjustmentRad = CarBehind . FrontAirHoseZAngleAdjustmentRad ;
1346
+
1331
1347
}
1332
1348
1333
1349
// Train will derail if lateral forces on the train exceed the vertical forces holding the train on the railway track.
0 commit comments