2020
2121namespace Orts . Simulation
2222{
23- public class Weather
23+ public static class WeatherConstants
2424 {
25- // Rainy conditions (Glossary of Meteorology (June 2000). "Rain". American Meteorological Society. Retrieved 2010-01-15.):
26- // Type Rate
27- // Light <2.5mm/h
28- // Moderate 2.5-7.3mm/h
29- // Heavy >7.3mm/h
30- // Violent >50.0mm/h
31- //
32- // Snowy conditions (Glossary of Meteorology (2009). "Snow". American Meteorological Society. Retrieved 2009-06-28.):
33- // Type Visibility
34- // Light >1.0km
35- // Moderate 0.5-1.0km
36- // Heavy <0.5km
25+ // Source: http://www.icscc.org.cn/upload/file/20190102/Doc.9837-EN%20Manual%20on%20Automatic%20Meteorological%20Observing%20Systems%20at%20Aerodromes.pdf
26+ // Manual on Automatic Meteorological Observing Systems at Aerodromes, Second Edition - 2011, International Civil Aviation Organization
27+ // Type Intensity Rate (mm/h)
28+ // Drizzle Light <0.1
29+ // Moderate 0.1-0.5
30+ // Heavy >0.5
31+ // Rain Light <2.5
32+ // Moderate 2.5-10.0
33+ // Heavy >10.0
34+ // Snow Light <1.0
35+ // Moderate 1.0-5.0
36+ // Heavy >5.0
37+ // Other interesting items:
38+ // - Page 79, Table A-1. MOR limit above which visibility is equal to MOR
39+ // Night/day background luminance values
40+ // - Page 81, Figure A-2. Example of diagram (T_air, RH) used for determining the present weather phenomenon
41+ // Chart of precipitation type vs air temperature and humidity
42+
43+ // Final values are twice the heavy value, as a reasonable maximum possible value for interpolation
44+ public static readonly float [ ] DrizzleRateMMpH = new [ ] { 0.0f , 0.1f , 0.5f , 1.0f } ;
45+ public static readonly float [ ] RainRateMMpH = new [ ] { 0.0f , 2.5f , 10.0f , 20.0f } ;
46+ public static readonly float [ ] SnowRateMMpH = new [ ] { 0.0f , 1.0f , 5.0f , 10.0f } ;
47+
48+ // Wind speed (Beaufort scale)
49+ // Number Description Speed (m/s)
50+ // 0 Calm >0.0
51+ // 1 Light air >0.5
52+ // 2 Light breeze >1.6
53+ // 3 Gentle breeze >3.4
54+ // 4 Moderate breeze >5.5
55+ // 5 Fresh breeze >8.0
56+ // 6 Strong breeze >10.8
57+ // 7 High wind >13.9
58+ // 8 Gale >17.2
59+ // 9 Strong gale >20.8
60+ // 10 Storm >24.5
61+ // 11 Violent storm >28.5
62+ // 12 Hurricane-force >32.7
63+ public static readonly float [ ] WindSpeedBeaufortMpS = new [ ] { 0.0f , 0.5f , 1.6f , 3.4f , 5.5f , 8.0f , 10.8f , 13.9f , 17.2f , 20.8f , 24.5f , 28.5f , 32.7f } ;
3764
65+ // Wind gusts ("Rafale". Glossaire météorologique (in French). Météo-France. Retrieved 2018-11-15.):
66+ // Type Excess speed (m/s)
67+ // Light >5.1 (10-15 knots)
68+ // Moderate >7.7 (15-25 knots)
69+ // Heavy >12.9 (>25 knots)
70+ public static readonly float [ ] WindSpeedGustMpS = new [ ] { 5.1f , 7.7f , 12.9f , 25.8f } ;
71+
72+ public enum Condition
73+ {
74+ Light ,
75+ Moderate ,
76+ Heavy ,
77+ }
78+ }
79+
80+ public class Weather
81+ {
3882 // Fog/visibility distance. Ranges from 10m (can't see anything), 5km (medium), 20km (clear) to 100km (clear arctic).
3983 public float VisibilityM ;
4084
@@ -47,8 +91,22 @@ public class Weather
4791 // Precipitation liquidity; 1 = rain, 0 = snow; intermediate values possible with dynamic weather.
4892 public float PrecipitationLiquidity ;
4993
50- public Vector2 WindSpeedMpS ;
94+ // Wind has an average direction (normalized vector pointing WITH wind movement) and speed, and instantaneous direction and speed (e.g. gusts).
95+ public Vector2 WindAverageDirection ;
96+ public Vector2 WindInstantaneousDirection ;
97+ public float WindAverageSpeedMpS ;
98+ public float WindInstantaneousSpeedMpS ;
99+
100+ public float WindAverageDirectionRad
101+ {
102+ get => ( float ) Math . Atan2 ( WindAverageDirection . X , - WindAverageDirection . Y ) ;
103+ set => WindAverageDirection = new Vector2 ( ( float ) Math . Sin ( value ) , - ( float ) Math . Cos ( value ) ) ;
104+ }
51105
52- public float WindDirectionRad => ( float ) Math . Atan2 ( WindSpeedMpS . X , WindSpeedMpS . Y ) ;
106+ public float WindInstantaneousDirectionRad
107+ {
108+ get => ( float ) Math . Atan2 ( WindInstantaneousDirection . X , - WindInstantaneousDirection . Y ) ;
109+ set => WindInstantaneousDirection = new Vector2 ( ( float ) Math . Sin ( value ) , - ( float ) Math . Cos ( value ) ) ;
110+ }
53111 }
54112}
0 commit comments