| | 1 | | using System.Diagnostics; |
| | 2 | |
|
| | 3 | | namespace Towel.Measurements; |
| | 4 | |
|
| | 5 | | // This file contains all the unit defintions as enum values |
| | 6 | | // for the various type of measurements. |
| | 7 | |
|
| | 8 | | #region Angle |
| | 9 | |
|
| | 10 | | /// <summary>Contains unit types and conversion factors for the generic Angle struct.</summary> |
| | 11 | | public static class Angle |
| | 12 | | { |
| | 13 | | /// <summary>Units for angle measurements.</summary> |
| | 14 | | [Measurement.ParseableUnit] |
| | 15 | | public enum Units |
| | 16 | | { |
| | 17 | | // Enum values must be 0, 1, 2, 3... as they are used for array look ups. |
| | 18 | | // They also need to be in order of least to greatest so that the enum |
| | 19 | | // value can be used for comparison checks. |
| | 20 | |
|
| | 21 | | /// <summary>Units of an angle measurement.</summary> |
| | 22 | | [ConversionFactor(Degrees, "9 / 10")] |
| | 23 | | [ConversionFactor(Radians, "π / 200")] |
| | 24 | | [ConversionFactor(Revolutions, "1 / 400")] |
| | 25 | | Gradians = 0, |
| | 26 | | /// <summary>Units of an angle measurement.</summary> |
| | 27 | | [ConversionFactor(Gradians, "10 / 9")] |
| | 28 | | [ConversionFactor(Radians, "π / 180")] |
| | 29 | | [ConversionFactor(Revolutions, "1 / 360")] |
| | 30 | | Degrees = 1, |
| | 31 | | /// <summary>Units of an angle measurement.</summary> |
| | 32 | | [ConversionFactor(Gradians, "200 / π")] |
| | 33 | | [ConversionFactor(Degrees, "180 / π")] |
| | 34 | | [ConversionFactor(Revolutions, "1 / (2π)")] |
| | 35 | | Radians = 2, |
| | 36 | | /// <summary>Units of an angle measurement.</summary> |
| | 37 | | [ConversionFactor(Gradians, "400")] |
| | 38 | | [ConversionFactor(Degrees, "360")] |
| | 39 | | [ConversionFactor(Radians, "2π")] |
| | 40 | | Revolutions = 3, |
| | 41 | | } |
| | 42 | | } |
| | 43 | |
|
| | 44 | | #endregion |
| | 45 | |
|
| | 46 | | #region ElectricCharge |
| | 47 | |
|
| | 48 | | /// <summary>Contains unit types and conversion factors for the generic ElectricCharge struct.</summary> |
| | 49 | | public static class ElectricCharge |
| | 50 | | { |
| | 51 | | /// <summary>Units for electric charge measurements.</summary> |
| | 52 | | [Measurement.ParseableUnit] |
| | 53 | | public enum Units |
| | 54 | | { |
| | 55 | | // Enum values must be 0, 1, 2, 3... as they are used for array look ups. |
| | 56 | | // They also need to be in order of least to greatest so that the enum |
| | 57 | | // value can be used for comparison checks. |
| | 58 | |
|
| | 59 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 60 | | [MetricUnit(MetricUnits.Yocto)] |
| | 61 | | Yoctocoulombs = 0, |
| | 62 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 63 | | [MetricUnit(MetricUnits.Zepto)] |
| | 64 | | Zeptocoulombs = 1, |
| | 65 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 66 | | [MetricUnit(MetricUnits.Atto)] |
| | 67 | | Attocoulombs = 2, |
| | 68 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 69 | | [MetricUnit(MetricUnits.Femto)] |
| | 70 | | Femtocoulombs = 3, |
| | 71 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 72 | | [MetricUnit(MetricUnits.Pico)] |
| | 73 | | Picocoulombs = 4, |
| | 74 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 75 | | [MetricUnit(MetricUnits.Nano)] |
| | 76 | | Nanocoulombs = 5, |
| | 77 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 78 | | [MetricUnit(MetricUnits.Micro)] |
| | 79 | | Microcoulombs = 6, |
| | 80 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 81 | | [MetricUnit(MetricUnits.Milli)] |
| | 82 | | Millicoulombs = 7, |
| | 83 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 84 | | [MetricUnit(MetricUnits.Centi)] |
| | 85 | | Centicoulombs = 8, |
| | 86 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 87 | | [MetricUnit(MetricUnits.Deci)] |
| | 88 | | Decicoulombs = 9, |
| | 89 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 90 | | [MetricUnit(MetricUnits.BASE)] |
| | 91 | | Coulombs = 10, |
| | 92 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 93 | | [MetricUnit(MetricUnits.Deka)] |
| | 94 | | Dekacoulombs = 11, |
| | 95 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 96 | | [MetricUnit(MetricUnits.Hecto)] |
| | 97 | | Hectocoulombs = 12, |
| | 98 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 99 | | [MetricUnit(MetricUnits.Kilo)] |
| | 100 | | Kilocoulombs = 13, |
| | 101 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 102 | | [MetricUnit(MetricUnits.Mega)] |
| | 103 | | Megacoulombs = 14, |
| | 104 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 105 | | [MetricUnit(MetricUnits.Giga)] |
| | 106 | | Gigacoulombs = 15, |
| | 107 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 108 | | [MetricUnit(MetricUnits.Tera)] |
| | 109 | | Teracoulombs = 16, |
| | 110 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 111 | | [MetricUnit(MetricUnits.Peta)] |
| | 112 | | Petacoulombs = 17, |
| | 113 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 114 | | [MetricUnit(MetricUnits.Exa)] |
| | 115 | | Exacoulombs = 18, |
| | 116 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 117 | | [MetricUnit(MetricUnits.Zetta)] |
| | 118 | | Zettacoulombs = 19, |
| | 119 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 120 | | [MetricUnit(MetricUnits.Yotta)] |
| | 121 | | Yottacoulombs = 20, |
| | 122 | | } |
| | 123 | | } |
| | 124 | |
|
| | 125 | | #endregion |
| | 126 | |
|
| | 127 | | #region Length |
| | 128 | |
|
| | 129 | | /// <summary>Contains unit types and conversion factors for the generic Length struct.</summary> |
| | 130 | | public static class Length |
| | 131 | | { |
| | 132 | | /// <summary>Units for length measurements.</summary> |
| | 133 | | [Measurement.ParseableUnit] |
| | 134 | | public enum Units |
| | 135 | | { |
| | 136 | | // Enum values must be 0, 1, 2, 3... as they are used for array look ups. |
| | 137 | | // They also need to be in order of least to greatest so that the enum |
| | 138 | | // value can be used for comparison checks. |
| | 139 | |
|
| | 140 | | /// <summary>Units of an length measurement.</summary> |
| | 141 | | [MetricUnit(MetricUnits.Yocto)] |
| | 142 | | Yoctometers = 0, |
| | 143 | | /// <summary>Units of an length measurement.</summary> |
| | 144 | | [MetricUnit(MetricUnits.Zepto)] |
| | 145 | | Zeptometers = 1, |
| | 146 | | /// <summary>Units of an length measurement.</summary> |
| | 147 | | [MetricUnit(MetricUnits.Atto)] |
| | 148 | | Attometers = 2, |
| | 149 | | /// <summary>Units of an length measurement.</summary> |
| | 150 | | [MetricUnit(MetricUnits.Femto)] |
| | 151 | | Femtometers = 3, |
| | 152 | | /// <summary>Units of an length measurement.</summary> |
| | 153 | | [MetricUnit(MetricUnits.Pico)] |
| | 154 | | Picometers = 4, |
| | 155 | | /// <summary>Units of an length measurement.</summary> |
| | 156 | | [MetricUnit(MetricUnits.Nano)] |
| | 157 | | Nanometers = 5, |
| | 158 | | /// <summary>Units of an length measurement.</summary> |
| | 159 | | [MetricUnit(MetricUnits.Micro)] |
| | 160 | | Micrometers = 6, |
| | 161 | | /// <summary>Units of an length measurement.</summary> |
| | 162 | | [MetricUnit(MetricUnits.Milli)] |
| | 163 | | Millimeters = 7, |
| | 164 | | /// <summary>Units of an length measurement.</summary> |
| | 165 | | [MetricUnit(MetricUnits.Centi)] |
| | 166 | | Centimeters = 8, |
| | 167 | | /// <summary>Units of an length measurement.</summary> |
| | 168 | | [ConversionFactor(Yoctometers, "2.54 * 10 ^ 22")] |
| | 169 | | [ConversionFactor(Zeptometers, "2.54 * 10 ^ 19")] |
| | 170 | | [ConversionFactor(Attometers, "2.54 * 10 ^ 16")] |
| | 171 | | [ConversionFactor(Femtometers, "2.54 * 10 ^ 13")] |
| | 172 | | [ConversionFactor(Picometers, "2.54 * 10 ^ 10")] |
| | 173 | | [ConversionFactor(Nanometers, "25400000")] |
| | 174 | | [ConversionFactor(Micrometers, "25400")] |
| | 175 | | [ConversionFactor(Millimeters, "25.4")] |
| | 176 | | [ConversionFactor(Centimeters, "2.54")] |
| | 177 | | Inches = 9, |
| | 178 | | /// <summary>Units of an length measurement.</summary> |
| | 179 | | [ConversionFactor(Inches, "3.937")] |
| | 180 | | [MetricUnit(MetricUnits.Deci)] |
| | 181 | | Decimeters = 10, |
| | 182 | | /// <summary>Units of an length measurement.</summary> |
| | 183 | | [ConversionFactor(Yoctometers, "3.048 * 10 ^ 23")] |
| | 184 | | [ConversionFactor(Zeptometers, "3.048 * 10 ^ 20")] |
| | 185 | | [ConversionFactor(Attometers, "3.048 * 10 ^ 17")] |
| | 186 | | [ConversionFactor(Femtometers, "3.048 * 10 ^ 14")] |
| | 187 | | [ConversionFactor(Picometers, "3.048 * 10 ^ 11")] |
| | 188 | | [ConversionFactor(Nanometers, "304800000")] |
| | 189 | | [ConversionFactor(Micrometers, "304800")] |
| | 190 | | [ConversionFactor(Millimeters, "304.8")] |
| | 191 | | [ConversionFactor(Centimeters, "30.48")] |
| | 192 | | [ConversionFactor(Inches, "12")] |
| | 193 | | [ConversionFactor(Decimeters, "3.048")] |
| | 194 | | Feet = 11, |
| | 195 | | /// <summary>Units of an length measurement.</summary> |
| | 196 | | [ConversionFactor(Yoctometers, "9.144 * 10 ^ 23")] |
| | 197 | | [ConversionFactor(Zeptometers, "9.144 * 10 ^ 20")] |
| | 198 | | [ConversionFactor(Attometers, "9.144 * 10 ^ 17")] |
| | 199 | | [ConversionFactor(Femtometers, "9.144 * 10 ^ 14")] |
| | 200 | | [ConversionFactor(Picometers, "9.144 * 10 ^ 11")] |
| | 201 | | [ConversionFactor(Nanometers, "914400000")] |
| | 202 | | [ConversionFactor(Micrometers, "914400")] |
| | 203 | | [ConversionFactor(Millimeters, "914.4")] |
| | 204 | | [ConversionFactor(Centimeters, "91.44")] |
| | 205 | | [ConversionFactor(Inches, "36")] |
| | 206 | | [ConversionFactor(Decimeters, "9.144")] |
| | 207 | | [ConversionFactor(Feet, "3")] |
| | 208 | | Yards = 12, |
| | 209 | | /// <summary>Units of an length measurement.</summary> |
| | 210 | | [ConversionFactor(Inches, "39.37")] |
| | 211 | | [ConversionFactor(Feet, "3.281")] |
| | 212 | | [ConversionFactor(Yards, "1.094")] |
| | 213 | | [MetricUnit(MetricUnits.BASE)] |
| | 214 | | Meters = 13, |
| | 215 | | /// <summary>Units of an length measurement.</summary> |
| | 216 | | [ConversionFactor(Inches, "393.7")] |
| | 217 | | [ConversionFactor(Feet, "32.81")] |
| | 218 | | [ConversionFactor(Yards, "10.94")] |
| | 219 | | [MetricUnit(MetricUnits.Deka)] |
| | 220 | | Dekameters = 14, |
| | 221 | | /// <summary>Units of an length measurement.</summary> |
| | 222 | | [ConversionFactor(Inches, "3937")] |
| | 223 | | [ConversionFactor(Feet, "328.1")] |
| | 224 | | [ConversionFactor(Yards, "109.4")] |
| | 225 | | [MetricUnit(MetricUnits.Hecto)] |
| | 226 | | Hectometers = 15, |
| | 227 | | /// <summary>Units of an length measurement.</summary> |
| | 228 | | [ConversionFactor(Inches, "39370")] |
| | 229 | | [ConversionFactor(Feet, "3281")] |
| | 230 | | [ConversionFactor(Yards, "1094")] |
| | 231 | | [MetricUnit(MetricUnits.Kilo)] |
| | 232 | | Kilometers = 16, |
| | 233 | | /// <summary>Units of an length measurement.</summary> |
| | 234 | | [ConversionFactor(Yoctometers, "1.609 * 10 ^ 27")] |
| | 235 | | [ConversionFactor(Zeptometers, "1.609 * 10 ^ 24")] |
| | 236 | | [ConversionFactor(Attometers, "1.609 * 10 ^ 21")] |
| | 237 | | [ConversionFactor(Femtometers, "1.609 * 10 ^ 18")] |
| | 238 | | [ConversionFactor(Picometers, "1.609 * 10 ^ 15")] |
| | 239 | | [ConversionFactor(Nanometers, "1.609 * 10 ^ 12")] |
| | 240 | | [ConversionFactor(Micrometers, "1609340000")] |
| | 241 | | [ConversionFactor(Millimeters, "1609340")] |
| | 242 | | [ConversionFactor(Centimeters, "160934")] |
| | 243 | | [ConversionFactor(Inches, "63360")] |
| | 244 | | [ConversionFactor(Decimeters, "16093.4")] |
| | 245 | | [ConversionFactor(Feet, "5280")] |
| | 246 | | [ConversionFactor(Yards, "1760")] |
| | 247 | | [ConversionFactor(Meters, "1609.344")] |
| | 248 | | [ConversionFactor(Dekameters, "160.934")] |
| | 249 | | [ConversionFactor(Hectometers, "16.0934")] |
| | 250 | | [ConversionFactor(Kilometers, "1.60934")] |
| | 251 | | Miles = 17, |
| | 252 | | /// <summary>Units of an length measurement.</summary> |
| | 253 | | [ConversionFactor(Yoctometers, "1.852 * 10 ^ 27")] |
| | 254 | | [ConversionFactor(Zeptometers, "1.852 * 10 ^ 24")] |
| | 255 | | [ConversionFactor(Attometers, "1.852 * 10 ^ 21")] |
| | 256 | | [ConversionFactor(Femtometers, "1.852 * 10 ^ 18")] |
| | 257 | | [ConversionFactor(Picometers, "1.852 * 10 ^ 15")] |
| | 258 | | [ConversionFactor(Nanometers, "1.852 * 10 ^ 12")] |
| | 259 | | [ConversionFactor(Micrometers, "1852000000")] |
| | 260 | | [ConversionFactor(Millimeters, "1852000")] |
| | 261 | | [ConversionFactor(Centimeters, "185200")] |
| | 262 | | [ConversionFactor(Inches, "72913.42082")] |
| | 263 | | [ConversionFactor(Decimeters, "18520")] |
| | 264 | | [ConversionFactor(Feet, "6076.11840")] |
| | 265 | | [ConversionFactor(Yards, "2025.37280")] |
| | 266 | | [ConversionFactor(Meters, "1852")] |
| | 267 | | [ConversionFactor(Dekameters, "185.2")] |
| | 268 | | [ConversionFactor(Hectometers, "18.52")] |
| | 269 | | [ConversionFactor(Kilometers, "1.852")] |
| | 270 | | [ConversionFactor(Miles, "1.15078")] |
| | 271 | | NauticalMiles = 18, |
| | 272 | | /// <summary>Units of an length measurement.</summary> |
| | 273 | | [ConversionFactor(Inches, "39370000")] |
| | 274 | | [ConversionFactor(Feet, "3281000")] |
| | 275 | | [ConversionFactor(Yards, "1094000")] |
| | 276 | | [ConversionFactor(Miles, "621.371")] |
| | 277 | | [ConversionFactor(NauticalMiles, "540")] |
| | 278 | | [MetricUnit(MetricUnits.Mega)] |
| | 279 | | Megameters = 19, |
| | 280 | | /// <summary>Units of an length measurement.</summary> |
| | 281 | | [ConversionFactor(Inches, "3.937 * 10 ^ 10")] |
| | 282 | | [ConversionFactor(Feet, "3.281 * 10 ^ 9")] |
| | 283 | | [ConversionFactor(Yards, "1094000000")] |
| | 284 | | [ConversionFactor(Miles, "621371")] |
| | 285 | | [ConversionFactor(NauticalMiles, "540000")] |
| | 286 | | [MetricUnit(MetricUnits.Giga)] |
| | 287 | | Gigameters = 20, |
| | 288 | | /// <summary>Units of an length measurement.</summary> |
| | 289 | | [ConversionFactor(Inches, "3.937 * 10 ^ 13")] |
| | 290 | | [ConversionFactor(Feet, "3.281 * 10 ^ 12")] |
| | 291 | | [ConversionFactor(Yards, "1.094 * 10 ^ 12")] |
| | 292 | | [ConversionFactor(Miles, "621371000")] |
| | 293 | | [ConversionFactor(NauticalMiles, "540000000")] |
| | 294 | | [MetricUnit(MetricUnits.Tera)] |
| | 295 | | Terameters = 21, |
| | 296 | | /// <summary>Units of an length measurement.</summary> |
| | 297 | | [ConversionFactor(Inches, "3.937 * 10 ^ 16")] |
| | 298 | | [ConversionFactor(Feet, "3.281 * 10 ^ 15")] |
| | 299 | | [ConversionFactor(Yards, "1.094 * 10 ^ 15")] |
| | 300 | | [ConversionFactor(Miles, "6.21371 * 10 ^ 11")] |
| | 301 | | [ConversionFactor(NauticalMiles, "5.4 * 10 ^ 11")] |
| | 302 | | [MetricUnit(MetricUnits.Peta)] |
| | 303 | | Petameters = 22, |
| | 304 | | /// <summary>Units of an length measurement.</summary> |
| | 305 | | [ConversionFactor(Inches, "3.937 * 10 ^ 19")] |
| | 306 | | [ConversionFactor(Feet, "3.281 * 10 ^ 18")] |
| | 307 | | [ConversionFactor(Yards, "1.094 * 10 ^ 18")] |
| | 308 | | [ConversionFactor(Miles, "6.21371 * 10 ^ 14")] |
| | 309 | | [ConversionFactor(NauticalMiles, "5.4 * 10 ^ 14")] |
| | 310 | | [MetricUnit(MetricUnits.Exa)] |
| | 311 | | Exameters = 23, |
| | 312 | | /// <summary>Units of an length measurement.</summary> |
| | 313 | | [ConversionFactor(Inches, "3.937 * 10 ^ 22")] |
| | 314 | | [ConversionFactor(Feet, "3.281 * 10 ^ 21")] |
| | 315 | | [ConversionFactor(Yards, "1.094 * 10 ^ 21")] |
| | 316 | | [ConversionFactor(Miles, "6.21371 * 10 ^ 17")] |
| | 317 | | [ConversionFactor(NauticalMiles, "5.4 * 10 ^ 17")] |
| | 318 | | [MetricUnit(MetricUnits.Zetta)] |
| | 319 | | Zettameters = 24, |
| | 320 | | /// <summary>Units of an length measurement.</summary> |
| | 321 | | [ConversionFactor(Inches, "3.937 * 10 ^ 25")] |
| | 322 | | [ConversionFactor(Feet, "3.281 * 10 ^ 24")] |
| | 323 | | [ConversionFactor(Yards, "1.094 * 10 ^ 24")] |
| | 324 | | [ConversionFactor(Miles, "6.21371 * 10 ^ 20")] |
| | 325 | | [ConversionFactor(NauticalMiles, "5.4 * 10 ^ 20")] |
| | 326 | | [MetricUnit(MetricUnits.Yotta)] |
| | 327 | | Yottameters = 25, |
| | 328 | | // <summary>Units of an length measurement.</summary> |
| | 329 | | // LightYear = 26, |
| | 330 | | } |
| | 331 | | } |
| | 332 | |
|
| | 333 | | #endregion |
| | 334 | |
|
| | 335 | | #region Mass |
| | 336 | |
|
| | 337 | | /// <summary>Contains unit types and conversion factors for the generic Mass struct.</summary> |
| | 338 | | public static class Mass |
| | 339 | | { |
| | 340 | | /// <summary>Units for Mass measurements.</summary> |
| | 341 | | [Measurement.ParseableUnit] |
| | 342 | | public enum Units |
| | 343 | | { |
| | 344 | | // Note: It is critical that these enum values are in increasing order of size. |
| | 345 | | // Their value is used as a priority when doing operations on measurements in |
| | 346 | | // different units. |
| | 347 | |
|
| | 348 | | /// <summary>Units of an mass measurement.</summary> |
| | 349 | | [MetricUnit(MetricUnits.Yocto)] |
| | 350 | | Yoctograms = 0, |
| | 351 | | /// <summary>Units of an mass measurement.</summary> |
| | 352 | | [MetricUnit(MetricUnits.Zepto)] |
| | 353 | | Zeptograms = 1, |
| | 354 | | /// <summary>Units of an mass measurement.</summary> |
| | 355 | | [MetricUnit(MetricUnits.Atto)] |
| | 356 | | Attograms = 2, |
| | 357 | | /// <summary>Units of an mass measurement.</summary> |
| | 358 | | [MetricUnit(MetricUnits.Femto)] |
| | 359 | | Femtograms = 3, |
| | 360 | | /// <summary>Units of an mass measurement.</summary> |
| | 361 | | [MetricUnit(MetricUnits.Pico)] |
| | 362 | | Picograms = 4, |
| | 363 | | /// <summary>Units of an mass measurement.</summary> |
| | 364 | | [MetricUnit(MetricUnits.Nano)] |
| | 365 | | Nanograms = 5, |
| | 366 | | /// <summary>Units of an mass measurement.</summary> |
| | 367 | | [MetricUnit(MetricUnits.Micro)] |
| | 368 | | Micrograms = 6, |
| | 369 | | /// <summary>Units of an mass measurement.</summary> |
| | 370 | | [MetricUnit(MetricUnits.Milli)] |
| | 371 | | Milligrams = 7, |
| | 372 | | /// <summary>Units of an mass measurement.</summary> |
| | 373 | | [MetricUnit(MetricUnits.Centi)] |
| | 374 | | Centigrams = 8, |
| | 375 | | /// <summary>Units of an mass measurement.</summary> |
| | 376 | | [MetricUnit(MetricUnits.Deci)] |
| | 377 | | Decigrams = 10, |
| | 378 | | /// <summary>Units of an mass measurement.</summary> |
| | 379 | | [MetricUnit(MetricUnits.BASE)] |
| | 380 | | Grams = 13, |
| | 381 | | /// <summary>Units of an mass measurement.</summary> |
| | 382 | | [MetricUnit(MetricUnits.Deka)] |
| | 383 | | Dekagrams = 14, |
| | 384 | | /// <summary>Units of an mass measurement.</summary> |
| | 385 | | [MetricUnit(MetricUnits.Hecto)] |
| | 386 | | Hectograms = 15, |
| | 387 | | /// <summary>Units of an mass measurement.</summary> |
| | 388 | | [MetricUnit(MetricUnits.Kilo)] |
| | 389 | | Kilograms = 16, |
| | 390 | | /// <summary>Units of an mass measurement.</summary> |
| | 391 | | [MetricUnit(MetricUnits.Mega)] |
| | 392 | | Megagrams = 18, |
| | 393 | | /// <summary>Units of an mass measurement.</summary> |
| | 394 | | [MetricUnit(MetricUnits.Giga)] |
| | 395 | | Gigagrams = 19, |
| | 396 | | /// <summary>Units of an mass measurement.</summary> |
| | 397 | | [MetricUnit(MetricUnits.Tera)] |
| | 398 | | Teragrams = 20, |
| | 399 | | /// <summary>Units of an mass measurement.</summary> |
| | 400 | | [MetricUnit(MetricUnits.Peta)] |
| | 401 | | Petagrams = 21, |
| | 402 | | /// <summary>Units of an mass measurement.</summary> |
| | 403 | | [MetricUnit(MetricUnits.Exa)] |
| | 404 | | Exagrams = 22, |
| | 405 | | /// <summary>Units of an mass measurement.</summary> |
| | 406 | | [MetricUnit(MetricUnits.Zetta)] |
| | 407 | | Zettagrams = 23, |
| | 408 | | /// <summary>Units of an mass measurement.</summary> |
| | 409 | | [MetricUnit(MetricUnits.Yotta)] |
| | 410 | | Yottagrams = 24, |
| | 411 | | } |
| | 412 | | } |
| | 413 | |
|
| | 414 | | #endregion |
| | 415 | |
|
| | 416 | | #region Tempurature |
| | 417 | |
|
| | 418 | | /// <summary>Contains unit types and conversion factors for the generic Tempurature struct.</summary> |
| | 419 | | public static class Tempurature |
| | 420 | | { |
| | 421 | | /// <summary>Units for Tempurature measurements.</summary> |
| | 422 | | [Measurement.ParseableUnit] |
| | 423 | | public enum Units |
| | 424 | | { |
| | 425 | | // Enum values must be 0, 1, 2, 3... as they are used for array look ups. |
| | 426 | | // They also need to be in order of preferred autoconversion. |
| | 427 | |
|
| | 428 | | /// <summary>Units of an Tempurature measurement.</summary> |
| | 429 | | Kelvin = 0, |
| | 430 | | /// <summary>Units of an Tempurature measurement.</summary> |
| | 431 | | Celsius = 1, |
| | 432 | | /// <summary>Units of an Tempurature measurement.</summary> |
| | 433 | | Fahrenheit = 2, |
| | 434 | | } |
| | 435 | |
|
| | 436 | | internal static Func<T, T>[][] BuildConversionTable<T>() |
| | 437 | | { |
| | 438 | | T A = Symbolics.ParseAndSimplifyToConstant<T>("273.15"); |
| | 439 | | T B = Symbolics.ParseAndSimplifyToConstant<T>("9 / 5"); |
| | 440 | | T C = Symbolics.ParseAndSimplifyToConstant<T>("459.67"); |
| | 441 | | T D = Symbolics.ParseAndSimplifyToConstant<T>("32"); |
| | 442 | |
|
| | 443 | | Func<T, T>[][] table = ConstructSquareJaggedArray<Func<T, T>>(3); |
| | 444 | |
|
| | 445 | | table[(int)Units.Kelvin][(int)Units.Kelvin] = x => x; |
| | 446 | | table[(int)Units.Kelvin][(int)Units.Celsius] = x => Subtraction(x, A); |
| | 447 | | table[(int)Units.Kelvin][(int)Units.Fahrenheit] = x => Subtraction(Multiplication(x, B), C); |
| | 448 | |
|
| | 449 | | table[(int)Units.Celsius][(int)Units.Celsius] = x => x; |
| | 450 | | table[(int)Units.Celsius][(int)Units.Kelvin] = x => Addition(x, A); |
| | 451 | | table[(int)Units.Celsius][(int)Units.Fahrenheit] = x => Addition(Multiplication(x, B), D); |
| | 452 | |
|
| | 453 | | table[(int)Units.Fahrenheit][(int)Units.Fahrenheit] = x => x; |
| | 454 | | table[(int)Units.Fahrenheit][(int)Units.Celsius] = x => Division(Subtraction(x, D), B); |
| | 455 | | table[(int)Units.Fahrenheit][(int)Units.Kelvin] = x => Division(Addition(x, C), B); |
| | 456 | |
|
| | 457 | | return table; |
| | 458 | | } |
| | 459 | | } |
| | 460 | |
|
| | 461 | | #endregion |
| | 462 | |
|
| | 463 | | #region Time |
| | 464 | |
|
| | 465 | | /// <summary>Contains unit types and conversion factors for the generic Time struct.</summary> |
| | 466 | | public static class Time |
| | 467 | | { |
| | 468 | | /// <summary>Units for time measurements.</summary> |
| | 469 | | [Measurement.ParseableUnit] |
| | 470 | | public enum Units |
| | 471 | | { |
| | 472 | | // Enum values must be 0, 1, 2, 3... as they are used for array look ups. |
| | 473 | | // They also need to be in order of least to greatest so that the enum |
| | 474 | | // value can be used for comparison checks. |
| | 475 | |
|
| | 476 | | /// <summary>Units of an time measurement.</summary> |
| | 477 | | [ConversionFactor(Seconds, "1/1000")] |
| | 478 | | [ConversionFactor(Minutes, "1/60000")] |
| | 479 | | [ConversionFactor(Hours, "1/3600000")] |
| | 480 | | [ConversionFactor(Days, "1/86400000")] |
| | 481 | | Milliseconds = 0, |
| | 482 | | /// <summary>Units of an time measurement.</summary> |
| | 483 | | [ConversionFactor(Milliseconds, "1000")] |
| | 484 | | [ConversionFactor(Minutes, "1/60")] |
| | 485 | | [ConversionFactor(Hours, "1/3600")] |
| | 486 | | [ConversionFactor(Days, "1/86400")] |
| | 487 | | Seconds = 1, |
| | 488 | | /// <summary>Units of an time measurement.</summary> |
| | 489 | | [ConversionFactor(Milliseconds, "60000")] |
| | 490 | | [ConversionFactor(Seconds, "60")] |
| | 491 | | [ConversionFactor(Hours, "1/60")] |
| | 492 | | [ConversionFactor(Days, "1/1440")] |
| | 493 | | Minutes = 2, |
| | 494 | | /// <summary>Units of an time measurement.</summary> |
| | 495 | | [ConversionFactor(Milliseconds, "3600000")] |
| | 496 | | [ConversionFactor(Seconds, "3600")] |
| | 497 | | [ConversionFactor(Minutes, "60")] |
| | 498 | | [ConversionFactor(Days, "1/24")] |
| | 499 | | Hours = 3, |
| | 500 | | /// <summary>Units of an time measurement.</summary> |
| | 501 | | [ConversionFactor(Milliseconds, "86400000")] |
| | 502 | | [ConversionFactor(Seconds, "86400")] |
| | 503 | | [ConversionFactor(Minutes, "1440")] |
| | 504 | | [ConversionFactor(Hours, "24")] |
| | 505 | | Days = 4, |
| | 506 | | } |
| | 507 | | } |
| | 508 | |
|
| | 509 | | #endregion |
| | 510 | |
|
| | 511 | | // Tools has shared functionality between the various unit definitions |
| | 512 | |
|
| | 513 | | #region Tools |
| | 514 | |
|
| | 515 | | [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)] |
| | 516 | | internal class ConversionFactorAttribute : Attribute |
| | 517 | | { |
| | 518 | | internal readonly Enum To; |
| | 519 | | internal readonly string Expression; |
| | 520 | |
|
| 428 | 521 | | internal ConversionFactorAttribute(object to, string expression) |
| 428 | 522 | | { |
| 428 | 523 | | if (to is not Enum) |
| 0 | 524 | | { |
| 0 | 525 | | throw new TowelBugException($"a {nameof(ConversionFactorAttribute)} contains a non-enum value: {to}"); |
| | 526 | | } |
| 428 | 527 | | To = (Enum)to; |
| 428 | 528 | | Expression = expression; |
| 428 | 529 | | } |
| | 530 | |
|
| | 531 | | internal T Value<T>() |
| 116 | 532 | | { |
| 116 | 533 | | Symbolics.Expression expression = Symbolics.Parse<T>(Expression); |
| 116 | 534 | | if (expression.Simplify() is not Symbolics.Constant<T> constant) |
| 0 | 535 | | { |
| 0 | 536 | | throw new TowelBugException($"encountered a measurement conversion expression that could not be simplified to a co |
| | 537 | | } |
| 116 | 538 | | return constant.Value; |
| 116 | 539 | | } |
| | 540 | | } |
| | 541 | |
|
| | 542 | | [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)] |
| | 543 | | internal class MetricUnitAttribute : Attribute |
| | 544 | | { |
| | 545 | | internal readonly MetricUnits MetricUnits; |
| | 546 | |
|
| | 547 | | internal MetricUnitAttribute(MetricUnits metricUnits) |
| | 548 | | { |
| | 549 | | MetricUnits = metricUnits; |
| | 550 | | } |
| | 551 | | } |
| | 552 | |
|
| | 553 | | internal static class UnitConversionTable |
| | 554 | | { |
| | 555 | | internal static Func<T, T>[][] Build<TUnits, T>() |
| | 556 | | where TUnits : struct, Enum |
| | 557 | | { |
| | 558 | | if (typeof(TUnits) == typeof(Tempurature.Units)) |
| | 559 | | { |
| | 560 | | return Tempurature.BuildConversionTable<T>(); |
| | 561 | | } |
| | 562 | |
|
| | 563 | | int size = Convert<TUnits, int>(Meta.GetLastEnumValue<TUnits>()); |
| | 564 | | Func<T, T>[][] conversionFactorTable = ConstructSquareJaggedArray<Func<T, T>>(size + 1); |
| | 565 | | foreach (Enum A_unit in Enum.GetValues<TUnits>()) |
| | 566 | | { |
| | 567 | | int A = System.Convert.ToInt32(A_unit); |
| | 568 | |
|
| | 569 | | foreach (Enum B_unit in Enum.GetValues<TUnits>()) |
| | 570 | | { |
| | 571 | | int B = System.Convert.ToInt32(B_unit); |
| | 572 | |
|
| | 573 | | MetricUnitAttribute? A_metric = A_unit.GetEnumAttribute<MetricUnitAttribute>(); |
| | 574 | | MetricUnitAttribute? B_metric = B_unit.GetEnumAttribute<MetricUnitAttribute>(); |
| | 575 | |
|
| | 576 | | if (A == B) |
| | 577 | | { |
| | 578 | | conversionFactorTable[A][B] = x => x; |
| | 579 | | } |
| | 580 | | else if (A_metric is not null && B_metric is not null) |
| | 581 | | { |
| | 582 | | int metricDifference = (int)A_metric.MetricUnits - (int)B_metric.MetricUnits; |
| | 583 | | if (metricDifference < 0) |
| | 584 | | { |
| | 585 | | metricDifference = -metricDifference; |
| | 586 | | T factor = Power(Constant<T>.Ten, Convert<int, T>(metricDifference)); |
| | 587 | | conversionFactorTable[A][B] = x => Division(x, factor); |
| | 588 | | } |
| | 589 | | else |
| | 590 | | { |
| | 591 | | T factor = Power(Constant<T>.Ten, Convert<int, T>(metricDifference)); |
| | 592 | | conversionFactorTable[A][B] = x => Multiplication(x, factor); |
| | 593 | | } |
| | 594 | | } |
| | 595 | | else if (A < B) |
| | 596 | | { |
| | 597 | | foreach (ConversionFactorAttribute conversionFactor in B_unit.GetEnumAttributes<ConversionFactorAttribute>().W |
| | 598 | | { |
| | 599 | | T factor = conversionFactor.Value<T>(); |
| | 600 | | conversionFactorTable[A][B] = x => Division(x, factor); |
| | 601 | | } |
| | 602 | | } |
| | 603 | | else if (A > B) |
| | 604 | | { |
| | 605 | | foreach (ConversionFactorAttribute conversionFactor in A_unit.GetEnumAttributes<ConversionFactorAttribute>().W |
| | 606 | | { |
| | 607 | | T factor = conversionFactor.Value<T>(); |
| | 608 | | conversionFactorTable[A][B] = x => Multiplication(x, factor); |
| | 609 | | } |
| | 610 | | } |
| | 611 | | else |
| | 612 | | { |
| | 613 | | conversionFactorTable[A][B] = x => throw new Exception("Bug. Encountered an unhandled unit conversion."); |
| | 614 | | } |
| | 615 | |
|
| | 616 | | if (conversionFactorTable[A][B] is null) |
| | 617 | | { |
| | 618 | | Type type1 = typeof(TUnits); |
| | 619 | | Type type2 = typeof(T); |
| | 620 | | Debugger.Break(); |
| | 621 | | } |
| | 622 | | } |
| | 623 | |
|
| | 624 | | //// handle metric units first |
| | 625 | | // MetricUnitAttribute A_metric = A_unit.GetEnumAttribute<MetricUnitAttribute>(); |
| | 626 | | // if (!(A_metric is null)) |
| | 627 | | // { |
| | 628 | | // foreach (Enum B_units in Enum.GetValues(typeof(UNITS))) |
| | 629 | | // { |
| | 630 | | // int B = Convert.ToInt32(B_units); |
| | 631 | | // MetricUnitAttribute B_metric = B_units.GetEnumAttribute<MetricUnitAttribute>(); |
| | 632 | | // if (!(B_metric is null)) |
| | 633 | | // { |
| | 634 | | // int metricDifference = (int)A_metric.MetricUnits - (int)B_metric.MetricUnits; |
| | 635 | | // T factor = Compute.Power(Constant<T>.Ten, Compute.FromInt32<T>(metricDifference)); |
| | 636 | | // conversionFactorTable[A][B] = x => Compute.Multiply(factor, x); |
| | 637 | | // } |
| | 638 | | // else |
| | 639 | | // { |
| | 640 | | // foreach (ConversionFactorAttribute conversionFactor in B_units.GetEnumAttributes<ConversionFactorAt |
| | 641 | | // { |
| | 642 | | // if (conversionFactor.To.Equals(A_unit)) |
| | 643 | | // { |
| | 644 | | // T factor = Compute.Invert(conversionFactor.Value<T>()); |
| | 645 | | // conversionFactorTable[A][B] = x => Compute.Multiply(factor, x); |
| | 646 | | // break; |
| | 647 | | // } |
| | 648 | | // } |
| | 649 | | // } |
| | 650 | | // } |
| | 651 | | // } |
| | 652 | |
|
| | 653 | | //// handle explicit conversion factors |
| | 654 | | // foreach (ConversionFactorAttribute conversionFactor in A_unit.GetEnumAttributes<ConversionFactorAttribute>()) |
| | 655 | | // { |
| | 656 | | // int B = Convert.ToInt32(conversionFactor.To); |
| | 657 | | // T factor = conversionFactor.Value<T>(); |
| | 658 | | // conversionFactorTable[A][B] = x => Compute.Multiply(factor, x); |
| | 659 | | // } |
| | 660 | | } |
| | 661 | | return conversionFactorTable; |
| | 662 | | } |
| | 663 | | } |
| | 664 | |
|
| | 665 | | internal enum MetricUnits |
| | 666 | | { |
| | 667 | | #pragma warning disable SA1602 // Enumeration items should be documented |
| | 668 | | Yocto = -24, |
| | 669 | | Zepto = -21, |
| | 670 | | Atto = -18, |
| | 671 | | Femto = -15, |
| | 672 | | Pico = -12, |
| | 673 | | Nano = -9, |
| | 674 | | Micro = -6, |
| | 675 | | Milli = -3, |
| | 676 | | Centi = -2, |
| | 677 | | Deci = -1, |
| | 678 | | BASE = 0, |
| | 679 | | Deka = 1, |
| | 680 | | Hecto = 2, |
| | 681 | | Kilo = 3, |
| | 682 | | Mega = 6, |
| | 683 | | Giga = 9, |
| | 684 | | Tera = 12, |
| | 685 | | Peta = 15, |
| | 686 | | Exa = 18, |
| | 687 | | Zetta = 21, |
| | 688 | | Yotta = 24, |
| | 689 | | #pragma warning restore SA1602 // Enumeration items should be documented |
| | 690 | | } |
| | 691 | |
|
| | 692 | | #endregion |
| | 693 | |
|
| | 694 | | // Syntax contains the syntax sugar mappings provided via optional alias |
| | 695 | |
|
| | 696 | | #region Syntax |
| | 697 | |
|
| | 698 | | /// <summary>Provides syntax for measurement unit definition. Intended to be referenced via "using static" keyword in fi |
| | 699 | | public static class MeasurementsSyntax |
| | 700 | | { |
| | 701 | | #region Angle Units |
| | 702 | |
|
| | 703 | | /// <summary>Units of an angle measurement.</summary> |
| | 704 | | public static readonly MeasurementUnitsSyntaxTypes.AngleUnits Gradians = new() { _AngleUnits1 = Angle.Units.Gradians } |
| | 705 | | /// <summary>Units of an angle measurement.</summary> |
| | 706 | | public static readonly MeasurementUnitsSyntaxTypes.AngleUnits Degrees = new() { _AngleUnits1 = Angle.Units.Degrees }; |
| | 707 | | /// <summary>Units of an angle measurement.</summary> |
| | 708 | | public static readonly MeasurementUnitsSyntaxTypes.AngleUnits Radians = new() { _AngleUnits1 = Angle.Units.Radians }; |
| | 709 | | /// <summary>Units of an angle measurement.</summary> |
| | 710 | | public static readonly MeasurementUnitsSyntaxTypes.AngleUnits Revolutions = new() { _AngleUnits1 = Angle.Units.Revolut |
| | 711 | |
|
| | 712 | | #endregion |
| | 713 | |
|
| | 714 | | #region Electric Charge Units |
| | 715 | |
|
| | 716 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 717 | | public static readonly MeasurementUnitsSyntaxTypes.ElectricChargeUnits Coulombs = new() { _ElectricChargeUnits1 = Elec |
| | 718 | |
|
| | 719 | | #endregion |
| | 720 | |
|
| | 721 | | #region Electric Current Units |
| | 722 | |
|
| | 723 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 724 | | public static readonly MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits Yoctoampheres = new() { _ElectricChargeUni |
| | 725 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 726 | | public static readonly MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits Zeptoampheres = new() { _ElectricChargeUni |
| | 727 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 728 | | public static readonly MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits Attoampheres = new() { _ElectricChargeUnit |
| | 729 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 730 | | public static readonly MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits Femtoampheres = new() { _ElectricChargeUni |
| | 731 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 732 | | public static readonly MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits Picoampheres = new() { _ElectricChargeUnit |
| | 733 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 734 | | public static readonly MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits Nanoampheres = new() { _ElectricChargeUnit |
| | 735 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 736 | | public static readonly MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits Microampheres = new() { _ElectricChargeUni |
| | 737 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 738 | | public static readonly MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits Milliampheres = new() { _ElectricChargeUni |
| | 739 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 740 | | public static readonly MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits Centiampheres = new() { _ElectricChargeUni |
| | 741 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 742 | | public static readonly MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits Deciampheres = new() { _ElectricChargeUnit |
| | 743 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 744 | | public static readonly MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits Amperes = new() { _ElectricChargeUnits1 = |
| | 745 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 746 | | public static readonly MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits Dekaampheres = new() { _ElectricChargeUnit |
| | 747 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 748 | | public static readonly MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits Hectoampheres = new() { _ElectricChargeUni |
| | 749 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 750 | | public static readonly MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits Kiloampheres = new() { _ElectricChargeUnit |
| | 751 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 752 | | public static readonly MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits Megaampheres = new() { _ElectricChargeUnit |
| | 753 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 754 | | public static readonly MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits Gigaampheres = new() { _ElectricChargeUnit |
| | 755 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 756 | | public static readonly MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits Teraampheres = new() { _ElectricChargeUnit |
| | 757 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 758 | | public static readonly MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits Petaampheres = new() { _ElectricChargeUnit |
| | 759 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 760 | | public static readonly MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits Exaampheres = new() { _ElectricChargeUnits |
| | 761 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 762 | | public static readonly MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits Zettaampheres = new() { _ElectricChargeUni |
| | 763 | | /// <summary>Units of an electric charge measurement.</summary> |
| | 764 | | public static readonly MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits Yottaampheres = new() { _ElectricChargeUni |
| | 765 | |
|
| | 766 | | #endregion |
| | 767 | |
|
| | 768 | | #region Energy Units |
| | 769 | |
|
| | 770 | | /// <summary>Units of an Energy measurement.</summary> |
| | 771 | | public static readonly MeasurementUnitsSyntaxTypes.EnergyBaseUnits Joules = new() { _MassUnits1 = Mass.Units.Kilograms |
| | 772 | |
|
| | 773 | | #endregion |
| | 774 | |
|
| | 775 | | #region Force Units |
| | 776 | |
|
| | 777 | | /// <summary>Units of an force measurement.</summary> |
| | 778 | | public static readonly MeasurementUnitsSyntaxTypes.ForceBaseUnits Newtons = new() { _MassUnits1 = Mass.Units.Kilograms |
| | 779 | |
|
| | 780 | | #endregion |
| | 781 | |
|
| | 782 | | #region Length Units |
| | 783 | |
|
| | 784 | | /// <summary>Units of an length measurement.</summary> |
| | 785 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Yoctometers = new() { _LengthUnits1 = Length.Units.Yoct |
| | 786 | | /// <summary>Units of an length measurement.</summary> |
| | 787 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Zeptometers = new() { _LengthUnits1 = Length.Units.Zept |
| | 788 | | /// <summary>Units of an length measurement.</summary> |
| | 789 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Attometers = new() { _LengthUnits1 = Length.Units.Attom |
| | 790 | | /// <summary>Units of an length measurement.</summary> |
| | 791 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Femtometers = new() { _LengthUnits1 = Length.Units.Femt |
| | 792 | | /// <summary>Units of an length measurement.</summary> |
| | 793 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Picometers = new() { _LengthUnits1 = Length.Units.Picom |
| | 794 | | /// <summary>Units of an length measurement.</summary> |
| | 795 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Nanometers = new() { _LengthUnits1 = Length.Units.Nanom |
| | 796 | | /// <summary>Units of an length measurement.</summary> |
| | 797 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Micrometers = new() { _LengthUnits1 = Length.Units.Micr |
| | 798 | | /// <summary>Units of an length measurement.</summary> |
| | 799 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Millimeters = new() { _LengthUnits1 = Length.Units.Mill |
| | 800 | | /// <summary>Units of an length measurement.</summary> |
| | 801 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Centimeters = new() { _LengthUnits1 = Length.Units.Cent |
| | 802 | | /// <summary>Units of an length measurement.</summary> |
| | 803 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Inches = new() { _LengthUnits1 = Length.Units.Inches }; |
| | 804 | | /// <summary>Units of an length measurement.</summary> |
| | 805 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Decimeters = new() { _LengthUnits1 = Length.Units.Decim |
| | 806 | | /// <summary>Units of an length measurement.</summary> |
| | 807 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Feet = new() { _LengthUnits1 = Length.Units.Feet }; |
| | 808 | | /// <summary>Units of an length measurement.</summary> |
| | 809 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Yards = new() { _LengthUnits1 = Length.Units.Yards }; |
| | 810 | | /// <summary>Units of an length measurement.</summary> |
| | 811 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Meters = new() { _LengthUnits1 = Length.Units.Meters }; |
| | 812 | | /// <summary>Units of an length measurement.</summary> |
| | 813 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Dekameters = new() { _LengthUnits1 = Length.Units.Dekam |
| | 814 | | /// <summary>Units of an length measurement.</summary> |
| | 815 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Hectometers = new() { _LengthUnits1 = Length.Units.Hect |
| | 816 | | /// <summary>Units of an length measurement.</summary> |
| | 817 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Kilometers = new() { _LengthUnits1 = Length.Units.Kilom |
| | 818 | | /// <summary>Units of an length measurement.</summary> |
| | 819 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Miles = new() { _LengthUnits1 = Length.Units.Miles }; |
| | 820 | | /// <summary>Units of an length measurement.</summary> |
| | 821 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits NauticalMiles = new() { _LengthUnits1 = Length.Units.Na |
| | 822 | | /// <summary>Units of an length measurement.</summary> |
| | 823 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Megameters = new() { _LengthUnits1 = Length.Units.Megam |
| | 824 | | /// <summary>Units of an length measurement.</summary> |
| | 825 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Gigameters = new() { _LengthUnits1 = Length.Units.Gigam |
| | 826 | | /// <summary>Units of an length measurement.</summary> |
| | 827 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Terameters = new() { _LengthUnits1 = Length.Units.Teram |
| | 828 | | /// <summary>Units of an length measurement.</summary> |
| | 829 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Petameters = new() { _LengthUnits1 = Length.Units.Petam |
| | 830 | | /// <summary>Units of an length measurement.</summary> |
| | 831 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Exameters = new() { _LengthUnits1 = Length.Units.Examet |
| | 832 | | /// <summary>Units of an length measurement.</summary> |
| | 833 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Zettameters = new() { _LengthUnits1 = Length.Units.Zett |
| | 834 | | /// <summary>Units of an length measurement.</summary> |
| | 835 | | public static readonly MeasurementUnitsSyntaxTypes.LengthUnits Yottameters = new() { _LengthUnits1 = Length.Units.Yott |
| | 836 | |
|
| | 837 | | #endregion |
| | 838 | |
|
| | 839 | | #region Mass Units |
| | 840 | |
|
| | 841 | | /// <summary>Units of an mass measurement.</summary> |
| | 842 | | public static readonly MeasurementUnitsSyntaxTypes.MassUnits Yoctograms = new() { _MassUnits1 = Mass.Units.Yoctograms |
| | 843 | | /// <summary>Units of an mass measurement.</summary> |
| | 844 | | public static readonly MeasurementUnitsSyntaxTypes.MassUnits Zeptograms = new() { _MassUnits1 = Mass.Units.Zeptograms |
| | 845 | | /// <summary>Units of an mass measurement.</summary> |
| | 846 | | public static readonly MeasurementUnitsSyntaxTypes.MassUnits Attograms = new() { _MassUnits1 = Mass.Units.Attograms }; |
| | 847 | | /// <summary>Units of an mass measurement.</summary> |
| | 848 | | public static readonly MeasurementUnitsSyntaxTypes.MassUnits Femtograms = new() { _MassUnits1 = Mass.Units.Femtograms |
| | 849 | | /// <summary>Units of an mass measurement.</summary> |
| | 850 | | public static readonly MeasurementUnitsSyntaxTypes.MassUnits Picograms = new() { _MassUnits1 = Mass.Units.Picograms }; |
| | 851 | | /// <summary>Units of an mass measurement.</summary> |
| | 852 | | public static readonly MeasurementUnitsSyntaxTypes.MassUnits Nanograms = new() { _MassUnits1 = Mass.Units.Nanograms }; |
| | 853 | | /// <summary>Units of an mass measurement.</summary> |
| | 854 | | public static readonly MeasurementUnitsSyntaxTypes.MassUnits Micrograms = new() { _MassUnits1 = Mass.Units.Micrograms |
| | 855 | | /// <summary>Units of an mass measurement.</summary> |
| | 856 | | public static readonly MeasurementUnitsSyntaxTypes.MassUnits Milligrams = new() { _MassUnits1 = Mass.Units.Milligrams |
| | 857 | | /// <summary>Units of an mass measurement.</summary> |
| | 858 | | public static readonly MeasurementUnitsSyntaxTypes.MassUnits Centigrams = new() { _MassUnits1 = Mass.Units.Centigrams |
| | 859 | | /// <summary>Units of an mass measurement.</summary> |
| | 860 | | public static readonly MeasurementUnitsSyntaxTypes.MassUnits Decigrams = new() { _MassUnits1 = Mass.Units.Decigrams }; |
| | 861 | | /// <summary>Units of an mass measurement.</summary> |
| | 862 | | public static readonly MeasurementUnitsSyntaxTypes.MassUnits Grams = new() { _MassUnits1 = Mass.Units.Grams }; |
| | 863 | | /// <summary>Units of an mass measurement.</summary> |
| | 864 | | public static readonly MeasurementUnitsSyntaxTypes.MassUnits Dekagrams = new() { _MassUnits1 = Mass.Units.Dekagrams }; |
| | 865 | | /// <summary>Units of an mass measurement.</summary> |
| | 866 | | public static readonly MeasurementUnitsSyntaxTypes.MassUnits Hectograms = new() { _MassUnits1 = Mass.Units.Hectograms |
| | 867 | | /// <summary>Units of an mass measurement.</summary> |
| | 868 | | public static readonly MeasurementUnitsSyntaxTypes.MassUnits Kilograms = new() { _MassUnits1 = Mass.Units.Kilograms }; |
| | 869 | | /// <summary>Units of an mass measurement.</summary> |
| | 870 | | public static readonly MeasurementUnitsSyntaxTypes.MassUnits Megagrams = new() { _MassUnits1 = Mass.Units.Megagrams }; |
| | 871 | | /// <summary>Units of an mass measurement.</summary> |
| | 872 | | public static readonly MeasurementUnitsSyntaxTypes.MassUnits Gigagrams = new() { _MassUnits1 = Mass.Units.Gigagrams }; |
| | 873 | | /// <summary>Units of an mass measurement.</summary> |
| | 874 | | public static readonly MeasurementUnitsSyntaxTypes.MassUnits Teragrams = new() { _MassUnits1 = Mass.Units.Teragrams }; |
| | 875 | | /// <summary>Units of an mass measurement.</summary> |
| | 876 | | public static readonly MeasurementUnitsSyntaxTypes.MassUnits Petagrams = new() { _MassUnits1 = Mass.Units.Petagrams }; |
| | 877 | | /// <summary>Units of an mass measurement.</summary> |
| | 878 | | public static readonly MeasurementUnitsSyntaxTypes.MassUnits Exagrams = new() { _MassUnits1 = Mass.Units.Exagrams }; |
| | 879 | | /// <summary>Units of an mass measurement.</summary> |
| | 880 | | public static readonly MeasurementUnitsSyntaxTypes.MassUnits Zettagrams = new() { _MassUnits1 = Mass.Units.Zettagrams |
| | 881 | | /// <summary>Units of an mass measurement.</summary> |
| | 882 | | public static readonly MeasurementUnitsSyntaxTypes.MassUnits Yottagrams = new() { _MassUnits1 = Mass.Units.Yottagrams |
| | 883 | |
|
| | 884 | | #endregion |
| | 885 | |
|
| | 886 | | #region Power Units |
| | 887 | |
|
| | 888 | | /// <summary>Units of an Power measurement.</summary> |
| | 889 | | public static readonly MeasurementUnitsSyntaxTypes.PowerBaseUnits Watts = new() { _MassUnits1 = Mass.Units.Kilograms, |
| | 890 | |
|
| | 891 | | #endregion |
| | 892 | |
|
| | 893 | | #region Pressure Units |
| | 894 | |
|
| | 895 | | /// <summary>Units of an Pressure measurement.</summary> |
| | 896 | | public static readonly MeasurementUnitsSyntaxTypes.PressureBaseUnits Pascals = new() { _MassUnits1 = Mass.Units.Kilogr |
| | 897 | |
|
| | 898 | | #endregion |
| | 899 | |
|
| | 900 | | #region Speed Units |
| | 901 | |
|
| | 902 | | /// <summary>Units of an speed measurement.</summary> |
| | 903 | | public static readonly MeasurementUnitsSyntaxTypes.SpeedBaseUnits Knots = new() { _LengthUnits1 = Length.Units.Nautica |
| | 904 | |
|
| | 905 | | #endregion |
| | 906 | |
|
| | 907 | | #region Time Units |
| | 908 | |
|
| | 909 | | /// <summary>Units of an time measurement.</summary> |
| | 910 | | public static readonly MeasurementUnitsSyntaxTypes.TimeUnits Milliseconds = new() { _TimeUnits1 = Time.Units.Milliseco |
| | 911 | | /// <summary>Units of an time measurement.</summary> |
| | 912 | | public static readonly MeasurementUnitsSyntaxTypes.TimeUnits Seconds = new() { _TimeUnits1 = Time.Units.Seconds }; |
| | 913 | | /// <summary>Units of an time measurement.</summary> |
| | 914 | | public static readonly MeasurementUnitsSyntaxTypes.TimeUnits Minutes = new() { _TimeUnits1 = Time.Units.Minutes }; |
| | 915 | | /// <summary>Units of an time measurement.</summary> |
| | 916 | | public static readonly MeasurementUnitsSyntaxTypes.TimeUnits Hours = new() { _TimeUnits1 = Time.Units.Hours }; |
| | 917 | | /// <summary>Units of an time measurement.</summary> |
| | 918 | | public static readonly MeasurementUnitsSyntaxTypes.TimeUnits Days = new() { _TimeUnits1 = Time.Units.Days }; |
| | 919 | |
|
| | 920 | | #endregion |
| | 921 | | } |
| | 922 | |
|
| | 923 | | #endregion |