| | 1 | | //------------------------------------------------------------------------------ |
| | 2 | | // <auto-generated> |
| | 3 | | // This code was generated from the "MeasurementTypes.tt" T4 Text Template. |
| | 4 | | // </auto-generated> |
| | 5 | | //------------------------------------------------------------------------------ |
| | 6 | |
|
| | 7 | | // Measurement Definitions: |
| | 8 | | // |
| | 9 | | // Acceleration: Length/Time/Time |
| | 10 | | // AngularAcceleration: Angle/Time/Time |
| | 11 | | // Angle: Angle |
| | 12 | | // AngularSpeed: Angle/Time |
| | 13 | | // Area: Length*Length |
| | 14 | | // AreaDensity: Mass/Length/Length |
| | 15 | | // Density: Mass/Length/Length/Length |
| | 16 | | // ElectricCharge: ElectricCharge |
| | 17 | | // ElectricCurrent: ElectricCharge/Time |
| | 18 | | // Energy: Mass*Length*Length/Time/Time |
| | 19 | | // Force: Mass*Length/Time/Time |
| | 20 | | // Length: Length |
| | 21 | | // LinearDensity: Mass/Length |
| | 22 | | // LinearMass: Mass*Length |
| | 23 | | // LinearMassFlow: Mass*Length/Time |
| | 24 | | // Mass: Mass |
| | 25 | | // MassRate: Mass/Time |
| | 26 | | // Power: Mass*Length*Length/Time/Time/Time |
| | 27 | | // Pressure: Mass/Length/Time/Time |
| | 28 | | // Speed: Length/Time |
| | 29 | | // Tempurature: Tempurature |
| | 30 | | // Time: Time |
| | 31 | | // TimeArea: Time*Time |
| | 32 | | // Volume: Length*Length*Length |
| | 33 | | // VolumeRate: Length*Length*Length/Time |
| | 34 | |
|
| | 35 | | #region Operators |
| | 36 | |
|
| | 37 | | // Operators: |
| | 38 | | // |
| | 39 | | // Acceleration * AreaDensity = Pressure |
| | 40 | | // Acceleration * LinearMass = Energy |
| | 41 | | // Acceleration * LinearMassFlow = Power |
| | 42 | | // Acceleration * Mass = Force |
| | 43 | | // Acceleration * Time = Speed |
| | 44 | | // Acceleration * TimeArea = Length |
| | 45 | | // AngularAcceleration * Time = AngularSpeed |
| | 46 | | // AngularAcceleration * TimeArea = Angle |
| | 47 | | // AngularSpeed * Time = Angle |
| | 48 | | // Area * AreaDensity = Mass |
| | 49 | | // Area * Density = LinearDensity |
| | 50 | | // Area * Length = Volume |
| | 51 | | // Area * LinearDensity = LinearMass |
| | 52 | | // Area * Pressure = Force |
| | 53 | | // Area * Speed = VolumeRate |
| | 54 | | // AreaDensity * Acceleration = Pressure |
| | 55 | | // AreaDensity * Area = Mass |
| | 56 | | // AreaDensity * Length = LinearDensity |
| | 57 | | // AreaDensity * Volume = LinearMass |
| | 58 | | // AreaDensity * VolumeRate = LinearMassFlow |
| | 59 | | // Density * Area = LinearDensity |
| | 60 | | // Density * Length = AreaDensity |
| | 61 | | // Density * Volume = Mass |
| | 62 | | // Density * VolumeRate = MassRate |
| | 63 | | // ElectricCurrent * Time = ElectricCharge |
| | 64 | | // Force * Length = Energy |
| | 65 | | // Force * Speed = Power |
| | 66 | | // Force * Time = LinearMassFlow |
| | 67 | | // Force * TimeArea = LinearMass |
| | 68 | | // Length * Area = Volume |
| | 69 | | // Length * AreaDensity = LinearDensity |
| | 70 | | // Length * Density = AreaDensity |
| | 71 | | // Length * Force = Energy |
| | 72 | | // Length * Length = Area |
| | 73 | | // Length * LinearDensity = Mass |
| | 74 | | // Length * Mass = LinearMass |
| | 75 | | // Length * MassRate = LinearMassFlow |
| | 76 | | // LinearDensity * Area = LinearMass |
| | 77 | | // LinearDensity * Length = Mass |
| | 78 | | // LinearDensity * Speed = MassRate |
| | 79 | | // LinearMass * Acceleration = Energy |
| | 80 | | // LinearMassFlow * Acceleration = Power |
| | 81 | | // LinearMassFlow * Speed = Energy |
| | 82 | | // LinearMassFlow * Time = LinearMass |
| | 83 | | // Mass * Acceleration = Force |
| | 84 | | // Mass * Length = LinearMass |
| | 85 | | // Mass * Speed = LinearMassFlow |
| | 86 | | // MassRate * Length = LinearMassFlow |
| | 87 | | // MassRate * Speed = Force |
| | 88 | | // MassRate * Time = Mass |
| | 89 | | // Power * Time = Energy |
| | 90 | | // Pressure * Area = Force |
| | 91 | | // Pressure * TimeArea = LinearDensity |
| | 92 | | // Pressure * Volume = Energy |
| | 93 | | // Pressure * VolumeRate = Power |
| | 94 | | // Speed * Area = VolumeRate |
| | 95 | | // Speed * Force = Power |
| | 96 | | // Speed * LinearDensity = MassRate |
| | 97 | | // Speed * LinearMassFlow = Energy |
| | 98 | | // Speed * Mass = LinearMassFlow |
| | 99 | | // Speed * MassRate = Force |
| | 100 | | // Speed * Time = Length |
| | 101 | | // Time * Acceleration = Speed |
| | 102 | | // Time * AngularAcceleration = AngularSpeed |
| | 103 | | // Time * AngularSpeed = Angle |
| | 104 | | // Time * ElectricCurrent = ElectricCharge |
| | 105 | | // Time * Force = LinearMassFlow |
| | 106 | | // Time * LinearMassFlow = LinearMass |
| | 107 | | // Time * MassRate = Mass |
| | 108 | | // Time * Power = Energy |
| | 109 | | // Time * Speed = Length |
| | 110 | | // Time * Time = TimeArea |
| | 111 | | // Time * VolumeRate = Volume |
| | 112 | | // TimeArea * Acceleration = Length |
| | 113 | | // TimeArea * AngularAcceleration = Angle |
| | 114 | | // TimeArea * Force = LinearMass |
| | 115 | | // TimeArea * Pressure = LinearDensity |
| | 116 | | // Volume * AreaDensity = LinearMass |
| | 117 | | // Volume * Density = Mass |
| | 118 | | // Volume * Pressure = Energy |
| | 119 | | // VolumeRate * AreaDensity = LinearMassFlow |
| | 120 | | // VolumeRate * Density = MassRate |
| | 121 | | // VolumeRate * Pressure = Power |
| | 122 | | // VolumeRate * Time = Volume |
| | 123 | | // Angle / AngularAcceleration = TimeArea |
| | 124 | | // Angle / AngularSpeed = Time |
| | 125 | | // Angle / Time = AngularSpeed |
| | 126 | | // Angle / TimeArea = AngularAcceleration |
| | 127 | | // AngularSpeed / AngularAcceleration = Time |
| | 128 | | // AngularSpeed / Time = AngularAcceleration |
| | 129 | | // Area / Length = Length |
| | 130 | | // AreaDensity / Density = Length |
| | 131 | | // AreaDensity / Length = Density |
| | 132 | | // ElectricCharge / ElectricCurrent = Time |
| | 133 | | // ElectricCharge / Time = ElectricCurrent |
| | 134 | | // Energy / Acceleration = LinearMass |
| | 135 | | // Energy / Force = Length |
| | 136 | | // Energy / Length = Force |
| | 137 | | // Energy / LinearMass = Acceleration |
| | 138 | | // Energy / LinearMassFlow = Speed |
| | 139 | | // Energy / Power = Time |
| | 140 | | // Energy / Pressure = Volume |
| | 141 | | // Energy / Speed = LinearMassFlow |
| | 142 | | // Energy / Time = Power |
| | 143 | | // Energy / Volume = Pressure |
| | 144 | | // Force / Acceleration = Mass |
| | 145 | | // Force / Area = Pressure |
| | 146 | | // Force / Mass = Acceleration |
| | 147 | | // Force / MassRate = Speed |
| | 148 | | // Force / Pressure = Area |
| | 149 | | // Force / Speed = MassRate |
| | 150 | | // Length / Acceleration = TimeArea |
| | 151 | | // Length / Speed = Time |
| | 152 | | // Length / Time = Speed |
| | 153 | | // Length / TimeArea = Acceleration |
| | 154 | | // LinearDensity / Area = Density |
| | 155 | | // LinearDensity / AreaDensity = Length |
| | 156 | | // LinearDensity / Density = Area |
| | 157 | | // LinearDensity / Length = AreaDensity |
| | 158 | | // LinearDensity / Pressure = TimeArea |
| | 159 | | // LinearDensity / TimeArea = Pressure |
| | 160 | | // LinearMass / Area = LinearDensity |
| | 161 | | // LinearMass / AreaDensity = Volume |
| | 162 | | // LinearMass / Force = TimeArea |
| | 163 | | // LinearMass / Length = Mass |
| | 164 | | // LinearMass / LinearDensity = Area |
| | 165 | | // LinearMass / LinearMassFlow = Time |
| | 166 | | // LinearMass / Mass = Length |
| | 167 | | // LinearMass / Time = LinearMassFlow |
| | 168 | | // LinearMass / TimeArea = Force |
| | 169 | | // LinearMass / Volume = AreaDensity |
| | 170 | | // LinearMassFlow / AreaDensity = VolumeRate |
| | 171 | | // LinearMassFlow / Force = Time |
| | 172 | | // LinearMassFlow / Length = MassRate |
| | 173 | | // LinearMassFlow / Mass = Speed |
| | 174 | | // LinearMassFlow / MassRate = Length |
| | 175 | | // LinearMassFlow / Speed = Mass |
| | 176 | | // LinearMassFlow / Time = Force |
| | 177 | | // LinearMassFlow / VolumeRate = AreaDensity |
| | 178 | | // Mass / Area = AreaDensity |
| | 179 | | // Mass / AreaDensity = Area |
| | 180 | | // Mass / Density = Volume |
| | 181 | | // Mass / Length = LinearDensity |
| | 182 | | // Mass / LinearDensity = Length |
| | 183 | | // Mass / MassRate = Time |
| | 184 | | // Mass / Time = MassRate |
| | 185 | | // Mass / Volume = Density |
| | 186 | | // MassRate / Density = VolumeRate |
| | 187 | | // MassRate / LinearDensity = Speed |
| | 188 | | // MassRate / Speed = LinearDensity |
| | 189 | | // MassRate / VolumeRate = Density |
| | 190 | | // Power / Acceleration = LinearMassFlow |
| | 191 | | // Power / Force = Speed |
| | 192 | | // Power / LinearMassFlow = Acceleration |
| | 193 | | // Power / Pressure = VolumeRate |
| | 194 | | // Power / Speed = Force |
| | 195 | | // Power / VolumeRate = Pressure |
| | 196 | | // Pressure / Acceleration = AreaDensity |
| | 197 | | // Pressure / AreaDensity = Acceleration |
| | 198 | | // Speed / Acceleration = Time |
| | 199 | | // Speed / Time = Acceleration |
| | 200 | | // TimeArea / Time = Time |
| | 201 | | // Volume / Area = Length |
| | 202 | | // Volume / Length = Area |
| | 203 | | // Volume / Time = VolumeRate |
| | 204 | | // Volume / VolumeRate = Time |
| | 205 | | // VolumeRate / Area = Speed |
| | 206 | | // VolumeRate / Speed = Area |
| | 207 | |
|
| | 208 | | #endregion |
| | 209 | |
|
| | 210 | | using System; |
| | 211 | | using static Towel.Statics; |
| | 212 | |
|
| | 213 | | namespace Towel.Measurements |
| | 214 | | { |
| | 215 | | #region Acceleration |
| | 216 | |
|
| | 217 | | internal static partial class ParsingFunctions |
| | 218 | | { |
| | 219 | | [Measurement.Parseable("Length/Time/Time")] |
| | 220 | | public static object Acceleration<T>(T value, object[] units) |
| | 221 | | { |
| | 222 | | if (units.Length != 3) |
| | 223 | | { |
| | 224 | | throw new Exception("Bug in Towel. Invalid parameters to Acceleration Factory."); |
| | 225 | | } |
| | 226 | | if (!(units[0] is Length.Units)) |
| | 227 | | { |
| | 228 | | throw new Exception("Bug in Towel. Invalid parameters to Acceleration Factory."); |
| | 229 | | } |
| | 230 | | if (!(units[1] is Time.Units)) |
| | 231 | | { |
| | 232 | | throw new Exception("Bug in Towel. Invalid parameters to Acceleration Factory."); |
| | 233 | | } |
| | 234 | | if (!(units[2] is Time.Units)) |
| | 235 | | { |
| | 236 | | throw new Exception("Bug in Towel. Invalid parameters to Acceleration Factory."); |
| | 237 | | } |
| | 238 | | return new Acceleration<T>(value |
| | 239 | | , (Length.Units)units[0] |
| | 240 | | , (Time.Units)units[1] |
| | 241 | | , (Time.Units)units[2] |
| | 242 | | ); |
| | 243 | | } |
| | 244 | | } |
| | 245 | |
|
| | 246 | | /// <summary>Acceleration measurement with a value and the units.</summary> |
| | 247 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 248 | | public struct Acceleration<T> |
| | 249 | | { |
| | 250 | | internal T _measurement; |
| | 251 | | internal Length.Units _LengthUnits1; |
| | 252 | | internal Time.Units _TimeUnits2; |
| | 253 | | internal Time.Units _TimeUnits3; |
| | 254 | |
|
| | 255 | | #region Statics |
| | 256 | |
|
| | 257 | | /// <summary>Converts a Acceleration measurement from units to another.</summary> |
| | 258 | | /// <param name="value">The value to convert the units of.</param> |
| | 259 | | /// <param name="fromLengthUnits1">The current units of the measurement.</param> |
| | 260 | | /// <param name="fromTimeUnits2">The current units of the measurement.</param> |
| | 261 | | /// <param name="fromTimeUnits3">The current units of the measurement.</param> |
| | 262 | | /// <param name="toLengthUnits1">The desired units of the measurement.</param> |
| | 263 | | /// <param name="toTimeUnits2">The desired units of the measurement.</param> |
| | 264 | | /// <param name="toTimeUnits3">The desired units of the measurement.</param> |
| | 265 | | /// <returns>The Acceleration measurement converted into the desired units.</returns> |
| | 266 | | public static T Convert(T value |
| | 267 | | , Length.Units fromLengthUnits1 |
| | 268 | | , Time.Units fromTimeUnits2 |
| | 269 | | , Time.Units fromTimeUnits3 |
| | 270 | | , Length.Units toLengthUnits1 |
| | 271 | | , Time.Units toTimeUnits2 |
| | 272 | | , Time.Units toTimeUnits3 |
| | 273 | | ) |
| | 274 | | { |
| | 275 | | Acceleration<T> measurement = new Acceleration<T>(value |
| | 276 | | , fromLengthUnits1 |
| | 277 | | , fromTimeUnits2 |
| | 278 | | , fromTimeUnits3 |
| | 279 | | ); |
| | 280 | | return measurement[ |
| | 281 | | toLengthUnits1 |
| | 282 | | , toTimeUnits2 |
| | 283 | | , toTimeUnits3 |
| | 284 | | ]; |
| | 285 | | } |
| | 286 | |
|
| | 287 | | /// <summary>Converts a Acceleration measurement from units to another.</summary> |
| | 288 | | /// <param name="value">The value to convert the units of.</param> |
| | 289 | | /// <param name="from">The current units of the measurement.</param> |
| | 290 | | /// <param name="to">The desired units of the measurement.</param> |
| | 291 | | /// <returns>The Acceleration measurement converted into the desired units.</returns> |
| | 292 | | public static T Convert(T value, |
| | 293 | | MeasurementUnitsSyntaxTypes.AccelerationBaseUnits from, |
| | 294 | | MeasurementUnitsSyntaxTypes.AccelerationBaseUnits to) |
| | 295 | | { |
| | 296 | | return Convert(value |
| | 297 | | , from._LengthUnits1 |
| | 298 | | , from._TimeUnits2 |
| | 299 | | , from._TimeUnits3 |
| | 300 | | , to._LengthUnits1 |
| | 301 | | , to._TimeUnits2 |
| | 302 | | , to._TimeUnits3 |
| | 303 | | ); |
| | 304 | | } |
| | 305 | |
|
| | 306 | | /// <summary>Parses a Acceleration measurement string.</summary> |
| | 307 | | /// <param name="string">The string to be parsed.</param> |
| | 308 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 309 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 310 | | public static (bool Success, Acceleration<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value)> |
| | 311 | |
|
| | 312 | | #endregion |
| | 313 | |
|
| | 314 | | #region Constructors |
| | 315 | |
|
| | 316 | | /// <summary>Constructs an Acceleration with the measurement value and units.</summary> |
| | 317 | | /// <param name="measurement">The measurement value of the Acceleration.</param> |
| | 318 | | /// <param name="units">The units of the Acceleration.</param> |
| | 319 | | public Acceleration(T measurement, MeasurementUnitsSyntaxTypes.AccelerationBaseUnits units) : this(measurement |
| | 320 | | , units._LengthUnits1 |
| | 321 | | , units._TimeUnits2 |
| | 322 | | , units._TimeUnits3 |
| | 323 | | ) { } |
| | 324 | |
|
| | 325 | |
|
| | 326 | | /// <summary>Constructs an Acceleration with the measurement value and units.</summary> |
| | 327 | | /// <param name="measurement">The measurement value of the Acceleration.</param> |
| | 328 | | /// <param name="LengthUnits1">The units of the Acceleration.</param> |
| | 329 | | /// <param name="TimeUnits2">The units of the Acceleration.</param> |
| | 330 | | /// <param name="TimeUnits3">The units of the Acceleration.</param> |
| | 331 | | public Acceleration(T measurement |
| | 332 | | , Length.Units LengthUnits1 |
| | 333 | | , Time.Units TimeUnits2 |
| | 334 | | , Time.Units TimeUnits3 |
| | 335 | | ) |
| | 336 | | { |
| | 337 | | _measurement = measurement; |
| | 338 | | _LengthUnits1 = LengthUnits1; |
| | 339 | | _TimeUnits2 = TimeUnits2; |
| | 340 | | _TimeUnits3 = TimeUnits3; |
| | 341 | | } |
| | 342 | |
|
| | 343 | | #endregion |
| | 344 | |
|
| | 345 | | #region Properties |
| | 346 | |
|
| | 347 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 348 | | public Length.Units LengthUnits1 |
| | 349 | | { |
| | 350 | | get { return _LengthUnits1; } |
| | 351 | | set |
| | 352 | | { |
| | 353 | | if (value != _LengthUnits1) |
| | 354 | | { |
| | 355 | | _measurement = this[value, _TimeUnits2, _TimeUnits3]; |
| | 356 | | _LengthUnits1 = value; |
| | 357 | | } |
| | 358 | | } |
| | 359 | | } |
| | 360 | |
|
| | 361 | | /// <summary>The #2 component of this measurements units.</summary> |
| | 362 | | public Time.Units TimeUnits2 |
| | 363 | | { |
| | 364 | | get { return _TimeUnits2; } |
| | 365 | | set |
| | 366 | | { |
| | 367 | | if (value != _TimeUnits2) |
| | 368 | | { |
| | 369 | | _measurement = this[_LengthUnits1, value, _TimeUnits3]; |
| | 370 | | _TimeUnits2 = value; |
| | 371 | | } |
| | 372 | | } |
| | 373 | | } |
| | 374 | |
|
| | 375 | | /// <summary>The #3 component of this measurements units.</summary> |
| | 376 | | public Time.Units TimeUnits3 |
| | 377 | | { |
| | 378 | | get { return _TimeUnits3; } |
| | 379 | | set |
| | 380 | | { |
| | 381 | | if (value != _TimeUnits3) |
| | 382 | | { |
| | 383 | | _measurement = this[_LengthUnits1, _TimeUnits2, value]; |
| | 384 | | _TimeUnits3 = value; |
| | 385 | | } |
| | 386 | | } |
| | 387 | | } |
| | 388 | |
|
| | 389 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 390 | | /// <param name="units">The units to get the measurement in.</param> |
| | 391 | | /// <returns>The measurement value in the specified units.</returns> |
| | 392 | | public T this[MeasurementUnitsSyntaxTypes.AccelerationBaseUnits units] |
| | 393 | | { |
| | 394 | | get { return this[units._LengthUnits1, units._TimeUnits2, units._TimeUnits3]; } |
| | 395 | | } |
| | 396 | |
|
| | 397 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 398 | | /// <param name="LengthUnits1">The #1 component of this measurements units.</param> |
| | 399 | | /// <param name="TimeUnits2">The #2 component of this measurements units.</param> |
| | 400 | | /// <param name="TimeUnits3">The #3 component of this measurements units.</param> |
| | 401 | | /// <returns>The measurement value in the specified units.</returns> |
| | 402 | | public T this[Length.Units LengthUnits1, Time.Units TimeUnits2, Time.Units TimeUnits3] |
| | 403 | | { |
| | 404 | | get |
| | 405 | | { |
| | 406 | | T measurement = _measurement; |
| | 407 | | if (LengthUnits1 != _LengthUnits1) |
| | 408 | | { |
| | 409 | | measurement = Length<T>.Table[(int)_LengthUnits1][(int)LengthUnits1](measurement); |
| | 410 | | //if (LengthUnits1 < _LengthUnits1) |
| | 411 | | //{ |
| | 412 | | // measurement = Length<T>.Table[(int)_LengthUnits1][(int)LengthUnits1](measurement); |
| | 413 | | //} |
| | 414 | | //else |
| | 415 | | //{ |
| | 416 | | // measurement = Length<T>.Table[(int)LengthUnits1][(int)_LengthUnits1](measurement); |
| | 417 | | //} |
| | 418 | | } |
| | 419 | | if (TimeUnits2 != _TimeUnits2) |
| | 420 | | { |
| | 421 | | measurement = Time<T>.Table[(int)TimeUnits2][(int)_TimeUnits2](measurement); |
| | 422 | | //if (TimeUnits2 > _TimeUnits2) |
| | 423 | | //{ |
| | 424 | | // measurement = Time<T>.Table[(int)_TimeUnits2][(int)TimeUnits2](measurement); |
| | 425 | | //} |
| | 426 | | //else |
| | 427 | | //{ |
| | 428 | | // measurement = Time<T>.Table[(int)TimeUnits2][(int)_TimeUnits2](measurement); |
| | 429 | | //} |
| | 430 | | } |
| | 431 | | if (TimeUnits3 != _TimeUnits3) |
| | 432 | | { |
| | 433 | | measurement = Time<T>.Table[(int)TimeUnits3][(int)_TimeUnits3](measurement); |
| | 434 | | //if (TimeUnits3 > _TimeUnits3) |
| | 435 | | //{ |
| | 436 | | // measurement = Time<T>.Table[(int)_TimeUnits3][(int)TimeUnits3](measurement); |
| | 437 | | //} |
| | 438 | | //else |
| | 439 | | //{ |
| | 440 | | // measurement = Time<T>.Table[(int)TimeUnits3][(int)_TimeUnits3](measurement); |
| | 441 | | //} |
| | 442 | | } |
| | 443 | | return measurement; |
| | 444 | | } |
| | 445 | | } |
| | 446 | |
|
| | 447 | | #endregion |
| | 448 | |
|
| | 449 | | #region Casting Operators |
| | 450 | |
|
| | 451 | | /// <summary>Converts a ValueTuple to a Acceleration measurement.</summary> |
| | 452 | | /// <param name="valueTuple">The ValueTuple to converted into a Acceleration measurement.</param> |
| | 453 | | public static implicit operator Acceleration<T>((T, MeasurementUnitsSyntaxTypes.AccelerationBaseUnits) valueTuple) |
| | 454 | | { |
| | 455 | | return new Acceleration<T>(valueTuple.Item1, valueTuple.Item2); |
| | 456 | | } |
| | 457 | |
|
| | 458 | | #endregion |
| | 459 | |
|
| | 460 | | #region Mathematics |
| | 461 | |
|
| | 462 | | #region Bases |
| | 463 | |
|
| | 464 | | internal static Acceleration<T> MathBase(Acceleration<T> a, T b, Func<T, T, T> func) |
| | 465 | | { |
| | 466 | | return new Acceleration<T>(func(a._measurement, b) |
| | 467 | | , a._LengthUnits1 |
| | 468 | | , a._TimeUnits2 |
| | 469 | | , a._TimeUnits3 |
| | 470 | | ); |
| | 471 | | } |
| | 472 | |
|
| | 473 | | internal static Acceleration<T> MathBase(Acceleration<T> a, Acceleration<T> b, Func<T, T, T> func) |
| | 474 | | { |
| | 475 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 476 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 477 | | Time.Units TimeUnits3 = a._TimeUnits3 <= b._TimeUnits3 ? a._TimeUnits3 : b._TimeUnits3; |
| | 478 | | T A = a[LengthUnits1, TimeUnits2, TimeUnits3]; |
| | 479 | | T B = b[LengthUnits1, TimeUnits2, TimeUnits3]; |
| | 480 | | T C = func(A, B); |
| | 481 | | return new Acceleration<T>(C, LengthUnits1, TimeUnits2, TimeUnits3); |
| | 482 | | } |
| | 483 | |
|
| | 484 | | internal static bool LogicBase(Acceleration<T> a, Acceleration<T> b, Func<T, T, bool> func) |
| | 485 | | { |
| | 486 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 487 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 488 | | Time.Units TimeUnits3 = a._TimeUnits3 <= b._TimeUnits3 ? a._TimeUnits3 : b._TimeUnits3; |
| | 489 | | T A = a[LengthUnits1, TimeUnits2, TimeUnits3]; |
| | 490 | | T B = b[LengthUnits1, TimeUnits2, TimeUnits3]; |
| | 491 | | return func(A, B); |
| | 492 | | } |
| | 493 | |
|
| | 494 | | #endregion |
| | 495 | |
|
| | 496 | | #region Add |
| | 497 | |
|
| | 498 | | /// <summary>Adds two Acceleration measurements.</summary> |
| | 499 | | /// <param name="a">The first operand of the addition.</param> |
| | 500 | | /// <param name="b">The second operand of the addition.</param> |
| | 501 | | /// <returns>The result of the addition operation.</returns> |
| | 502 | | public static Acceleration<T> Add(Acceleration<T> a, Acceleration<T> b) |
| | 503 | | { |
| | 504 | | return MathBase(a, b, Statics.Addition); |
| | 505 | | } |
| | 506 | |
|
| | 507 | | /// <summary>Adds two Acceleration measurements.</summary> |
| | 508 | | /// <param name="a">The first operand of the addition.</param> |
| | 509 | | /// <param name="b">The second operand of the addition.</param> |
| | 510 | | /// <returns>The result of the addition operation.</returns> |
| | 511 | | public static Acceleration<T> operator +(Acceleration<T> a, Acceleration<T> b) |
| | 512 | | { |
| | 513 | | return Add(a, b); |
| | 514 | | } |
| | 515 | |
|
| | 516 | | /// <summary>Adds two Acceleration measurements.</summary> |
| | 517 | | /// <param name="b">The second operand of the addition.</param> |
| | 518 | | /// <returns>The result of the addition operation.</returns> |
| | 519 | | public Acceleration<T> Add(Acceleration<T> b) |
| | 520 | | { |
| | 521 | | return this + b; |
| | 522 | | } |
| | 523 | |
|
| | 524 | | #endregion |
| | 525 | |
|
| | 526 | | #region Subtract |
| | 527 | |
|
| | 528 | | /// <summary>Subtracts two Acceleration measurements.</summary> |
| | 529 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 530 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 531 | | /// <returns>The result of the subtraction.</returns> |
| | 532 | | public static Acceleration<T> Subtract(Acceleration<T> a, Acceleration<T> b) |
| | 533 | | { |
| | 534 | | return MathBase(a, b, Statics.Subtraction); |
| | 535 | | } |
| | 536 | |
|
| | 537 | | /// <summary>Subtracts two Acceleration measurements.</summary> |
| | 538 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 539 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 540 | | /// <returns>The result of the subtraction.</returns> |
| | 541 | | public static Acceleration<T> operator -(Acceleration<T> a, Acceleration<T> b) |
| | 542 | | { |
| | 543 | | return Subtract(a, b); |
| | 544 | | } |
| | 545 | |
|
| | 546 | | /// <summary>Subtracts two Acceleration measurements.</summary> |
| | 547 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 548 | | /// <returns>The result of the subtraction.</returns> |
| | 549 | | public Acceleration<T> Subtract(Acceleration<T> b) |
| | 550 | | { |
| | 551 | | return this - b; |
| | 552 | | } |
| | 553 | |
|
| | 554 | | #endregion |
| | 555 | |
|
| | 556 | | #region Multiply |
| | 557 | |
|
| | 558 | | /// <summary>Multiplies an Acceleration by a scalar numeric value.</summary> |
| | 559 | | /// <param name="a">The Acceleration measurement to multiply.</param> |
| | 560 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 561 | | /// <returns>The result of the multiplication.</returns> |
| | 562 | | public static Acceleration<T> Multiply(Acceleration<T> a, T b) |
| | 563 | | { |
| | 564 | | return MathBase(a, b, Statics.Multiplication); |
| | 565 | | } |
| | 566 | |
|
| | 567 | | /// <summary>Multiplies an Acceleration by a scalar numeric value.</summary> |
| | 568 | | /// <param name="a">The Acceleration measurement to multiply.</param> |
| | 569 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 570 | | /// <returns>The result of the multiplication.</returns> |
| | 571 | | public static Acceleration<T> Multiply(T b, Acceleration<T> a) |
| | 572 | | { |
| | 573 | | return Multiply(a, b); |
| | 574 | | } |
| | 575 | |
|
| | 576 | | /// <summary>Multiplies an Acceleration by a scalar numeric value.</summary> |
| | 577 | | /// <param name="a">The Acceleration measurement to multiply.</param> |
| | 578 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 579 | | /// <returns>The result of the multiplication.</returns> |
| | 580 | | public static Acceleration<T> operator *(Acceleration<T> a, T b) |
| | 581 | | { |
| | 582 | | return Multiply(a, b); |
| | 583 | | } |
| | 584 | |
|
| | 585 | | /// <summary>Multiplies an Acceleration by a scalar numeric value.</summary> |
| | 586 | | /// <param name="a">The Acceleration measurement to multiply.</param> |
| | 587 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 588 | | /// <returns>The result of the multiplication.</returns> |
| | 589 | | public static Acceleration<T> operator *(T b, Acceleration<T> a) |
| | 590 | | { |
| | 591 | | return Multiply(b, a); |
| | 592 | | } |
| | 593 | |
|
| | 594 | | /// <summary>Multiplies an Acceleration by a scalar numeric value.</summary> |
| | 595 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 596 | | /// <returns>The result of the multiplication.</returns> |
| | 597 | | public Acceleration<T> Add(T b) |
| | 598 | | { |
| | 599 | | return this * b; |
| | 600 | | } |
| | 601 | |
|
| | 602 | | #region Acceleration<T> * AreaDensity<T> = Pressure<T> |
| | 603 | |
|
| | 604 | | /// <summary>Mulitplies Acceleration by AreaDensity resulting in Pressure.</summary> |
| | 605 | | /// <param name="a">The Acceleration to be multiplied.</param> |
| | 606 | | /// <param name="b">The AreaDensity to multiply by.</param> |
| | 607 | | /// <returns>The Pressure result of the multiplication.</returns> |
| | 608 | | public static Pressure<T> Multiply(Acceleration<T> a, AreaDensity<T> b) |
| | 609 | | { |
| | 610 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits2 ? a._LengthUnits1 : b._LengthUnits2; |
| | 611 | |
|
| | 612 | | T A = a[LengthUnits1, a._TimeUnits2, a._TimeUnits3]; |
| | 613 | | T B = b[b._MassUnits1, LengthUnits1, b._LengthUnits3]; |
| | 614 | | T C = Statics.Multiplication(A, B); |
| | 615 | |
|
| | 616 | | return new Pressure<T>(C |
| | 617 | | , b._MassUnits1 |
| | 618 | | , b._LengthUnits3 |
| | 619 | | , a._TimeUnits2 |
| | 620 | | , a._TimeUnits3 |
| | 621 | | ); |
| | 622 | | } |
| | 623 | |
|
| | 624 | | /// <summary>Mulitplies Acceleration by AreaDensity resulting in Pressure.</summary> |
| | 625 | | /// <param name="a">The Acceleration to be multiplied.</param> |
| | 626 | | /// <param name="b">The AreaDensity to multiply by.</param> |
| | 627 | | /// <returns>The Pressure result of the multiplication.</returns> |
| | 628 | | public static Pressure<T> operator *(Acceleration<T> a, AreaDensity<T> b) |
| | 629 | | { |
| | 630 | | return Multiply(a, b); |
| | 631 | | } |
| | 632 | |
|
| | 633 | | /// <summary>Mulitplies Acceleration by AreaDensity resulting in Pressure.</summary> |
| | 634 | | /// <param name="b">The AreaDensity to multiply by.</param> |
| | 635 | | /// <returns>The Pressure result of the multiplication.</returns> |
| | 636 | | public Pressure<T> Multiply(AreaDensity<T> b) |
| | 637 | | { |
| | 638 | | return this * b; |
| | 639 | | } |
| | 640 | |
|
| | 641 | | #endregion |
| | 642 | |
|
| | 643 | | #region Acceleration<T> * LinearMass<T> = Energy<T> |
| | 644 | |
|
| | 645 | | /// <summary>Mulitplies Acceleration by LinearMass resulting in Energy.</summary> |
| | 646 | | /// <param name="a">The Acceleration to be multiplied.</param> |
| | 647 | | /// <param name="b">The LinearMass to multiply by.</param> |
| | 648 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 649 | | public static Energy<T> Multiply(Acceleration<T> a, LinearMass<T> b) |
| | 650 | | { |
| | 651 | |
|
| | 652 | | T A = a[a._LengthUnits1, a._TimeUnits2, a._TimeUnits3]; |
| | 653 | | T B = b[b._MassUnits1, b._LengthUnits2]; |
| | 654 | | T C = Statics.Multiplication(A, B); |
| | 655 | |
|
| | 656 | | return new Energy<T>(C |
| | 657 | | , b._MassUnits1 |
| | 658 | | , a._LengthUnits1 |
| | 659 | | , b._LengthUnits2 |
| | 660 | | , a._TimeUnits2 |
| | 661 | | , a._TimeUnits3 |
| | 662 | | ); |
| | 663 | | } |
| | 664 | |
|
| | 665 | | /// <summary>Mulitplies Acceleration by LinearMass resulting in Energy.</summary> |
| | 666 | | /// <param name="a">The Acceleration to be multiplied.</param> |
| | 667 | | /// <param name="b">The LinearMass to multiply by.</param> |
| | 668 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 669 | | public static Energy<T> operator *(Acceleration<T> a, LinearMass<T> b) |
| | 670 | | { |
| | 671 | | return Multiply(a, b); |
| | 672 | | } |
| | 673 | |
|
| | 674 | | /// <summary>Mulitplies Acceleration by LinearMass resulting in Energy.</summary> |
| | 675 | | /// <param name="b">The LinearMass to multiply by.</param> |
| | 676 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 677 | | public Energy<T> Multiply(LinearMass<T> b) |
| | 678 | | { |
| | 679 | | return this * b; |
| | 680 | | } |
| | 681 | |
|
| | 682 | | #endregion |
| | 683 | |
|
| | 684 | | #region Acceleration<T> * LinearMassFlow<T> = Power<T> |
| | 685 | |
|
| | 686 | | /// <summary>Mulitplies Acceleration by LinearMassFlow resulting in Power.</summary> |
| | 687 | | /// <param name="a">The Acceleration to be multiplied.</param> |
| | 688 | | /// <param name="b">The LinearMassFlow to multiply by.</param> |
| | 689 | | /// <returns>The Power result of the multiplication.</returns> |
| | 690 | | public static Power<T> Multiply(Acceleration<T> a, LinearMassFlow<T> b) |
| | 691 | | { |
| | 692 | |
|
| | 693 | | T A = a[a._LengthUnits1, a._TimeUnits2, a._TimeUnits3]; |
| | 694 | | T B = b[b._MassUnits1, b._LengthUnits2, b._TimeUnits3]; |
| | 695 | | T C = Statics.Multiplication(A, B); |
| | 696 | |
|
| | 697 | | return new Power<T>(C |
| | 698 | | , b._MassUnits1 |
| | 699 | | , a._LengthUnits1 |
| | 700 | | , b._LengthUnits2 |
| | 701 | | , a._TimeUnits2 |
| | 702 | | , a._TimeUnits3 |
| | 703 | | , b._TimeUnits3 |
| | 704 | | ); |
| | 705 | | } |
| | 706 | |
|
| | 707 | | /// <summary>Mulitplies Acceleration by LinearMassFlow resulting in Power.</summary> |
| | 708 | | /// <param name="a">The Acceleration to be multiplied.</param> |
| | 709 | | /// <param name="b">The LinearMassFlow to multiply by.</param> |
| | 710 | | /// <returns>The Power result of the multiplication.</returns> |
| | 711 | | public static Power<T> operator *(Acceleration<T> a, LinearMassFlow<T> b) |
| | 712 | | { |
| | 713 | | return Multiply(a, b); |
| | 714 | | } |
| | 715 | |
|
| | 716 | | /// <summary>Mulitplies Acceleration by LinearMassFlow resulting in Power.</summary> |
| | 717 | | /// <param name="b">The LinearMassFlow to multiply by.</param> |
| | 718 | | /// <returns>The Power result of the multiplication.</returns> |
| | 719 | | public Power<T> Multiply(LinearMassFlow<T> b) |
| | 720 | | { |
| | 721 | | return this * b; |
| | 722 | | } |
| | 723 | |
|
| | 724 | | #endregion |
| | 725 | |
|
| | 726 | | #region Acceleration<T> * Mass<T> = Force<T> |
| | 727 | |
|
| | 728 | | /// <summary>Mulitplies Acceleration by Mass resulting in Force.</summary> |
| | 729 | | /// <param name="a">The Acceleration to be multiplied.</param> |
| | 730 | | /// <param name="b">The Mass to multiply by.</param> |
| | 731 | | /// <returns>The Force result of the multiplication.</returns> |
| | 732 | | public static Force<T> Multiply(Acceleration<T> a, Mass<T> b) |
| | 733 | | { |
| | 734 | |
|
| | 735 | | T A = a[a._LengthUnits1, a._TimeUnits2, a._TimeUnits3]; |
| | 736 | | T B = b[b._MassUnits1]; |
| | 737 | | T C = Statics.Multiplication(A, B); |
| | 738 | |
|
| | 739 | | return new Force<T>(C |
| | 740 | | , b._MassUnits1 |
| | 741 | | , a._LengthUnits1 |
| | 742 | | , a._TimeUnits2 |
| | 743 | | , a._TimeUnits3 |
| | 744 | | ); |
| | 745 | | } |
| | 746 | |
|
| | 747 | | /// <summary>Mulitplies Acceleration by Mass resulting in Force.</summary> |
| | 748 | | /// <param name="a">The Acceleration to be multiplied.</param> |
| | 749 | | /// <param name="b">The Mass to multiply by.</param> |
| | 750 | | /// <returns>The Force result of the multiplication.</returns> |
| | 751 | | public static Force<T> operator *(Acceleration<T> a, Mass<T> b) |
| | 752 | | { |
| | 753 | | return Multiply(a, b); |
| | 754 | | } |
| | 755 | |
|
| | 756 | | /// <summary>Mulitplies Acceleration by Mass resulting in Force.</summary> |
| | 757 | | /// <param name="b">The Mass to multiply by.</param> |
| | 758 | | /// <returns>The Force result of the multiplication.</returns> |
| | 759 | | public Force<T> Multiply(Mass<T> b) |
| | 760 | | { |
| | 761 | | return this * b; |
| | 762 | | } |
| | 763 | |
|
| | 764 | | #endregion |
| | 765 | |
|
| | 766 | | #region Acceleration<T> * Time<T> = Speed<T> |
| | 767 | |
|
| | 768 | | /// <summary>Mulitplies Acceleration by Time resulting in Speed.</summary> |
| | 769 | | /// <param name="a">The Acceleration to be multiplied.</param> |
| | 770 | | /// <param name="b">The Time to multiply by.</param> |
| | 771 | | /// <returns>The Speed result of the multiplication.</returns> |
| | 772 | | public static Speed<T> Multiply(Acceleration<T> a, Time<T> b) |
| | 773 | | { |
| | 774 | | Time.Units TimeUnits1 = a._TimeUnits2 <= b._TimeUnits1 ? a._TimeUnits2 : b._TimeUnits1; |
| | 775 | |
|
| | 776 | | T A = a[a._LengthUnits1, TimeUnits1, a._TimeUnits3]; |
| | 777 | | T B = b[TimeUnits1]; |
| | 778 | | T C = Statics.Multiplication(A, B); |
| | 779 | |
|
| | 780 | | return new Speed<T>(C |
| | 781 | | , a._LengthUnits1 |
| | 782 | | , a._TimeUnits3 |
| | 783 | | ); |
| | 784 | | } |
| | 785 | |
|
| | 786 | | /// <summary>Mulitplies Acceleration by Time resulting in Speed.</summary> |
| | 787 | | /// <param name="a">The Acceleration to be multiplied.</param> |
| | 788 | | /// <param name="b">The Time to multiply by.</param> |
| | 789 | | /// <returns>The Speed result of the multiplication.</returns> |
| | 790 | | public static Speed<T> operator *(Acceleration<T> a, Time<T> b) |
| | 791 | | { |
| | 792 | | return Multiply(a, b); |
| | 793 | | } |
| | 794 | |
|
| | 795 | | /// <summary>Mulitplies Acceleration by Time resulting in Speed.</summary> |
| | 796 | | /// <param name="b">The Time to multiply by.</param> |
| | 797 | | /// <returns>The Speed result of the multiplication.</returns> |
| | 798 | | public Speed<T> Multiply(Time<T> b) |
| | 799 | | { |
| | 800 | | return this * b; |
| | 801 | | } |
| | 802 | |
|
| | 803 | | #endregion |
| | 804 | |
|
| | 805 | | #region Acceleration<T> * TimeArea<T> = Length<T> |
| | 806 | |
|
| | 807 | | /// <summary>Mulitplies Acceleration by TimeArea resulting in Length.</summary> |
| | 808 | | /// <param name="a">The Acceleration to be multiplied.</param> |
| | 809 | | /// <param name="b">The TimeArea to multiply by.</param> |
| | 810 | | /// <returns>The Length result of the multiplication.</returns> |
| | 811 | | public static Length<T> Multiply(Acceleration<T> a, TimeArea<T> b) |
| | 812 | | { |
| | 813 | | Time.Units TimeUnits1 = a._TimeUnits2 <= b._TimeUnits1 ? a._TimeUnits2 : b._TimeUnits1; |
| | 814 | | Time.Units TimeUnits2 = a._TimeUnits3 <= b._TimeUnits2 ? a._TimeUnits3 : b._TimeUnits2; |
| | 815 | |
|
| | 816 | | T A = a[a._LengthUnits1, TimeUnits1, TimeUnits2]; |
| | 817 | | T B = b[TimeUnits1, TimeUnits2]; |
| | 818 | | T C = Statics.Multiplication(A, B); |
| | 819 | |
|
| | 820 | | return new Length<T>(C |
| | 821 | | , a._LengthUnits1 |
| | 822 | | ); |
| | 823 | | } |
| | 824 | |
|
| | 825 | | /// <summary>Mulitplies Acceleration by TimeArea resulting in Length.</summary> |
| | 826 | | /// <param name="a">The Acceleration to be multiplied.</param> |
| | 827 | | /// <param name="b">The TimeArea to multiply by.</param> |
| | 828 | | /// <returns>The Length result of the multiplication.</returns> |
| | 829 | | public static Length<T> operator *(Acceleration<T> a, TimeArea<T> b) |
| | 830 | | { |
| | 831 | | return Multiply(a, b); |
| | 832 | | } |
| | 833 | |
|
| | 834 | | /// <summary>Mulitplies Acceleration by TimeArea resulting in Length.</summary> |
| | 835 | | /// <param name="b">The TimeArea to multiply by.</param> |
| | 836 | | /// <returns>The Length result of the multiplication.</returns> |
| | 837 | | public Length<T> Multiply(TimeArea<T> b) |
| | 838 | | { |
| | 839 | | return this * b; |
| | 840 | | } |
| | 841 | |
|
| | 842 | | #endregion |
| | 843 | |
|
| | 844 | | #endregion |
| | 845 | |
|
| | 846 | | #region Divide |
| | 847 | |
|
| | 848 | | /// <summary>Divides an Acceleration measurement by another Acceleration measurement resulting in a scalar numeric v |
| | 849 | | /// <param name="a">The first operand of the division operation.</param> |
| | 850 | | /// <param name="b">The second operand of the division operation.</param> |
| | 851 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 852 | | public static T Divide(Acceleration<T> a, Acceleration<T> b) |
| | 853 | | { |
| | 854 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 855 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 856 | | Time.Units TimeUnits3 = a._TimeUnits3 <= b._TimeUnits3 ? a._TimeUnits3 : b._TimeUnits3; |
| | 857 | | T A = a[LengthUnits1, TimeUnits2, TimeUnits3]; |
| | 858 | | T B = b[LengthUnits1, TimeUnits2, TimeUnits3]; |
| | 859 | | return Statics.Division(A, B); |
| | 860 | | } |
| | 861 | |
|
| | 862 | | /// <summary>Divides this Acceleration measurement by a numaric scalar value.</summary> |
| | 863 | | /// <param name="a">The Acceleration measurement to divide.</param> |
| | 864 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 865 | | /// <returns>The result of the division.</returns> |
| | 866 | | public static Acceleration<T> Divide(Acceleration<T> a, T b) |
| | 867 | | { |
| | 868 | | return MathBase(a, b, Statics.Division); |
| | 869 | | } |
| | 870 | |
|
| | 871 | | /// <summary>Divides this Acceleration measurement by a numaric scalar value.</summary> |
| | 872 | | /// <param name="a">The Acceleration measurement to divide.</param> |
| | 873 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 874 | | /// <returns>The result of the division.</returns> |
| | 875 | | public static Acceleration<T> operator /(Acceleration<T> a, T b) |
| | 876 | | { |
| | 877 | | return Divide(a, b); |
| | 878 | | } |
| | 879 | |
|
| | 880 | | /// <summary>Divides this Acceleration measurement by a numaric scalar value.</summary> |
| | 881 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 882 | | /// <returns>The result of the division.</returns> |
| | 883 | | public Acceleration<T> Divide(T b) |
| | 884 | | { |
| | 885 | | return this / b; |
| | 886 | | } |
| | 887 | |
|
| | 888 | | /// <summary>Divides an Acceleration measurement by another Acceleration measurement resulting in a scalar numeric v |
| | 889 | | /// <param name="a">The first operand of the division operation.</param> |
| | 890 | | /// <param name="b">The second operand of the division operation.</param> |
| | 891 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 892 | | public static T operator /(Acceleration<T> a, Acceleration<T> b) |
| | 893 | | { |
| | 894 | | return Divide(a, b); |
| | 895 | | } |
| | 896 | |
|
| | 897 | | /// <summary>Divides an Acceleration measurement by another Acceleration measurement resulting in a scalar numeric v |
| | 898 | | /// <param name="b">The second operand of the division operation.</param> |
| | 899 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 900 | | public T Divide(Acceleration<T> b) |
| | 901 | | { |
| | 902 | | return this / b; |
| | 903 | | } |
| | 904 | |
|
| | 905 | | #endregion |
| | 906 | |
|
| | 907 | | #region LessThan |
| | 908 | |
|
| | 909 | | /// <summary>Determines if an Acceleration measurement is less than another Acceleration measurement.</summary> |
| | 910 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 911 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 912 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 913 | | public static bool LessThan(Acceleration<T> a, Acceleration<T> b) |
| | 914 | | { |
| | 915 | | return LogicBase(a, b, Statics.LessThan); |
| | 916 | | } |
| | 917 | |
|
| | 918 | | /// <summary>Determines if an Acceleration measurement is less than another Acceleration measurement.</summary> |
| | 919 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 920 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 921 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 922 | | public static bool operator <(Acceleration<T> a, Acceleration<T> b) |
| | 923 | | { |
| | 924 | | return LessThan(a, b); |
| | 925 | | } |
| | 926 | |
|
| | 927 | | /// <summary>Determines if an Acceleration measurement is less than another Acceleration measurement.</summary> |
| | 928 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 929 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 930 | | public bool LessThan(Acceleration<T> b) |
| | 931 | | { |
| | 932 | | return this < b; |
| | 933 | | } |
| | 934 | |
|
| | 935 | | #endregion |
| | 936 | |
|
| | 937 | | #region GreaterThan |
| | 938 | |
|
| | 939 | | /// <summary>Determines if an Acceleration measurement is greater than another Acceleration measurement.</summary> |
| | 940 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 941 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 942 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 943 | | public static bool GreaterThan(Acceleration<T> a, Acceleration<T> b) |
| | 944 | | { |
| | 945 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 946 | | } |
| | 947 | |
|
| | 948 | | /// <summary>Determines if an Acceleration measurement is greater than another Acceleration measurement.</summary> |
| | 949 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 950 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 951 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 952 | | public static bool operator >(Acceleration<T> a, Acceleration<T> b) |
| | 953 | | { |
| | 954 | | return GreaterThan(a, b); |
| | 955 | | } |
| | 956 | |
|
| | 957 | | /// <summary>Determines if an Acceleration measurement is greater than another Acceleration measurement.</summary> |
| | 958 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 959 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 960 | | public bool GreaterThan(Acceleration<T> b) |
| | 961 | | { |
| | 962 | | return this > b; |
| | 963 | | } |
| | 964 | |
|
| | 965 | | #endregion |
| | 966 | |
|
| | 967 | | #region LessThanOrEqual |
| | 968 | |
|
| | 969 | | /// <summary>Determines if an Acceleration measurement is less than or equal to another Acceleration measurement.</s |
| | 970 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 971 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 972 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 973 | | public static bool LessThanOrEqual(Acceleration<T> a, Acceleration<T> b) |
| | 974 | | { |
| | 975 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 976 | | } |
| | 977 | |
|
| | 978 | | /// <summary>Determines if an Acceleration measurement is less than or equal to another Acceleration measurement.</s |
| | 979 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 980 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 981 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 982 | | public static bool operator <=(Acceleration<T> a, Acceleration<T> b) |
| | 983 | | { |
| | 984 | | return LessThanOrEqual(a, b); |
| | 985 | | } |
| | 986 | |
|
| | 987 | | /// <summary>Determines if an Acceleration measurement is less than or equal to another Acceleration measurement.</s |
| | 988 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 989 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 990 | | public bool LessThanOrEqual(Acceleration<T> b) |
| | 991 | | { |
| | 992 | | return this <= b; |
| | 993 | | } |
| | 994 | |
|
| | 995 | | #endregion |
| | 996 | |
|
| | 997 | | #region GreaterThanOrEqual |
| | 998 | |
|
| | 999 | | /// <summary>Determines if an Acceleration measurement is greater than or equal to another Acceleration measurement. |
| | 1000 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 1001 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 1002 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 1003 | | public static bool GreaterThanOrEqual(Acceleration<T> a, Acceleration<T> b) |
| | 1004 | | { |
| | 1005 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 1006 | | } |
| | 1007 | |
|
| | 1008 | | /// <summary>Determines if an Acceleration measurement is greater than or equal to another Acceleration measurement. |
| | 1009 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 1010 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 1011 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 1012 | | public static bool operator >=(Acceleration<T> a, Acceleration<T> b) |
| | 1013 | | { |
| | 1014 | | return GreaterThanOrEqual(a, b); |
| | 1015 | | } |
| | 1016 | |
|
| | 1017 | | /// <summary>Determines if an Acceleration measurement is greater than or equal to another Acceleration measurement. |
| | 1018 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 1019 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 1020 | | public bool GreaterThanOrEqual(Acceleration<T> b) |
| | 1021 | | { |
| | 1022 | | return this >= b; |
| | 1023 | | } |
| | 1024 | |
|
| | 1025 | | #endregion |
| | 1026 | |
|
| | 1027 | | #region Equal |
| | 1028 | |
|
| | 1029 | | /// <summary>Determines if an Acceleration measurement is equal to another Acceleration measurement.</summary> |
| | 1030 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 1031 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 1032 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 1033 | | public static bool Equal(Acceleration<T> a, Acceleration<T> b) |
| | 1034 | | { |
| | 1035 | | return LogicBase(a, b, Statics.Equate); |
| | 1036 | | } |
| | 1037 | |
|
| | 1038 | | /// <summary>Determines if an Acceleration measurement is equal to another Acceleration measurement.</summary> |
| | 1039 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 1040 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 1041 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 1042 | | public static bool operator ==(Acceleration<T> a, Acceleration<T> b) |
| | 1043 | | { |
| | 1044 | | return Equal(a, b); |
| | 1045 | | } |
| | 1046 | |
|
| | 1047 | | /// <summary>Determines if an Acceleration measurement is equal to another Acceleration measurement.</summary> |
| | 1048 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 1049 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 1050 | | public bool Equal(Acceleration<T> b) |
| | 1051 | | { |
| | 1052 | | return this == b; |
| | 1053 | | } |
| | 1054 | |
|
| | 1055 | | #endregion |
| | 1056 | |
|
| | 1057 | | #region NotEqual |
| | 1058 | |
|
| | 1059 | | /// <summary>Determines if an Acceleration measurement is not equal to another Acceleration measurement.</summary> |
| | 1060 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 1061 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 1062 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 1063 | | public static bool NotEqual(Acceleration<T> a, Acceleration<T> b) |
| | 1064 | | { |
| | 1065 | | return LogicBase(a, b, Statics.Inequate); |
| | 1066 | | } |
| | 1067 | |
|
| | 1068 | | /// <summary>Determines if an Acceleration measurement is not equal to another Acceleration measurement.</summary> |
| | 1069 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 1070 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 1071 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 1072 | | public static bool operator !=(Acceleration<T> a, Acceleration<T> b) |
| | 1073 | | { |
| | 1074 | | return NotEqual(a, b); |
| | 1075 | | } |
| | 1076 | |
|
| | 1077 | | /// <summary>Determines if an Acceleration measurement is not equal to another Acceleration measurement.</summary> |
| | 1078 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 1079 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 1080 | | public bool NotEqual(Acceleration<T> b) |
| | 1081 | | { |
| | 1082 | | return this != b; |
| | 1083 | | } |
| | 1084 | |
|
| | 1085 | | #endregion |
| | 1086 | |
|
| | 1087 | | #endregion |
| | 1088 | |
|
| | 1089 | | #region Overrides |
| | 1090 | |
|
| | 1091 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 1092 | | /// <param name="obj">The object to check for equality with.</param> |
| | 1093 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 1094 | | public override bool Equals(object obj) |
| | 1095 | | { |
| | 1096 | | if (obj is Acceleration<T>) |
| | 1097 | | { |
| | 1098 | | return this == (Acceleration<T>)obj; |
| | 1099 | | } |
| | 1100 | | return false; |
| | 1101 | | } |
| | 1102 | |
|
| | 1103 | | /// <summary>Converts the Acceleration measurement to a string represenation.</summary> |
| | 1104 | | /// <returns>The string representation of the measurement.</returns> |
| | 1105 | | public override string ToString() |
| | 1106 | | { |
| | 1107 | | return _measurement + " " + |
| | 1108 | | _LengthUnits1 |
| | 1109 | | + "/" + |
| | 1110 | | _TimeUnits2 + "/" + _TimeUnits3 |
| | 1111 | | ; |
| | 1112 | | } |
| | 1113 | |
|
| | 1114 | | /// <summary>Base hashing function for Acceleration measurements.</summary> |
| | 1115 | | /// <returns>Computed hash code for this instance.</returns> |
| | 1116 | | public override int GetHashCode() => Hash(_measurement); |
| | 1117 | |
|
| | 1118 | | #endregion |
| | 1119 | | } |
| | 1120 | |
|
| | 1121 | | #endregion |
| | 1122 | |
|
| | 1123 | | #region AngularAcceleration |
| | 1124 | |
|
| | 1125 | | internal static partial class ParsingFunctions |
| | 1126 | | { |
| | 1127 | | [Measurement.Parseable("Angle/Time/Time")] |
| | 1128 | | public static object AngularAcceleration<T>(T value, object[] units) |
| | 1129 | | { |
| | 1130 | | if (units.Length != 3) |
| | 1131 | | { |
| | 1132 | | throw new Exception("Bug in Towel. Invalid parameters to AngularAcceleration Factory."); |
| | 1133 | | } |
| | 1134 | | if (!(units[0] is Angle.Units)) |
| | 1135 | | { |
| | 1136 | | throw new Exception("Bug in Towel. Invalid parameters to AngularAcceleration Factory."); |
| | 1137 | | } |
| | 1138 | | if (!(units[1] is Time.Units)) |
| | 1139 | | { |
| | 1140 | | throw new Exception("Bug in Towel. Invalid parameters to AngularAcceleration Factory."); |
| | 1141 | | } |
| | 1142 | | if (!(units[2] is Time.Units)) |
| | 1143 | | { |
| | 1144 | | throw new Exception("Bug in Towel. Invalid parameters to AngularAcceleration Factory."); |
| | 1145 | | } |
| | 1146 | | return new AngularAcceleration<T>(value |
| | 1147 | | , (Angle.Units)units[0] |
| | 1148 | | , (Time.Units)units[1] |
| | 1149 | | , (Time.Units)units[2] |
| | 1150 | | ); |
| | 1151 | | } |
| | 1152 | | } |
| | 1153 | |
|
| | 1154 | | /// <summary>AngularAcceleration measurement with a value and the units.</summary> |
| | 1155 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 1156 | | public struct AngularAcceleration<T> |
| | 1157 | | { |
| | 1158 | | internal T _measurement; |
| | 1159 | | internal Angle.Units _AngleUnits1; |
| | 1160 | | internal Time.Units _TimeUnits2; |
| | 1161 | | internal Time.Units _TimeUnits3; |
| | 1162 | |
|
| | 1163 | | #region Statics |
| | 1164 | |
|
| | 1165 | | /// <summary>Converts a AngularAcceleration measurement from units to another.</summary> |
| | 1166 | | /// <param name="value">The value to convert the units of.</param> |
| | 1167 | | /// <param name="fromAngleUnits1">The current units of the measurement.</param> |
| | 1168 | | /// <param name="fromTimeUnits2">The current units of the measurement.</param> |
| | 1169 | | /// <param name="fromTimeUnits3">The current units of the measurement.</param> |
| | 1170 | | /// <param name="toAngleUnits1">The desired units of the measurement.</param> |
| | 1171 | | /// <param name="toTimeUnits2">The desired units of the measurement.</param> |
| | 1172 | | /// <param name="toTimeUnits3">The desired units of the measurement.</param> |
| | 1173 | | /// <returns>The AngularAcceleration measurement converted into the desired units.</returns> |
| | 1174 | | public static T Convert(T value |
| | 1175 | | , Angle.Units fromAngleUnits1 |
| | 1176 | | , Time.Units fromTimeUnits2 |
| | 1177 | | , Time.Units fromTimeUnits3 |
| | 1178 | | , Angle.Units toAngleUnits1 |
| | 1179 | | , Time.Units toTimeUnits2 |
| | 1180 | | , Time.Units toTimeUnits3 |
| | 1181 | | ) |
| | 1182 | | { |
| | 1183 | | AngularAcceleration<T> measurement = new AngularAcceleration<T>(value |
| | 1184 | | , fromAngleUnits1 |
| | 1185 | | , fromTimeUnits2 |
| | 1186 | | , fromTimeUnits3 |
| | 1187 | | ); |
| | 1188 | | return measurement[ |
| | 1189 | | toAngleUnits1 |
| | 1190 | | , toTimeUnits2 |
| | 1191 | | , toTimeUnits3 |
| | 1192 | | ]; |
| | 1193 | | } |
| | 1194 | |
|
| | 1195 | | /// <summary>Converts a AngularAcceleration measurement from units to another.</summary> |
| | 1196 | | /// <param name="value">The value to convert the units of.</param> |
| | 1197 | | /// <param name="from">The current units of the measurement.</param> |
| | 1198 | | /// <param name="to">The desired units of the measurement.</param> |
| | 1199 | | /// <returns>The AngularAcceleration measurement converted into the desired units.</returns> |
| | 1200 | | public static T Convert(T value, |
| | 1201 | | MeasurementUnitsSyntaxTypes.AngularAccelerationBaseUnits from, |
| | 1202 | | MeasurementUnitsSyntaxTypes.AngularAccelerationBaseUnits to) |
| | 1203 | | { |
| | 1204 | | return Convert(value |
| | 1205 | | , from._AngleUnits1 |
| | 1206 | | , from._TimeUnits2 |
| | 1207 | | , from._TimeUnits3 |
| | 1208 | | , to._AngleUnits1 |
| | 1209 | | , to._TimeUnits2 |
| | 1210 | | , to._TimeUnits3 |
| | 1211 | | ); |
| | 1212 | | } |
| | 1213 | |
|
| | 1214 | | /// <summary>Parses a AngularAcceleration measurement string.</summary> |
| | 1215 | | /// <param name="string">The string to be parsed.</param> |
| | 1216 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 1217 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 1218 | | public static (bool Success, AngularAcceleration<T>? Value) TryParse(string @string, Func<string, (bool Success, T V |
| | 1219 | |
|
| | 1220 | | #endregion |
| | 1221 | |
|
| | 1222 | | #region Constructors |
| | 1223 | |
|
| | 1224 | | /// <summary>Constructs an AngularAcceleration with the measurement value and units.</summary> |
| | 1225 | | /// <param name="measurement">The measurement value of the AngularAcceleration.</param> |
| | 1226 | | /// <param name="units">The units of the AngularAcceleration.</param> |
| | 1227 | | public AngularAcceleration(T measurement, MeasurementUnitsSyntaxTypes.AngularAccelerationBaseUnits units) : this(mea |
| | 1228 | | , units._AngleUnits1 |
| | 1229 | | , units._TimeUnits2 |
| | 1230 | | , units._TimeUnits3 |
| | 1231 | | ) { } |
| | 1232 | |
|
| | 1233 | |
|
| | 1234 | | /// <summary>Constructs an AngularAcceleration with the measurement value and units.</summary> |
| | 1235 | | /// <param name="measurement">The measurement value of the AngularAcceleration.</param> |
| | 1236 | | /// <param name="AngleUnits1">The units of the AngularAcceleration.</param> |
| | 1237 | | /// <param name="TimeUnits2">The units of the AngularAcceleration.</param> |
| | 1238 | | /// <param name="TimeUnits3">The units of the AngularAcceleration.</param> |
| | 1239 | | public AngularAcceleration(T measurement |
| | 1240 | | , Angle.Units AngleUnits1 |
| | 1241 | | , Time.Units TimeUnits2 |
| | 1242 | | , Time.Units TimeUnits3 |
| | 1243 | | ) |
| | 1244 | | { |
| | 1245 | | _measurement = measurement; |
| | 1246 | | _AngleUnits1 = AngleUnits1; |
| | 1247 | | _TimeUnits2 = TimeUnits2; |
| | 1248 | | _TimeUnits3 = TimeUnits3; |
| | 1249 | | } |
| | 1250 | |
|
| | 1251 | | #endregion |
| | 1252 | |
|
| | 1253 | | #region Properties |
| | 1254 | |
|
| | 1255 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 1256 | | public Angle.Units AngleUnits1 |
| | 1257 | | { |
| | 1258 | | get { return _AngleUnits1; } |
| | 1259 | | set |
| | 1260 | | { |
| | 1261 | | if (value != _AngleUnits1) |
| | 1262 | | { |
| | 1263 | | _measurement = this[value, _TimeUnits2, _TimeUnits3]; |
| | 1264 | | _AngleUnits1 = value; |
| | 1265 | | } |
| | 1266 | | } |
| | 1267 | | } |
| | 1268 | |
|
| | 1269 | | /// <summary>The #2 component of this measurements units.</summary> |
| | 1270 | | public Time.Units TimeUnits2 |
| | 1271 | | { |
| | 1272 | | get { return _TimeUnits2; } |
| | 1273 | | set |
| | 1274 | | { |
| | 1275 | | if (value != _TimeUnits2) |
| | 1276 | | { |
| | 1277 | | _measurement = this[_AngleUnits1, value, _TimeUnits3]; |
| | 1278 | | _TimeUnits2 = value; |
| | 1279 | | } |
| | 1280 | | } |
| | 1281 | | } |
| | 1282 | |
|
| | 1283 | | /// <summary>The #3 component of this measurements units.</summary> |
| | 1284 | | public Time.Units TimeUnits3 |
| | 1285 | | { |
| | 1286 | | get { return _TimeUnits3; } |
| | 1287 | | set |
| | 1288 | | { |
| | 1289 | | if (value != _TimeUnits3) |
| | 1290 | | { |
| | 1291 | | _measurement = this[_AngleUnits1, _TimeUnits2, value]; |
| | 1292 | | _TimeUnits3 = value; |
| | 1293 | | } |
| | 1294 | | } |
| | 1295 | | } |
| | 1296 | |
|
| | 1297 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 1298 | | /// <param name="units">The units to get the measurement in.</param> |
| | 1299 | | /// <returns>The measurement value in the specified units.</returns> |
| | 1300 | | public T this[MeasurementUnitsSyntaxTypes.AngularAccelerationBaseUnits units] |
| | 1301 | | { |
| | 1302 | | get { return this[units._AngleUnits1, units._TimeUnits2, units._TimeUnits3]; } |
| | 1303 | | } |
| | 1304 | |
|
| | 1305 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 1306 | | /// <param name="AngleUnits1">The #1 component of this measurements units.</param> |
| | 1307 | | /// <param name="TimeUnits2">The #2 component of this measurements units.</param> |
| | 1308 | | /// <param name="TimeUnits3">The #3 component of this measurements units.</param> |
| | 1309 | | /// <returns>The measurement value in the specified units.</returns> |
| | 1310 | | public T this[Angle.Units AngleUnits1, Time.Units TimeUnits2, Time.Units TimeUnits3] |
| | 1311 | | { |
| | 1312 | | get |
| | 1313 | | { |
| | 1314 | | T measurement = _measurement; |
| | 1315 | | if (AngleUnits1 != _AngleUnits1) |
| | 1316 | | { |
| | 1317 | | measurement = Angle<T>.Table[(int)_AngleUnits1][(int)AngleUnits1](measurement); |
| | 1318 | | //if (AngleUnits1 < _AngleUnits1) |
| | 1319 | | //{ |
| | 1320 | | // measurement = Angle<T>.Table[(int)_AngleUnits1][(int)AngleUnits1](measurement); |
| | 1321 | | //} |
| | 1322 | | //else |
| | 1323 | | //{ |
| | 1324 | | // measurement = Angle<T>.Table[(int)AngleUnits1][(int)_AngleUnits1](measurement); |
| | 1325 | | //} |
| | 1326 | | } |
| | 1327 | | if (TimeUnits2 != _TimeUnits2) |
| | 1328 | | { |
| | 1329 | | measurement = Time<T>.Table[(int)TimeUnits2][(int)_TimeUnits2](measurement); |
| | 1330 | | //if (TimeUnits2 > _TimeUnits2) |
| | 1331 | | //{ |
| | 1332 | | // measurement = Time<T>.Table[(int)_TimeUnits2][(int)TimeUnits2](measurement); |
| | 1333 | | //} |
| | 1334 | | //else |
| | 1335 | | //{ |
| | 1336 | | // measurement = Time<T>.Table[(int)TimeUnits2][(int)_TimeUnits2](measurement); |
| | 1337 | | //} |
| | 1338 | | } |
| | 1339 | | if (TimeUnits3 != _TimeUnits3) |
| | 1340 | | { |
| | 1341 | | measurement = Time<T>.Table[(int)TimeUnits3][(int)_TimeUnits3](measurement); |
| | 1342 | | //if (TimeUnits3 > _TimeUnits3) |
| | 1343 | | //{ |
| | 1344 | | // measurement = Time<T>.Table[(int)_TimeUnits3][(int)TimeUnits3](measurement); |
| | 1345 | | //} |
| | 1346 | | //else |
| | 1347 | | //{ |
| | 1348 | | // measurement = Time<T>.Table[(int)TimeUnits3][(int)_TimeUnits3](measurement); |
| | 1349 | | //} |
| | 1350 | | } |
| | 1351 | | return measurement; |
| | 1352 | | } |
| | 1353 | | } |
| | 1354 | |
|
| | 1355 | | #endregion |
| | 1356 | |
|
| | 1357 | | #region Casting Operators |
| | 1358 | |
|
| | 1359 | | /// <summary>Converts a ValueTuple to a AngularAcceleration measurement.</summary> |
| | 1360 | | /// <param name="valueTuple">The ValueTuple to converted into a AngularAcceleration measurement.</param> |
| | 1361 | | public static implicit operator AngularAcceleration<T>((T, MeasurementUnitsSyntaxTypes.AngularAccelerationBaseUnits) |
| | 1362 | | { |
| | 1363 | | return new AngularAcceleration<T>(valueTuple.Item1, valueTuple.Item2); |
| | 1364 | | } |
| | 1365 | |
|
| | 1366 | | #endregion |
| | 1367 | |
|
| | 1368 | | #region Mathematics |
| | 1369 | |
|
| | 1370 | | #region Bases |
| | 1371 | |
|
| | 1372 | | internal static AngularAcceleration<T> MathBase(AngularAcceleration<T> a, T b, Func<T, T, T> func) |
| | 1373 | | { |
| | 1374 | | return new AngularAcceleration<T>(func(a._measurement, b) |
| | 1375 | | , a._AngleUnits1 |
| | 1376 | | , a._TimeUnits2 |
| | 1377 | | , a._TimeUnits3 |
| | 1378 | | ); |
| | 1379 | | } |
| | 1380 | |
|
| | 1381 | | internal static AngularAcceleration<T> MathBase(AngularAcceleration<T> a, AngularAcceleration<T> b, Func<T, T, T> fu |
| | 1382 | | { |
| | 1383 | | Angle.Units AngleUnits1 = a._AngleUnits1 <= b._AngleUnits1 ? a._AngleUnits1 : b._AngleUnits1; |
| | 1384 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 1385 | | Time.Units TimeUnits3 = a._TimeUnits3 <= b._TimeUnits3 ? a._TimeUnits3 : b._TimeUnits3; |
| | 1386 | | T A = a[AngleUnits1, TimeUnits2, TimeUnits3]; |
| | 1387 | | T B = b[AngleUnits1, TimeUnits2, TimeUnits3]; |
| | 1388 | | T C = func(A, B); |
| | 1389 | | return new AngularAcceleration<T>(C, AngleUnits1, TimeUnits2, TimeUnits3); |
| | 1390 | | } |
| | 1391 | |
|
| | 1392 | | internal static bool LogicBase(AngularAcceleration<T> a, AngularAcceleration<T> b, Func<T, T, bool> func) |
| | 1393 | | { |
| | 1394 | | Angle.Units AngleUnits1 = a._AngleUnits1 <= b._AngleUnits1 ? a._AngleUnits1 : b._AngleUnits1; |
| | 1395 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 1396 | | Time.Units TimeUnits3 = a._TimeUnits3 <= b._TimeUnits3 ? a._TimeUnits3 : b._TimeUnits3; |
| | 1397 | | T A = a[AngleUnits1, TimeUnits2, TimeUnits3]; |
| | 1398 | | T B = b[AngleUnits1, TimeUnits2, TimeUnits3]; |
| | 1399 | | return func(A, B); |
| | 1400 | | } |
| | 1401 | |
|
| | 1402 | | #endregion |
| | 1403 | |
|
| | 1404 | | #region Add |
| | 1405 | |
|
| | 1406 | | /// <summary>Adds two AngularAcceleration measurements.</summary> |
| | 1407 | | /// <param name="a">The first operand of the addition.</param> |
| | 1408 | | /// <param name="b">The second operand of the addition.</param> |
| | 1409 | | /// <returns>The result of the addition operation.</returns> |
| | 1410 | | public static AngularAcceleration<T> Add(AngularAcceleration<T> a, AngularAcceleration<T> b) |
| | 1411 | | { |
| | 1412 | | return MathBase(a, b, Statics.Addition); |
| | 1413 | | } |
| | 1414 | |
|
| | 1415 | | /// <summary>Adds two AngularAcceleration measurements.</summary> |
| | 1416 | | /// <param name="a">The first operand of the addition.</param> |
| | 1417 | | /// <param name="b">The second operand of the addition.</param> |
| | 1418 | | /// <returns>The result of the addition operation.</returns> |
| | 1419 | | public static AngularAcceleration<T> operator +(AngularAcceleration<T> a, AngularAcceleration<T> b) |
| | 1420 | | { |
| | 1421 | | return Add(a, b); |
| | 1422 | | } |
| | 1423 | |
|
| | 1424 | | /// <summary>Adds two AngularAcceleration measurements.</summary> |
| | 1425 | | /// <param name="b">The second operand of the addition.</param> |
| | 1426 | | /// <returns>The result of the addition operation.</returns> |
| | 1427 | | public AngularAcceleration<T> Add(AngularAcceleration<T> b) |
| | 1428 | | { |
| | 1429 | | return this + b; |
| | 1430 | | } |
| | 1431 | |
|
| | 1432 | | #endregion |
| | 1433 | |
|
| | 1434 | | #region Subtract |
| | 1435 | |
|
| | 1436 | | /// <summary>Subtracts two AngularAcceleration measurements.</summary> |
| | 1437 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 1438 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 1439 | | /// <returns>The result of the subtraction.</returns> |
| | 1440 | | public static AngularAcceleration<T> Subtract(AngularAcceleration<T> a, AngularAcceleration<T> b) |
| | 1441 | | { |
| | 1442 | | return MathBase(a, b, Statics.Subtraction); |
| | 1443 | | } |
| | 1444 | |
|
| | 1445 | | /// <summary>Subtracts two AngularAcceleration measurements.</summary> |
| | 1446 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 1447 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 1448 | | /// <returns>The result of the subtraction.</returns> |
| | 1449 | | public static AngularAcceleration<T> operator -(AngularAcceleration<T> a, AngularAcceleration<T> b) |
| | 1450 | | { |
| | 1451 | | return Subtract(a, b); |
| | 1452 | | } |
| | 1453 | |
|
| | 1454 | | /// <summary>Subtracts two AngularAcceleration measurements.</summary> |
| | 1455 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 1456 | | /// <returns>The result of the subtraction.</returns> |
| | 1457 | | public AngularAcceleration<T> Subtract(AngularAcceleration<T> b) |
| | 1458 | | { |
| | 1459 | | return this - b; |
| | 1460 | | } |
| | 1461 | |
|
| | 1462 | | #endregion |
| | 1463 | |
|
| | 1464 | | #region Multiply |
| | 1465 | |
|
| | 1466 | | /// <summary>Multiplies an AngularAcceleration by a scalar numeric value.</summary> |
| | 1467 | | /// <param name="a">The AngularAcceleration measurement to multiply.</param> |
| | 1468 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 1469 | | /// <returns>The result of the multiplication.</returns> |
| | 1470 | | public static AngularAcceleration<T> Multiply(AngularAcceleration<T> a, T b) |
| | 1471 | | { |
| | 1472 | | return MathBase(a, b, Statics.Multiplication); |
| | 1473 | | } |
| | 1474 | |
|
| | 1475 | | /// <summary>Multiplies an AngularAcceleration by a scalar numeric value.</summary> |
| | 1476 | | /// <param name="a">The AngularAcceleration measurement to multiply.</param> |
| | 1477 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 1478 | | /// <returns>The result of the multiplication.</returns> |
| | 1479 | | public static AngularAcceleration<T> Multiply(T b, AngularAcceleration<T> a) |
| | 1480 | | { |
| | 1481 | | return Multiply(a, b); |
| | 1482 | | } |
| | 1483 | |
|
| | 1484 | | /// <summary>Multiplies an AngularAcceleration by a scalar numeric value.</summary> |
| | 1485 | | /// <param name="a">The AngularAcceleration measurement to multiply.</param> |
| | 1486 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 1487 | | /// <returns>The result of the multiplication.</returns> |
| | 1488 | | public static AngularAcceleration<T> operator *(AngularAcceleration<T> a, T b) |
| | 1489 | | { |
| | 1490 | | return Multiply(a, b); |
| | 1491 | | } |
| | 1492 | |
|
| | 1493 | | /// <summary>Multiplies an AngularAcceleration by a scalar numeric value.</summary> |
| | 1494 | | /// <param name="a">The AngularAcceleration measurement to multiply.</param> |
| | 1495 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 1496 | | /// <returns>The result of the multiplication.</returns> |
| | 1497 | | public static AngularAcceleration<T> operator *(T b, AngularAcceleration<T> a) |
| | 1498 | | { |
| | 1499 | | return Multiply(b, a); |
| | 1500 | | } |
| | 1501 | |
|
| | 1502 | | /// <summary>Multiplies an AngularAcceleration by a scalar numeric value.</summary> |
| | 1503 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 1504 | | /// <returns>The result of the multiplication.</returns> |
| | 1505 | | public AngularAcceleration<T> Add(T b) |
| | 1506 | | { |
| | 1507 | | return this * b; |
| | 1508 | | } |
| | 1509 | |
|
| | 1510 | | #region AngularAcceleration<T> * Time<T> = AngularSpeed<T> |
| | 1511 | |
|
| | 1512 | | /// <summary>Mulitplies AngularAcceleration by Time resulting in AngularSpeed.</summary> |
| | 1513 | | /// <param name="a">The AngularAcceleration to be multiplied.</param> |
| | 1514 | | /// <param name="b">The Time to multiply by.</param> |
| | 1515 | | /// <returns>The AngularSpeed result of the multiplication.</returns> |
| | 1516 | | public static AngularSpeed<T> Multiply(AngularAcceleration<T> a, Time<T> b) |
| | 1517 | | { |
| | 1518 | | Time.Units TimeUnits1 = a._TimeUnits2 <= b._TimeUnits1 ? a._TimeUnits2 : b._TimeUnits1; |
| | 1519 | |
|
| | 1520 | | T A = a[a._AngleUnits1, TimeUnits1, a._TimeUnits3]; |
| | 1521 | | T B = b[TimeUnits1]; |
| | 1522 | | T C = Statics.Multiplication(A, B); |
| | 1523 | |
|
| | 1524 | | return new AngularSpeed<T>(C |
| | 1525 | | , a._AngleUnits1 |
| | 1526 | | , a._TimeUnits3 |
| | 1527 | | ); |
| | 1528 | | } |
| | 1529 | |
|
| | 1530 | | /// <summary>Mulitplies AngularAcceleration by Time resulting in AngularSpeed.</summary> |
| | 1531 | | /// <param name="a">The AngularAcceleration to be multiplied.</param> |
| | 1532 | | /// <param name="b">The Time to multiply by.</param> |
| | 1533 | | /// <returns>The AngularSpeed result of the multiplication.</returns> |
| | 1534 | | public static AngularSpeed<T> operator *(AngularAcceleration<T> a, Time<T> b) |
| | 1535 | | { |
| | 1536 | | return Multiply(a, b); |
| | 1537 | | } |
| | 1538 | |
|
| | 1539 | | /// <summary>Mulitplies AngularAcceleration by Time resulting in AngularSpeed.</summary> |
| | 1540 | | /// <param name="b">The Time to multiply by.</param> |
| | 1541 | | /// <returns>The AngularSpeed result of the multiplication.</returns> |
| | 1542 | | public AngularSpeed<T> Multiply(Time<T> b) |
| | 1543 | | { |
| | 1544 | | return this * b; |
| | 1545 | | } |
| | 1546 | |
|
| | 1547 | | #endregion |
| | 1548 | |
|
| | 1549 | | #region AngularAcceleration<T> * TimeArea<T> = Angle<T> |
| | 1550 | |
|
| | 1551 | | /// <summary>Mulitplies AngularAcceleration by TimeArea resulting in Angle.</summary> |
| | 1552 | | /// <param name="a">The AngularAcceleration to be multiplied.</param> |
| | 1553 | | /// <param name="b">The TimeArea to multiply by.</param> |
| | 1554 | | /// <returns>The Angle result of the multiplication.</returns> |
| | 1555 | | public static Angle<T> Multiply(AngularAcceleration<T> a, TimeArea<T> b) |
| | 1556 | | { |
| | 1557 | | Time.Units TimeUnits1 = a._TimeUnits2 <= b._TimeUnits1 ? a._TimeUnits2 : b._TimeUnits1; |
| | 1558 | | Time.Units TimeUnits2 = a._TimeUnits3 <= b._TimeUnits2 ? a._TimeUnits3 : b._TimeUnits2; |
| | 1559 | |
|
| | 1560 | | T A = a[a._AngleUnits1, TimeUnits1, TimeUnits2]; |
| | 1561 | | T B = b[TimeUnits1, TimeUnits2]; |
| | 1562 | | T C = Statics.Multiplication(A, B); |
| | 1563 | |
|
| | 1564 | | return new Angle<T>(C |
| | 1565 | | , a._AngleUnits1 |
| | 1566 | | ); |
| | 1567 | | } |
| | 1568 | |
|
| | 1569 | | /// <summary>Mulitplies AngularAcceleration by TimeArea resulting in Angle.</summary> |
| | 1570 | | /// <param name="a">The AngularAcceleration to be multiplied.</param> |
| | 1571 | | /// <param name="b">The TimeArea to multiply by.</param> |
| | 1572 | | /// <returns>The Angle result of the multiplication.</returns> |
| | 1573 | | public static Angle<T> operator *(AngularAcceleration<T> a, TimeArea<T> b) |
| | 1574 | | { |
| | 1575 | | return Multiply(a, b); |
| | 1576 | | } |
| | 1577 | |
|
| | 1578 | | /// <summary>Mulitplies AngularAcceleration by TimeArea resulting in Angle.</summary> |
| | 1579 | | /// <param name="b">The TimeArea to multiply by.</param> |
| | 1580 | | /// <returns>The Angle result of the multiplication.</returns> |
| | 1581 | | public Angle<T> Multiply(TimeArea<T> b) |
| | 1582 | | { |
| | 1583 | | return this * b; |
| | 1584 | | } |
| | 1585 | |
|
| | 1586 | | #endregion |
| | 1587 | |
|
| | 1588 | | #endregion |
| | 1589 | |
|
| | 1590 | | #region Divide |
| | 1591 | |
|
| | 1592 | | /// <summary>Divides an AngularAcceleration measurement by another AngularAcceleration measurement resulting in a sc |
| | 1593 | | /// <param name="a">The first operand of the division operation.</param> |
| | 1594 | | /// <param name="b">The second operand of the division operation.</param> |
| | 1595 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 1596 | | public static T Divide(AngularAcceleration<T> a, AngularAcceleration<T> b) |
| | 1597 | | { |
| | 1598 | | Angle.Units AngleUnits1 = a._AngleUnits1 <= b._AngleUnits1 ? a._AngleUnits1 : b._AngleUnits1; |
| | 1599 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 1600 | | Time.Units TimeUnits3 = a._TimeUnits3 <= b._TimeUnits3 ? a._TimeUnits3 : b._TimeUnits3; |
| | 1601 | | T A = a[AngleUnits1, TimeUnits2, TimeUnits3]; |
| | 1602 | | T B = b[AngleUnits1, TimeUnits2, TimeUnits3]; |
| | 1603 | | return Statics.Division(A, B); |
| | 1604 | | } |
| | 1605 | |
|
| | 1606 | | /// <summary>Divides this AngularAcceleration measurement by a numaric scalar value.</summary> |
| | 1607 | | /// <param name="a">The AngularAcceleration measurement to divide.</param> |
| | 1608 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 1609 | | /// <returns>The result of the division.</returns> |
| | 1610 | | public static AngularAcceleration<T> Divide(AngularAcceleration<T> a, T b) |
| | 1611 | | { |
| | 1612 | | return MathBase(a, b, Statics.Division); |
| | 1613 | | } |
| | 1614 | |
|
| | 1615 | | /// <summary>Divides this AngularAcceleration measurement by a numaric scalar value.</summary> |
| | 1616 | | /// <param name="a">The AngularAcceleration measurement to divide.</param> |
| | 1617 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 1618 | | /// <returns>The result of the division.</returns> |
| | 1619 | | public static AngularAcceleration<T> operator /(AngularAcceleration<T> a, T b) |
| | 1620 | | { |
| | 1621 | | return Divide(a, b); |
| | 1622 | | } |
| | 1623 | |
|
| | 1624 | | /// <summary>Divides this AngularAcceleration measurement by a numaric scalar value.</summary> |
| | 1625 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 1626 | | /// <returns>The result of the division.</returns> |
| | 1627 | | public AngularAcceleration<T> Divide(T b) |
| | 1628 | | { |
| | 1629 | | return this / b; |
| | 1630 | | } |
| | 1631 | |
|
| | 1632 | | /// <summary>Divides an AngularAcceleration measurement by another AngularAcceleration measurement resulting in a sc |
| | 1633 | | /// <param name="a">The first operand of the division operation.</param> |
| | 1634 | | /// <param name="b">The second operand of the division operation.</param> |
| | 1635 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 1636 | | public static T operator /(AngularAcceleration<T> a, AngularAcceleration<T> b) |
| | 1637 | | { |
| | 1638 | | return Divide(a, b); |
| | 1639 | | } |
| | 1640 | |
|
| | 1641 | | /// <summary>Divides an AngularAcceleration measurement by another AngularAcceleration measurement resulting in a sc |
| | 1642 | | /// <param name="b">The second operand of the division operation.</param> |
| | 1643 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 1644 | | public T Divide(AngularAcceleration<T> b) |
| | 1645 | | { |
| | 1646 | | return this / b; |
| | 1647 | | } |
| | 1648 | |
|
| | 1649 | | #endregion |
| | 1650 | |
|
| | 1651 | | #region LessThan |
| | 1652 | |
|
| | 1653 | | /// <summary>Determines if an AngularAcceleration measurement is less than another AngularAcceleration measurement.< |
| | 1654 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 1655 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 1656 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 1657 | | public static bool LessThan(AngularAcceleration<T> a, AngularAcceleration<T> b) |
| | 1658 | | { |
| | 1659 | | return LogicBase(a, b, Statics.LessThan); |
| | 1660 | | } |
| | 1661 | |
|
| | 1662 | | /// <summary>Determines if an AngularAcceleration measurement is less than another AngularAcceleration measurement.< |
| | 1663 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 1664 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 1665 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 1666 | | public static bool operator <(AngularAcceleration<T> a, AngularAcceleration<T> b) |
| | 1667 | | { |
| | 1668 | | return LessThan(a, b); |
| | 1669 | | } |
| | 1670 | |
|
| | 1671 | | /// <summary>Determines if an AngularAcceleration measurement is less than another AngularAcceleration measurement.< |
| | 1672 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 1673 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 1674 | | public bool LessThan(AngularAcceleration<T> b) |
| | 1675 | | { |
| | 1676 | | return this < b; |
| | 1677 | | } |
| | 1678 | |
|
| | 1679 | | #endregion |
| | 1680 | |
|
| | 1681 | | #region GreaterThan |
| | 1682 | |
|
| | 1683 | | /// <summary>Determines if an AngularAcceleration measurement is greater than another AngularAcceleration measuremen |
| | 1684 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 1685 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 1686 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 1687 | | public static bool GreaterThan(AngularAcceleration<T> a, AngularAcceleration<T> b) |
| | 1688 | | { |
| | 1689 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 1690 | | } |
| | 1691 | |
|
| | 1692 | | /// <summary>Determines if an AngularAcceleration measurement is greater than another AngularAcceleration measuremen |
| | 1693 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 1694 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 1695 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 1696 | | public static bool operator >(AngularAcceleration<T> a, AngularAcceleration<T> b) |
| | 1697 | | { |
| | 1698 | | return GreaterThan(a, b); |
| | 1699 | | } |
| | 1700 | |
|
| | 1701 | | /// <summary>Determines if an AngularAcceleration measurement is greater than another AngularAcceleration measuremen |
| | 1702 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 1703 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 1704 | | public bool GreaterThan(AngularAcceleration<T> b) |
| | 1705 | | { |
| | 1706 | | return this > b; |
| | 1707 | | } |
| | 1708 | |
|
| | 1709 | | #endregion |
| | 1710 | |
|
| | 1711 | | #region LessThanOrEqual |
| | 1712 | |
|
| | 1713 | | /// <summary>Determines if an AngularAcceleration measurement is less than or equal to another AngularAcceleration m |
| | 1714 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 1715 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 1716 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 1717 | | public static bool LessThanOrEqual(AngularAcceleration<T> a, AngularAcceleration<T> b) |
| | 1718 | | { |
| | 1719 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 1720 | | } |
| | 1721 | |
|
| | 1722 | | /// <summary>Determines if an AngularAcceleration measurement is less than or equal to another AngularAcceleration m |
| | 1723 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 1724 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 1725 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 1726 | | public static bool operator <=(AngularAcceleration<T> a, AngularAcceleration<T> b) |
| | 1727 | | { |
| | 1728 | | return LessThanOrEqual(a, b); |
| | 1729 | | } |
| | 1730 | |
|
| | 1731 | | /// <summary>Determines if an AngularAcceleration measurement is less than or equal to another AngularAcceleration m |
| | 1732 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 1733 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 1734 | | public bool LessThanOrEqual(AngularAcceleration<T> b) |
| | 1735 | | { |
| | 1736 | | return this <= b; |
| | 1737 | | } |
| | 1738 | |
|
| | 1739 | | #endregion |
| | 1740 | |
|
| | 1741 | | #region GreaterThanOrEqual |
| | 1742 | |
|
| | 1743 | | /// <summary>Determines if an AngularAcceleration measurement is greater than or equal to another AngularAcceleratio |
| | 1744 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 1745 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 1746 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 1747 | | public static bool GreaterThanOrEqual(AngularAcceleration<T> a, AngularAcceleration<T> b) |
| | 1748 | | { |
| | 1749 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 1750 | | } |
| | 1751 | |
|
| | 1752 | | /// <summary>Determines if an AngularAcceleration measurement is greater than or equal to another AngularAcceleratio |
| | 1753 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 1754 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 1755 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 1756 | | public static bool operator >=(AngularAcceleration<T> a, AngularAcceleration<T> b) |
| | 1757 | | { |
| | 1758 | | return GreaterThanOrEqual(a, b); |
| | 1759 | | } |
| | 1760 | |
|
| | 1761 | | /// <summary>Determines if an AngularAcceleration measurement is greater than or equal to another AngularAcceleratio |
| | 1762 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 1763 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 1764 | | public bool GreaterThanOrEqual(AngularAcceleration<T> b) |
| | 1765 | | { |
| | 1766 | | return this >= b; |
| | 1767 | | } |
| | 1768 | |
|
| | 1769 | | #endregion |
| | 1770 | |
|
| | 1771 | | #region Equal |
| | 1772 | |
|
| | 1773 | | /// <summary>Determines if an AngularAcceleration measurement is equal to another AngularAcceleration measurement.</ |
| | 1774 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 1775 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 1776 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 1777 | | public static bool Equal(AngularAcceleration<T> a, AngularAcceleration<T> b) |
| | 1778 | | { |
| | 1779 | | return LogicBase(a, b, Statics.Equate); |
| | 1780 | | } |
| | 1781 | |
|
| | 1782 | | /// <summary>Determines if an AngularAcceleration measurement is equal to another AngularAcceleration measurement.</ |
| | 1783 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 1784 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 1785 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 1786 | | public static bool operator ==(AngularAcceleration<T> a, AngularAcceleration<T> b) |
| | 1787 | | { |
| | 1788 | | return Equal(a, b); |
| | 1789 | | } |
| | 1790 | |
|
| | 1791 | | /// <summary>Determines if an AngularAcceleration measurement is equal to another AngularAcceleration measurement.</ |
| | 1792 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 1793 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 1794 | | public bool Equal(AngularAcceleration<T> b) |
| | 1795 | | { |
| | 1796 | | return this == b; |
| | 1797 | | } |
| | 1798 | |
|
| | 1799 | | #endregion |
| | 1800 | |
|
| | 1801 | | #region NotEqual |
| | 1802 | |
|
| | 1803 | | /// <summary>Determines if an AngularAcceleration measurement is not equal to another AngularAcceleration measuremen |
| | 1804 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 1805 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 1806 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 1807 | | public static bool NotEqual(AngularAcceleration<T> a, AngularAcceleration<T> b) |
| | 1808 | | { |
| | 1809 | | return LogicBase(a, b, Statics.Inequate); |
| | 1810 | | } |
| | 1811 | |
|
| | 1812 | | /// <summary>Determines if an AngularAcceleration measurement is not equal to another AngularAcceleration measuremen |
| | 1813 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 1814 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 1815 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 1816 | | public static bool operator !=(AngularAcceleration<T> a, AngularAcceleration<T> b) |
| | 1817 | | { |
| | 1818 | | return NotEqual(a, b); |
| | 1819 | | } |
| | 1820 | |
|
| | 1821 | | /// <summary>Determines if an AngularAcceleration measurement is not equal to another AngularAcceleration measuremen |
| | 1822 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 1823 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 1824 | | public bool NotEqual(AngularAcceleration<T> b) |
| | 1825 | | { |
| | 1826 | | return this != b; |
| | 1827 | | } |
| | 1828 | |
|
| | 1829 | | #endregion |
| | 1830 | |
|
| | 1831 | | #endregion |
| | 1832 | |
|
| | 1833 | | #region Overrides |
| | 1834 | |
|
| | 1835 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 1836 | | /// <param name="obj">The object to check for equality with.</param> |
| | 1837 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 1838 | | public override bool Equals(object obj) |
| | 1839 | | { |
| | 1840 | | if (obj is AngularAcceleration<T>) |
| | 1841 | | { |
| | 1842 | | return this == (AngularAcceleration<T>)obj; |
| | 1843 | | } |
| | 1844 | | return false; |
| | 1845 | | } |
| | 1846 | |
|
| | 1847 | | /// <summary>Converts the AngularAcceleration measurement to a string represenation.</summary> |
| | 1848 | | /// <returns>The string representation of the measurement.</returns> |
| | 1849 | | public override string ToString() |
| | 1850 | | { |
| | 1851 | | return _measurement + " " + |
| | 1852 | | _AngleUnits1 |
| | 1853 | | + "/" + |
| | 1854 | | _TimeUnits2 + "/" + _TimeUnits3 |
| | 1855 | | ; |
| | 1856 | | } |
| | 1857 | |
|
| | 1858 | | /// <summary>Base hashing function for AngularAcceleration measurements.</summary> |
| | 1859 | | /// <returns>Computed hash code for this instance.</returns> |
| | 1860 | | public override int GetHashCode() => Hash(_measurement); |
| | 1861 | |
|
| | 1862 | | #endregion |
| | 1863 | | } |
| | 1864 | |
|
| | 1865 | | #endregion |
| | 1866 | |
|
| | 1867 | | #region Angle |
| | 1868 | |
|
| | 1869 | | internal static partial class ParsingFunctions |
| | 1870 | | { |
| | 1871 | | [Measurement.Parseable("Angle")] |
| | 1872 | | public static object Angle<T>(T value, object[] units) |
| | 1873 | | { |
| | 1874 | | if (units.Length != 1) |
| | 1875 | | { |
| | 1876 | | throw new Exception("Bug in Towel. Invalid parameters to Angle Factory."); |
| | 1877 | | } |
| | 1878 | | if (!(units[0] is Angle.Units)) |
| | 1879 | | { |
| | 1880 | | throw new Exception("Bug in Towel. Invalid parameters to Angle Factory."); |
| | 1881 | | } |
| | 1882 | | return new Angle<T>(value |
| | 1883 | | , (Angle.Units)units[0] |
| | 1884 | | ); |
| | 1885 | | } |
| | 1886 | | } |
| | 1887 | |
|
| | 1888 | | /// <summary>Angle measurement with a value and the units.</summary> |
| | 1889 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 1890 | | public struct Angle<T> |
| | 1891 | | { |
| | 1892 | | internal static Func<T, T>[][] Table = UnitConversionTable.Build<Angle.Units, T>(); |
| | 1893 | | internal T _measurement; |
| | 1894 | | internal Angle.Units _AngleUnits1; |
| | 1895 | |
|
| | 1896 | | #region Statics |
| | 1897 | |
|
| | 1898 | | /// <summary>Converts a Angle measurement from units to another.</summary> |
| | 1899 | | /// <param name="value">The value to convert the units of.</param> |
| | 1900 | | /// <param name="fromAngleUnits1">The current units of the measurement.</param> |
| | 1901 | | /// <param name="toAngleUnits1">The desired units of the measurement.</param> |
| | 1902 | | /// <returns>The Angle measurement converted into the desired units.</returns> |
| | 1903 | | public static T Convert(T value |
| | 1904 | | , Angle.Units fromAngleUnits1 |
| | 1905 | | , Angle.Units toAngleUnits1 |
| | 1906 | | ) |
| | 1907 | | { |
| | 1908 | | Angle<T> measurement = new Angle<T>(value |
| | 1909 | | , fromAngleUnits1 |
| | 1910 | | ); |
| | 1911 | | return measurement[ |
| | 1912 | | toAngleUnits1 |
| | 1913 | | ]; |
| | 1914 | | } |
| | 1915 | |
|
| | 1916 | | /// <summary>Converts a Angle measurement from units to another.</summary> |
| | 1917 | | /// <param name="value">The value to convert the units of.</param> |
| | 1918 | | /// <param name="from">The current units of the measurement.</param> |
| | 1919 | | /// <param name="to">The desired units of the measurement.</param> |
| | 1920 | | /// <returns>The Angle measurement converted into the desired units.</returns> |
| | 1921 | | public static T Convert(T value, |
| | 1922 | | MeasurementUnitsSyntaxTypes.AngleUnits from, |
| | 1923 | | MeasurementUnitsSyntaxTypes.AngleUnits to) |
| | 1924 | | { |
| | 1925 | | return Convert(value |
| | 1926 | | , from._AngleUnits1 |
| | 1927 | | , to._AngleUnits1 |
| | 1928 | | ); |
| | 1929 | | } |
| | 1930 | |
|
| | 1931 | | /// <summary>Parses a Angle measurement string.</summary> |
| | 1932 | | /// <param name="string">The string to be parsed.</param> |
| | 1933 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 1934 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 1935 | | public static (bool Success, Angle<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value)> tryPars |
| | 1936 | |
|
| | 1937 | | #endregion |
| | 1938 | |
|
| | 1939 | | #region Constructors |
| | 1940 | |
|
| | 1941 | | /// <summary>Constructs an Angle with the measurement value and units.</summary> |
| | 1942 | | /// <param name="measurement">The measurement value of the Angle.</param> |
| | 1943 | | /// <param name="units">The units of the Angle.</param> |
| | 1944 | | public Angle(T measurement, MeasurementUnitsSyntaxTypes.AngleUnits units) : this(measurement |
| | 1945 | | , units._AngleUnits1 |
| | 1946 | | ) { } |
| | 1947 | |
|
| | 1948 | |
|
| | 1949 | | /// <summary>Constructs an Angle with the measurement value and units.</summary> |
| | 1950 | | /// <param name="measurement">The measurement value of the Angle.</param> |
| | 1951 | | /// <param name="AngleUnits1">The units of the Angle.</param> |
| | 1952 | | public Angle(T measurement |
| | 1953 | | , Angle.Units AngleUnits1 |
| | 1954 | | ) |
| | 1955 | | { |
| | 1956 | | _measurement = measurement; |
| | 1957 | | _AngleUnits1 = AngleUnits1; |
| | 1958 | | } |
| | 1959 | |
|
| | 1960 | | #endregion |
| | 1961 | |
|
| | 1962 | | #region Properties |
| | 1963 | |
|
| | 1964 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 1965 | | public Angle.Units AngleUnits1 |
| | 1966 | | { |
| | 1967 | | get { return _AngleUnits1; } |
| | 1968 | | set |
| | 1969 | | { |
| | 1970 | | if (value != _AngleUnits1) |
| | 1971 | | { |
| | 1972 | | _measurement = this[value]; |
| | 1973 | | _AngleUnits1 = value; |
| | 1974 | | } |
| | 1975 | | } |
| | 1976 | | } |
| | 1977 | |
|
| | 1978 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 1979 | | /// <param name="units">The units to get the measurement in.</param> |
| | 1980 | | /// <returns>The measurement value in the specified units.</returns> |
| | 1981 | | public T this[MeasurementUnitsSyntaxTypes.AngleUnits units] |
| | 1982 | | { |
| | 1983 | | get { return this[units._AngleUnits1]; } |
| | 1984 | | } |
| | 1985 | |
|
| | 1986 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 1987 | | /// <param name="AngleUnits1">The #1 component of this measurements units.</param> |
| | 1988 | | /// <returns>The measurement value in the specified units.</returns> |
| | 1989 | | public T this[Angle.Units AngleUnits1] |
| | 1990 | | { |
| | 1991 | | get |
| | 1992 | | { |
| | 1993 | | T measurement = _measurement; |
| | 1994 | | if (AngleUnits1 != _AngleUnits1) |
| | 1995 | | { |
| | 1996 | | measurement = Angle<T>.Table[(int)_AngleUnits1][(int)AngleUnits1](measurement); |
| | 1997 | | //if (AngleUnits1 < _AngleUnits1) |
| | 1998 | | //{ |
| | 1999 | | // measurement = Angle<T>.Table[(int)_AngleUnits1][(int)AngleUnits1](measurement); |
| | 2000 | | //} |
| | 2001 | | //else |
| | 2002 | | //{ |
| | 2003 | | // measurement = Angle<T>.Table[(int)AngleUnits1][(int)_AngleUnits1](measurement); |
| | 2004 | | //} |
| | 2005 | | } |
| | 2006 | | return measurement; |
| | 2007 | | } |
| | 2008 | | } |
| | 2009 | |
|
| | 2010 | | #endregion |
| | 2011 | |
|
| | 2012 | | #region Casting Operators |
| | 2013 | |
|
| | 2014 | | /// <summary>Converts a ValueTuple to a Angle measurement.</summary> |
| | 2015 | | /// <param name="valueTuple">The ValueTuple to converted into a Angle measurement.</param> |
| | 2016 | | public static implicit operator Angle<T>((T, MeasurementUnitsSyntaxTypes.AngleUnits) valueTuple) |
| | 2017 | | { |
| | 2018 | | return new Angle<T>(valueTuple.Item1, valueTuple.Item2); |
| | 2019 | | } |
| | 2020 | |
|
| | 2021 | | #endregion |
| | 2022 | |
|
| | 2023 | | #region Mathematics |
| | 2024 | |
|
| | 2025 | | #region Bases |
| | 2026 | |
|
| | 2027 | | internal static Angle<T> MathBase(Angle<T> a, T b, Func<T, T, T> func) |
| | 2028 | | { |
| | 2029 | | return new Angle<T>(func(a._measurement, b) |
| | 2030 | | , a._AngleUnits1 |
| | 2031 | | ); |
| | 2032 | | } |
| | 2033 | |
|
| | 2034 | | internal static Angle<T> MathBase(Angle<T> a, Angle<T> b, Func<T, T, T> func) |
| | 2035 | | { |
| | 2036 | | Angle.Units AngleUnits1 = a._AngleUnits1 <= b._AngleUnits1 ? a._AngleUnits1 : b._AngleUnits1; |
| | 2037 | | T A = a[AngleUnits1]; |
| | 2038 | | T B = b[AngleUnits1]; |
| | 2039 | | T C = func(A, B); |
| | 2040 | | return new Angle<T>(C, AngleUnits1); |
| | 2041 | | } |
| | 2042 | |
|
| | 2043 | | internal static bool LogicBase(Angle<T> a, Angle<T> b, Func<T, T, bool> func) |
| | 2044 | | { |
| | 2045 | | Angle.Units AngleUnits1 = a._AngleUnits1 <= b._AngleUnits1 ? a._AngleUnits1 : b._AngleUnits1; |
| | 2046 | | T A = a[AngleUnits1]; |
| | 2047 | | T B = b[AngleUnits1]; |
| | 2048 | | return func(A, B); |
| | 2049 | | } |
| | 2050 | |
|
| | 2051 | | #endregion |
| | 2052 | |
|
| | 2053 | | #region Add |
| | 2054 | |
|
| | 2055 | | /// <summary>Adds two Angle measurements.</summary> |
| | 2056 | | /// <param name="a">The first operand of the addition.</param> |
| | 2057 | | /// <param name="b">The second operand of the addition.</param> |
| | 2058 | | /// <returns>The result of the addition operation.</returns> |
| | 2059 | | public static Angle<T> Add(Angle<T> a, Angle<T> b) |
| | 2060 | | { |
| | 2061 | | return MathBase(a, b, Statics.Addition); |
| | 2062 | | } |
| | 2063 | |
|
| | 2064 | | /// <summary>Adds two Angle measurements.</summary> |
| | 2065 | | /// <param name="a">The first operand of the addition.</param> |
| | 2066 | | /// <param name="b">The second operand of the addition.</param> |
| | 2067 | | /// <returns>The result of the addition operation.</returns> |
| | 2068 | | public static Angle<T> operator +(Angle<T> a, Angle<T> b) |
| | 2069 | | { |
| | 2070 | | return Add(a, b); |
| | 2071 | | } |
| | 2072 | |
|
| | 2073 | | /// <summary>Adds two Angle measurements.</summary> |
| | 2074 | | /// <param name="b">The second operand of the addition.</param> |
| | 2075 | | /// <returns>The result of the addition operation.</returns> |
| | 2076 | | public Angle<T> Add(Angle<T> b) |
| | 2077 | | { |
| | 2078 | | return this + b; |
| | 2079 | | } |
| | 2080 | |
|
| | 2081 | | #endregion |
| | 2082 | |
|
| | 2083 | | #region Subtract |
| | 2084 | |
|
| | 2085 | | /// <summary>Subtracts two Angle measurements.</summary> |
| | 2086 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 2087 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 2088 | | /// <returns>The result of the subtraction.</returns> |
| | 2089 | | public static Angle<T> Subtract(Angle<T> a, Angle<T> b) |
| | 2090 | | { |
| | 2091 | | return MathBase(a, b, Statics.Subtraction); |
| | 2092 | | } |
| | 2093 | |
|
| | 2094 | | /// <summary>Subtracts two Angle measurements.</summary> |
| | 2095 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 2096 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 2097 | | /// <returns>The result of the subtraction.</returns> |
| | 2098 | | public static Angle<T> operator -(Angle<T> a, Angle<T> b) |
| | 2099 | | { |
| | 2100 | | return Subtract(a, b); |
| | 2101 | | } |
| | 2102 | |
|
| | 2103 | | /// <summary>Subtracts two Angle measurements.</summary> |
| | 2104 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 2105 | | /// <returns>The result of the subtraction.</returns> |
| | 2106 | | public Angle<T> Subtract(Angle<T> b) |
| | 2107 | | { |
| | 2108 | | return this - b; |
| | 2109 | | } |
| | 2110 | |
|
| | 2111 | | #endregion |
| | 2112 | |
|
| | 2113 | | #region Multiply |
| | 2114 | |
|
| | 2115 | | /// <summary>Multiplies an Angle by a scalar numeric value.</summary> |
| | 2116 | | /// <param name="a">The Angle measurement to multiply.</param> |
| | 2117 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 2118 | | /// <returns>The result of the multiplication.</returns> |
| | 2119 | | public static Angle<T> Multiply(Angle<T> a, T b) |
| | 2120 | | { |
| | 2121 | | return MathBase(a, b, Statics.Multiplication); |
| | 2122 | | } |
| | 2123 | |
|
| | 2124 | | /// <summary>Multiplies an Angle by a scalar numeric value.</summary> |
| | 2125 | | /// <param name="a">The Angle measurement to multiply.</param> |
| | 2126 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 2127 | | /// <returns>The result of the multiplication.</returns> |
| | 2128 | | public static Angle<T> Multiply(T b, Angle<T> a) |
| | 2129 | | { |
| | 2130 | | return Multiply(a, b); |
| | 2131 | | } |
| | 2132 | |
|
| | 2133 | | /// <summary>Multiplies an Angle by a scalar numeric value.</summary> |
| | 2134 | | /// <param name="a">The Angle measurement to multiply.</param> |
| | 2135 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 2136 | | /// <returns>The result of the multiplication.</returns> |
| | 2137 | | public static Angle<T> operator *(Angle<T> a, T b) |
| | 2138 | | { |
| | 2139 | | return Multiply(a, b); |
| | 2140 | | } |
| | 2141 | |
|
| | 2142 | | /// <summary>Multiplies an Angle by a scalar numeric value.</summary> |
| | 2143 | | /// <param name="a">The Angle measurement to multiply.</param> |
| | 2144 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 2145 | | /// <returns>The result of the multiplication.</returns> |
| | 2146 | | public static Angle<T> operator *(T b, Angle<T> a) |
| | 2147 | | { |
| | 2148 | | return Multiply(b, a); |
| | 2149 | | } |
| | 2150 | |
|
| | 2151 | | /// <summary>Multiplies an Angle by a scalar numeric value.</summary> |
| | 2152 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 2153 | | /// <returns>The result of the multiplication.</returns> |
| | 2154 | | public Angle<T> Add(T b) |
| | 2155 | | { |
| | 2156 | | return this * b; |
| | 2157 | | } |
| | 2158 | |
|
| | 2159 | | #endregion |
| | 2160 | |
|
| | 2161 | | #region Divide |
| | 2162 | |
|
| | 2163 | | /// <summary>Divides an Angle measurement by another Angle measurement resulting in a scalar numeric value.</summary |
| | 2164 | | /// <param name="a">The first operand of the division operation.</param> |
| | 2165 | | /// <param name="b">The second operand of the division operation.</param> |
| | 2166 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 2167 | | public static T Divide(Angle<T> a, Angle<T> b) |
| | 2168 | | { |
| | 2169 | | Angle.Units AngleUnits1 = a._AngleUnits1 <= b._AngleUnits1 ? a._AngleUnits1 : b._AngleUnits1; |
| | 2170 | | T A = a[AngleUnits1]; |
| | 2171 | | T B = b[AngleUnits1]; |
| | 2172 | | return Statics.Division(A, B); |
| | 2173 | | } |
| | 2174 | |
|
| | 2175 | | /// <summary>Divides this Angle measurement by a numaric scalar value.</summary> |
| | 2176 | | /// <param name="a">The Angle measurement to divide.</param> |
| | 2177 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 2178 | | /// <returns>The result of the division.</returns> |
| | 2179 | | public static Angle<T> Divide(Angle<T> a, T b) |
| | 2180 | | { |
| | 2181 | | return MathBase(a, b, Statics.Division); |
| | 2182 | | } |
| | 2183 | |
|
| | 2184 | | /// <summary>Divides this Angle measurement by a numaric scalar value.</summary> |
| | 2185 | | /// <param name="a">The Angle measurement to divide.</param> |
| | 2186 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 2187 | | /// <returns>The result of the division.</returns> |
| | 2188 | | public static Angle<T> operator /(Angle<T> a, T b) |
| | 2189 | | { |
| | 2190 | | return Divide(a, b); |
| | 2191 | | } |
| | 2192 | |
|
| | 2193 | | /// <summary>Divides this Angle measurement by a numaric scalar value.</summary> |
| | 2194 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 2195 | | /// <returns>The result of the division.</returns> |
| | 2196 | | public Angle<T> Divide(T b) |
| | 2197 | | { |
| | 2198 | | return this / b; |
| | 2199 | | } |
| | 2200 | |
|
| | 2201 | | /// <summary>Divides an Angle measurement by another Angle measurement resulting in a scalar numeric value.</summary |
| | 2202 | | /// <param name="a">The first operand of the division operation.</param> |
| | 2203 | | /// <param name="b">The second operand of the division operation.</param> |
| | 2204 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 2205 | | public static T operator /(Angle<T> a, Angle<T> b) |
| | 2206 | | { |
| | 2207 | | return Divide(a, b); |
| | 2208 | | } |
| | 2209 | |
|
| | 2210 | | /// <summary>Divides an Angle measurement by another Angle measurement resulting in a scalar numeric value.</summary |
| | 2211 | | /// <param name="b">The second operand of the division operation.</param> |
| | 2212 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 2213 | | public T Divide(Angle<T> b) |
| | 2214 | | { |
| | 2215 | | return this / b; |
| | 2216 | | } |
| | 2217 | |
|
| | 2218 | |
|
| | 2219 | | #region Angle<T> / AngularAcceleration<T> = TimeArea<T> |
| | 2220 | |
|
| | 2221 | | /// <summary>Divides Angle by AngularAcceleration resulting in TimeArea.</summary> |
| | 2222 | | /// <param name="a">The Angle to be divided.</param> |
| | 2223 | | /// <param name="b">The AngularAcceleration to divide by.</param> |
| | 2224 | | /// <returns>The TimeArea result of the division.</returns> |
| | 2225 | | public static TimeArea<T> Divide(Angle<T> a, AngularAcceleration<T> b) |
| | 2226 | | { |
| | 2227 | | Angle.Units AngleUnits1 = a._AngleUnits1 <= b._AngleUnits1 ? a._AngleUnits1 : b._AngleUnits1; |
| | 2228 | |
|
| | 2229 | | T A = a[AngleUnits1]; |
| | 2230 | | T B = b[AngleUnits1, b._TimeUnits2, b._TimeUnits3]; |
| | 2231 | | T C = Statics.Division(A, B); |
| | 2232 | |
|
| | 2233 | | return new TimeArea<T>(C |
| | 2234 | | , b._TimeUnits2 |
| | 2235 | | , b._TimeUnits3 |
| | 2236 | | ); |
| | 2237 | | } |
| | 2238 | |
|
| | 2239 | | /// <summary>Divides Angle by AngularAcceleration resulting in TimeArea.</summary> |
| | 2240 | | /// <param name="a">The Angle to be divided.</param> |
| | 2241 | | /// <param name="b">The AngularAcceleration to divide by.</param> |
| | 2242 | | /// <returns>The TimeArea result of the division.</returns> |
| | 2243 | | public static TimeArea<T> operator /(Angle<T> a, AngularAcceleration<T> b) |
| | 2244 | | { |
| | 2245 | | return Divide(a, b); |
| | 2246 | | } |
| | 2247 | |
|
| | 2248 | | /// <summary>Divides Angle by AngularAcceleration resulting in TimeArea.</summary> |
| | 2249 | | /// <param name="b">The AngularAcceleration to divide by.</param> |
| | 2250 | | /// <returns>The TimeArea result of the division.</returns> |
| | 2251 | | public TimeArea<T> Divide(AngularAcceleration<T> b) |
| | 2252 | | { |
| | 2253 | | return this / b; |
| | 2254 | | } |
| | 2255 | |
|
| | 2256 | | #endregion |
| | 2257 | |
|
| | 2258 | |
|
| | 2259 | | #region Angle<T> / AngularSpeed<T> = Time<T> |
| | 2260 | |
|
| | 2261 | | /// <summary>Divides Angle by AngularSpeed resulting in Time.</summary> |
| | 2262 | | /// <param name="a">The Angle to be divided.</param> |
| | 2263 | | /// <param name="b">The AngularSpeed to divide by.</param> |
| | 2264 | | /// <returns>The Time result of the division.</returns> |
| | 2265 | | public static Time<T> Divide(Angle<T> a, AngularSpeed<T> b) |
| | 2266 | | { |
| | 2267 | | Angle.Units AngleUnits1 = a._AngleUnits1 <= b._AngleUnits1 ? a._AngleUnits1 : b._AngleUnits1; |
| | 2268 | |
|
| | 2269 | | T A = a[AngleUnits1]; |
| | 2270 | | T B = b[AngleUnits1, b._TimeUnits2]; |
| | 2271 | | T C = Statics.Division(A, B); |
| | 2272 | |
|
| | 2273 | | return new Time<T>(C |
| | 2274 | | , b._TimeUnits2 |
| | 2275 | | ); |
| | 2276 | | } |
| | 2277 | |
|
| | 2278 | | /// <summary>Divides Angle by AngularSpeed resulting in Time.</summary> |
| | 2279 | | /// <param name="a">The Angle to be divided.</param> |
| | 2280 | | /// <param name="b">The AngularSpeed to divide by.</param> |
| | 2281 | | /// <returns>The Time result of the division.</returns> |
| | 2282 | | public static Time<T> operator /(Angle<T> a, AngularSpeed<T> b) |
| | 2283 | | { |
| | 2284 | | return Divide(a, b); |
| | 2285 | | } |
| | 2286 | |
|
| | 2287 | | /// <summary>Divides Angle by AngularSpeed resulting in Time.</summary> |
| | 2288 | | /// <param name="b">The AngularSpeed to divide by.</param> |
| | 2289 | | /// <returns>The Time result of the division.</returns> |
| | 2290 | | public Time<T> Divide(AngularSpeed<T> b) |
| | 2291 | | { |
| | 2292 | | return this / b; |
| | 2293 | | } |
| | 2294 | |
|
| | 2295 | | #endregion |
| | 2296 | |
|
| | 2297 | |
|
| | 2298 | | #region Angle<T> / Time<T> = AngularSpeed<T> |
| | 2299 | |
|
| | 2300 | | /// <summary>Divides Angle by Time resulting in AngularSpeed.</summary> |
| | 2301 | | /// <param name="a">The Angle to be divided.</param> |
| | 2302 | | /// <param name="b">The Time to divide by.</param> |
| | 2303 | | /// <returns>The AngularSpeed result of the division.</returns> |
| | 2304 | | public static AngularSpeed<T> Divide(Angle<T> a, Time<T> b) |
| | 2305 | | { |
| | 2306 | |
|
| | 2307 | | T A = a[a._AngleUnits1]; |
| | 2308 | | T B = b[b._TimeUnits1]; |
| | 2309 | | T C = Statics.Division(A, B); |
| | 2310 | |
|
| | 2311 | | return new AngularSpeed<T>(C |
| | 2312 | | , a._AngleUnits1 |
| | 2313 | | , b._TimeUnits1 |
| | 2314 | | ); |
| | 2315 | | } |
| | 2316 | |
|
| | 2317 | | /// <summary>Divides Angle by Time resulting in AngularSpeed.</summary> |
| | 2318 | | /// <param name="a">The Angle to be divided.</param> |
| | 2319 | | /// <param name="b">The Time to divide by.</param> |
| | 2320 | | /// <returns>The AngularSpeed result of the division.</returns> |
| | 2321 | | public static AngularSpeed<T> operator /(Angle<T> a, Time<T> b) |
| | 2322 | | { |
| | 2323 | | return Divide(a, b); |
| | 2324 | | } |
| | 2325 | |
|
| | 2326 | | /// <summary>Divides Angle by Time resulting in AngularSpeed.</summary> |
| | 2327 | | /// <param name="b">The Time to divide by.</param> |
| | 2328 | | /// <returns>The AngularSpeed result of the division.</returns> |
| | 2329 | | public AngularSpeed<T> Divide(Time<T> b) |
| | 2330 | | { |
| | 2331 | | return this / b; |
| | 2332 | | } |
| | 2333 | |
|
| | 2334 | | #endregion |
| | 2335 | |
|
| | 2336 | |
|
| | 2337 | | #region Angle<T> / TimeArea<T> = AngularAcceleration<T> |
| | 2338 | |
|
| | 2339 | | /// <summary>Divides Angle by TimeArea resulting in AngularAcceleration.</summary> |
| | 2340 | | /// <param name="a">The Angle to be divided.</param> |
| | 2341 | | /// <param name="b">The TimeArea to divide by.</param> |
| | 2342 | | /// <returns>The AngularAcceleration result of the division.</returns> |
| | 2343 | | public static AngularAcceleration<T> Divide(Angle<T> a, TimeArea<T> b) |
| | 2344 | | { |
| | 2345 | |
|
| | 2346 | | T A = a[a._AngleUnits1]; |
| | 2347 | | T B = b[b._TimeUnits1, b._TimeUnits2]; |
| | 2348 | | T C = Statics.Division(A, B); |
| | 2349 | |
|
| | 2350 | | return new AngularAcceleration<T>(C |
| | 2351 | | , a._AngleUnits1 |
| | 2352 | | , b._TimeUnits1 |
| | 2353 | | , b._TimeUnits2 |
| | 2354 | | ); |
| | 2355 | | } |
| | 2356 | |
|
| | 2357 | | /// <summary>Divides Angle by TimeArea resulting in AngularAcceleration.</summary> |
| | 2358 | | /// <param name="a">The Angle to be divided.</param> |
| | 2359 | | /// <param name="b">The TimeArea to divide by.</param> |
| | 2360 | | /// <returns>The AngularAcceleration result of the division.</returns> |
| | 2361 | | public static AngularAcceleration<T> operator /(Angle<T> a, TimeArea<T> b) |
| | 2362 | | { |
| | 2363 | | return Divide(a, b); |
| | 2364 | | } |
| | 2365 | |
|
| | 2366 | | /// <summary>Divides Angle by TimeArea resulting in AngularAcceleration.</summary> |
| | 2367 | | /// <param name="b">The TimeArea to divide by.</param> |
| | 2368 | | /// <returns>The AngularAcceleration result of the division.</returns> |
| | 2369 | | public AngularAcceleration<T> Divide(TimeArea<T> b) |
| | 2370 | | { |
| | 2371 | | return this / b; |
| | 2372 | | } |
| | 2373 | |
|
| | 2374 | | #endregion |
| | 2375 | |
|
| | 2376 | | #endregion |
| | 2377 | |
|
| | 2378 | | #region LessThan |
| | 2379 | |
|
| | 2380 | | /// <summary>Determines if an Angle measurement is less than another Angle measurement.</summary> |
| | 2381 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 2382 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 2383 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 2384 | | public static bool LessThan(Angle<T> a, Angle<T> b) |
| | 2385 | | { |
| | 2386 | | return LogicBase(a, b, Statics.LessThan); |
| | 2387 | | } |
| | 2388 | |
|
| | 2389 | | /// <summary>Determines if an Angle measurement is less than another Angle measurement.</summary> |
| | 2390 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 2391 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 2392 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 2393 | | public static bool operator <(Angle<T> a, Angle<T> b) |
| | 2394 | | { |
| | 2395 | | return LessThan(a, b); |
| | 2396 | | } |
| | 2397 | |
|
| | 2398 | | /// <summary>Determines if an Angle measurement is less than another Angle measurement.</summary> |
| | 2399 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 2400 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 2401 | | public bool LessThan(Angle<T> b) |
| | 2402 | | { |
| | 2403 | | return this < b; |
| | 2404 | | } |
| | 2405 | |
|
| | 2406 | | #endregion |
| | 2407 | |
|
| | 2408 | | #region GreaterThan |
| | 2409 | |
|
| | 2410 | | /// <summary>Determines if an Angle measurement is greater than another Angle measurement.</summary> |
| | 2411 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 2412 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 2413 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 2414 | | public static bool GreaterThan(Angle<T> a, Angle<T> b) |
| | 2415 | | { |
| | 2416 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 2417 | | } |
| | 2418 | |
|
| | 2419 | | /// <summary>Determines if an Angle measurement is greater than another Angle measurement.</summary> |
| | 2420 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 2421 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 2422 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 2423 | | public static bool operator >(Angle<T> a, Angle<T> b) |
| | 2424 | | { |
| | 2425 | | return GreaterThan(a, b); |
| | 2426 | | } |
| | 2427 | |
|
| | 2428 | | /// <summary>Determines if an Angle measurement is greater than another Angle measurement.</summary> |
| | 2429 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 2430 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 2431 | | public bool GreaterThan(Angle<T> b) |
| | 2432 | | { |
| | 2433 | | return this > b; |
| | 2434 | | } |
| | 2435 | |
|
| | 2436 | | #endregion |
| | 2437 | |
|
| | 2438 | | #region LessThanOrEqual |
| | 2439 | |
|
| | 2440 | | /// <summary>Determines if an Angle measurement is less than or equal to another Angle measurement.</summary> |
| | 2441 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 2442 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 2443 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 2444 | | public static bool LessThanOrEqual(Angle<T> a, Angle<T> b) |
| | 2445 | | { |
| | 2446 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 2447 | | } |
| | 2448 | |
|
| | 2449 | | /// <summary>Determines if an Angle measurement is less than or equal to another Angle measurement.</summary> |
| | 2450 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 2451 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 2452 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 2453 | | public static bool operator <=(Angle<T> a, Angle<T> b) |
| | 2454 | | { |
| | 2455 | | return LessThanOrEqual(a, b); |
| | 2456 | | } |
| | 2457 | |
|
| | 2458 | | /// <summary>Determines if an Angle measurement is less than or equal to another Angle measurement.</summary> |
| | 2459 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 2460 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 2461 | | public bool LessThanOrEqual(Angle<T> b) |
| | 2462 | | { |
| | 2463 | | return this <= b; |
| | 2464 | | } |
| | 2465 | |
|
| | 2466 | | #endregion |
| | 2467 | |
|
| | 2468 | | #region GreaterThanOrEqual |
| | 2469 | |
|
| | 2470 | | /// <summary>Determines if an Angle measurement is greater than or equal to another Angle measurement.</summary> |
| | 2471 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 2472 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 2473 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 2474 | | public static bool GreaterThanOrEqual(Angle<T> a, Angle<T> b) |
| | 2475 | | { |
| | 2476 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 2477 | | } |
| | 2478 | |
|
| | 2479 | | /// <summary>Determines if an Angle measurement is greater than or equal to another Angle measurement.</summary> |
| | 2480 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 2481 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 2482 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 2483 | | public static bool operator >=(Angle<T> a, Angle<T> b) |
| | 2484 | | { |
| | 2485 | | return GreaterThanOrEqual(a, b); |
| | 2486 | | } |
| | 2487 | |
|
| | 2488 | | /// <summary>Determines if an Angle measurement is greater than or equal to another Angle measurement.</summary> |
| | 2489 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 2490 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 2491 | | public bool GreaterThanOrEqual(Angle<T> b) |
| | 2492 | | { |
| | 2493 | | return this >= b; |
| | 2494 | | } |
| | 2495 | |
|
| | 2496 | | #endregion |
| | 2497 | |
|
| | 2498 | | #region Equal |
| | 2499 | |
|
| | 2500 | | /// <summary>Determines if an Angle measurement is equal to another Angle measurement.</summary> |
| | 2501 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 2502 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 2503 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 2504 | | public static bool Equal(Angle<T> a, Angle<T> b) |
| | 2505 | | { |
| | 2506 | | return LogicBase(a, b, Statics.Equate); |
| | 2507 | | } |
| | 2508 | |
|
| | 2509 | | /// <summary>Determines if an Angle measurement is equal to another Angle measurement.</summary> |
| | 2510 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 2511 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 2512 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 2513 | | public static bool operator ==(Angle<T> a, Angle<T> b) |
| | 2514 | | { |
| | 2515 | | return Equal(a, b); |
| | 2516 | | } |
| | 2517 | |
|
| | 2518 | | /// <summary>Determines if an Angle measurement is equal to another Angle measurement.</summary> |
| | 2519 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 2520 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 2521 | | public bool Equal(Angle<T> b) |
| | 2522 | | { |
| | 2523 | | return this == b; |
| | 2524 | | } |
| | 2525 | |
|
| | 2526 | | #endregion |
| | 2527 | |
|
| | 2528 | | #region NotEqual |
| | 2529 | |
|
| | 2530 | | /// <summary>Determines if an Angle measurement is not equal to another Angle measurement.</summary> |
| | 2531 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 2532 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 2533 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 2534 | | public static bool NotEqual(Angle<T> a, Angle<T> b) |
| | 2535 | | { |
| | 2536 | | return LogicBase(a, b, Statics.Inequate); |
| | 2537 | | } |
| | 2538 | |
|
| | 2539 | | /// <summary>Determines if an Angle measurement is not equal to another Angle measurement.</summary> |
| | 2540 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 2541 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 2542 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 2543 | | public static bool operator !=(Angle<T> a, Angle<T> b) |
| | 2544 | | { |
| | 2545 | | return NotEqual(a, b); |
| | 2546 | | } |
| | 2547 | |
|
| | 2548 | | /// <summary>Determines if an Angle measurement is not equal to another Angle measurement.</summary> |
| | 2549 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 2550 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 2551 | | public bool NotEqual(Angle<T> b) |
| | 2552 | | { |
| | 2553 | | return this != b; |
| | 2554 | | } |
| | 2555 | |
|
| | 2556 | | #endregion |
| | 2557 | |
|
| | 2558 | | #endregion |
| | 2559 | |
|
| | 2560 | | #region Overrides |
| | 2561 | |
|
| | 2562 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 2563 | | /// <param name="obj">The object to check for equality with.</param> |
| | 2564 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 2565 | | public override bool Equals(object obj) |
| | 2566 | | { |
| | 2567 | | if (obj is Angle<T>) |
| | 2568 | | { |
| | 2569 | | return this == (Angle<T>)obj; |
| | 2570 | | } |
| | 2571 | | return false; |
| | 2572 | | } |
| | 2573 | |
|
| | 2574 | | /// <summary>Converts the Angle measurement to a string represenation.</summary> |
| | 2575 | | /// <returns>The string representation of the measurement.</returns> |
| | 2576 | | public override string ToString() |
| | 2577 | | { |
| | 2578 | | return _measurement + " " + |
| | 2579 | | _AngleUnits1 |
| | 2580 | |
|
| | 2581 | | ; |
| | 2582 | | } |
| | 2583 | |
|
| | 2584 | | /// <summary>Base hashing function for Angle measurements.</summary> |
| | 2585 | | /// <returns>Computed hash code for this instance.</returns> |
| | 2586 | | public override int GetHashCode() => Hash(_measurement); |
| | 2587 | |
|
| | 2588 | | #endregion |
| | 2589 | | } |
| | 2590 | |
|
| | 2591 | | #endregion |
| | 2592 | |
|
| | 2593 | | #region AngularSpeed |
| | 2594 | |
|
| | 2595 | | internal static partial class ParsingFunctions |
| | 2596 | | { |
| | 2597 | | [Measurement.Parseable("Angle/Time")] |
| | 2598 | | public static object AngularSpeed<T>(T value, object[] units) |
| | 2599 | | { |
| | 2600 | | if (units.Length != 2) |
| | 2601 | | { |
| | 2602 | | throw new Exception("Bug in Towel. Invalid parameters to AngularSpeed Factory."); |
| | 2603 | | } |
| | 2604 | | if (!(units[0] is Angle.Units)) |
| | 2605 | | { |
| | 2606 | | throw new Exception("Bug in Towel. Invalid parameters to AngularSpeed Factory."); |
| | 2607 | | } |
| | 2608 | | if (!(units[1] is Time.Units)) |
| | 2609 | | { |
| | 2610 | | throw new Exception("Bug in Towel. Invalid parameters to AngularSpeed Factory."); |
| | 2611 | | } |
| | 2612 | | return new AngularSpeed<T>(value |
| | 2613 | | , (Angle.Units)units[0] |
| | 2614 | | , (Time.Units)units[1] |
| | 2615 | | ); |
| | 2616 | | } |
| | 2617 | | } |
| | 2618 | |
|
| | 2619 | | /// <summary>AngularSpeed measurement with a value and the units.</summary> |
| | 2620 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 2621 | | public struct AngularSpeed<T> |
| | 2622 | | { |
| | 2623 | | internal T _measurement; |
| | 2624 | | internal Angle.Units _AngleUnits1; |
| | 2625 | | internal Time.Units _TimeUnits2; |
| | 2626 | |
|
| | 2627 | | #region Statics |
| | 2628 | |
|
| | 2629 | | /// <summary>Converts a AngularSpeed measurement from units to another.</summary> |
| | 2630 | | /// <param name="value">The value to convert the units of.</param> |
| | 2631 | | /// <param name="fromAngleUnits1">The current units of the measurement.</param> |
| | 2632 | | /// <param name="fromTimeUnits2">The current units of the measurement.</param> |
| | 2633 | | /// <param name="toAngleUnits1">The desired units of the measurement.</param> |
| | 2634 | | /// <param name="toTimeUnits2">The desired units of the measurement.</param> |
| | 2635 | | /// <returns>The AngularSpeed measurement converted into the desired units.</returns> |
| | 2636 | | public static T Convert(T value |
| | 2637 | | , Angle.Units fromAngleUnits1 |
| | 2638 | | , Time.Units fromTimeUnits2 |
| | 2639 | | , Angle.Units toAngleUnits1 |
| | 2640 | | , Time.Units toTimeUnits2 |
| | 2641 | | ) |
| | 2642 | | { |
| | 2643 | | AngularSpeed<T> measurement = new AngularSpeed<T>(value |
| | 2644 | | , fromAngleUnits1 |
| | 2645 | | , fromTimeUnits2 |
| | 2646 | | ); |
| | 2647 | | return measurement[ |
| | 2648 | | toAngleUnits1 |
| | 2649 | | , toTimeUnits2 |
| | 2650 | | ]; |
| | 2651 | | } |
| | 2652 | |
|
| | 2653 | | /// <summary>Converts a AngularSpeed measurement from units to another.</summary> |
| | 2654 | | /// <param name="value">The value to convert the units of.</param> |
| | 2655 | | /// <param name="from">The current units of the measurement.</param> |
| | 2656 | | /// <param name="to">The desired units of the measurement.</param> |
| | 2657 | | /// <returns>The AngularSpeed measurement converted into the desired units.</returns> |
| | 2658 | | public static T Convert(T value, |
| | 2659 | | MeasurementUnitsSyntaxTypes.AngularSpeedBaseUnits from, |
| | 2660 | | MeasurementUnitsSyntaxTypes.AngularSpeedBaseUnits to) |
| | 2661 | | { |
| | 2662 | | return Convert(value |
| | 2663 | | , from._AngleUnits1 |
| | 2664 | | , from._TimeUnits2 |
| | 2665 | | , to._AngleUnits1 |
| | 2666 | | , to._TimeUnits2 |
| | 2667 | | ); |
| | 2668 | | } |
| | 2669 | |
|
| | 2670 | | /// <summary>Parses a AngularSpeed measurement string.</summary> |
| | 2671 | | /// <param name="string">The string to be parsed.</param> |
| | 2672 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 2673 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 2674 | | public static (bool Success, AngularSpeed<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value)> |
| | 2675 | |
|
| | 2676 | | #endregion |
| | 2677 | |
|
| | 2678 | | #region Constructors |
| | 2679 | |
|
| | 2680 | | /// <summary>Constructs an AngularSpeed with the measurement value and units.</summary> |
| | 2681 | | /// <param name="measurement">The measurement value of the AngularSpeed.</param> |
| | 2682 | | /// <param name="units">The units of the AngularSpeed.</param> |
| | 2683 | | public AngularSpeed(T measurement, MeasurementUnitsSyntaxTypes.AngularSpeedBaseUnits units) : this(measurement |
| | 2684 | | , units._AngleUnits1 |
| | 2685 | | , units._TimeUnits2 |
| | 2686 | | ) { } |
| | 2687 | |
|
| | 2688 | |
|
| | 2689 | | /// <summary>Constructs an AngularSpeed with the measurement value and units.</summary> |
| | 2690 | | /// <param name="measurement">The measurement value of the AngularSpeed.</param> |
| | 2691 | | /// <param name="AngleUnits1">The units of the AngularSpeed.</param> |
| | 2692 | | /// <param name="TimeUnits2">The units of the AngularSpeed.</param> |
| | 2693 | | public AngularSpeed(T measurement |
| | 2694 | | , Angle.Units AngleUnits1 |
| | 2695 | | , Time.Units TimeUnits2 |
| | 2696 | | ) |
| | 2697 | | { |
| | 2698 | | _measurement = measurement; |
| | 2699 | | _AngleUnits1 = AngleUnits1; |
| | 2700 | | _TimeUnits2 = TimeUnits2; |
| | 2701 | | } |
| | 2702 | |
|
| | 2703 | | #endregion |
| | 2704 | |
|
| | 2705 | | #region Properties |
| | 2706 | |
|
| | 2707 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 2708 | | public Angle.Units AngleUnits1 |
| | 2709 | | { |
| | 2710 | | get { return _AngleUnits1; } |
| | 2711 | | set |
| | 2712 | | { |
| | 2713 | | if (value != _AngleUnits1) |
| | 2714 | | { |
| | 2715 | | _measurement = this[value, _TimeUnits2]; |
| | 2716 | | _AngleUnits1 = value; |
| | 2717 | | } |
| | 2718 | | } |
| | 2719 | | } |
| | 2720 | |
|
| | 2721 | | /// <summary>The #2 component of this measurements units.</summary> |
| | 2722 | | public Time.Units TimeUnits2 |
| | 2723 | | { |
| | 2724 | | get { return _TimeUnits2; } |
| | 2725 | | set |
| | 2726 | | { |
| | 2727 | | if (value != _TimeUnits2) |
| | 2728 | | { |
| | 2729 | | _measurement = this[_AngleUnits1, value]; |
| | 2730 | | _TimeUnits2 = value; |
| | 2731 | | } |
| | 2732 | | } |
| | 2733 | | } |
| | 2734 | |
|
| | 2735 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 2736 | | /// <param name="units">The units to get the measurement in.</param> |
| | 2737 | | /// <returns>The measurement value in the specified units.</returns> |
| | 2738 | | public T this[MeasurementUnitsSyntaxTypes.AngularSpeedBaseUnits units] |
| | 2739 | | { |
| | 2740 | | get { return this[units._AngleUnits1, units._TimeUnits2]; } |
| | 2741 | | } |
| | 2742 | |
|
| | 2743 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 2744 | | /// <param name="AngleUnits1">The #1 component of this measurements units.</param> |
| | 2745 | | /// <param name="TimeUnits2">The #2 component of this measurements units.</param> |
| | 2746 | | /// <returns>The measurement value in the specified units.</returns> |
| | 2747 | | public T this[Angle.Units AngleUnits1, Time.Units TimeUnits2] |
| | 2748 | | { |
| | 2749 | | get |
| | 2750 | | { |
| | 2751 | | T measurement = _measurement; |
| | 2752 | | if (AngleUnits1 != _AngleUnits1) |
| | 2753 | | { |
| | 2754 | | measurement = Angle<T>.Table[(int)_AngleUnits1][(int)AngleUnits1](measurement); |
| | 2755 | | //if (AngleUnits1 < _AngleUnits1) |
| | 2756 | | //{ |
| | 2757 | | // measurement = Angle<T>.Table[(int)_AngleUnits1][(int)AngleUnits1](measurement); |
| | 2758 | | //} |
| | 2759 | | //else |
| | 2760 | | //{ |
| | 2761 | | // measurement = Angle<T>.Table[(int)AngleUnits1][(int)_AngleUnits1](measurement); |
| | 2762 | | //} |
| | 2763 | | } |
| | 2764 | | if (TimeUnits2 != _TimeUnits2) |
| | 2765 | | { |
| | 2766 | | measurement = Time<T>.Table[(int)TimeUnits2][(int)_TimeUnits2](measurement); |
| | 2767 | | //if (TimeUnits2 > _TimeUnits2) |
| | 2768 | | //{ |
| | 2769 | | // measurement = Time<T>.Table[(int)_TimeUnits2][(int)TimeUnits2](measurement); |
| | 2770 | | //} |
| | 2771 | | //else |
| | 2772 | | //{ |
| | 2773 | | // measurement = Time<T>.Table[(int)TimeUnits2][(int)_TimeUnits2](measurement); |
| | 2774 | | //} |
| | 2775 | | } |
| | 2776 | | return measurement; |
| | 2777 | | } |
| | 2778 | | } |
| | 2779 | |
|
| | 2780 | | #endregion |
| | 2781 | |
|
| | 2782 | | #region Casting Operators |
| | 2783 | |
|
| | 2784 | | /// <summary>Converts a ValueTuple to a AngularSpeed measurement.</summary> |
| | 2785 | | /// <param name="valueTuple">The ValueTuple to converted into a AngularSpeed measurement.</param> |
| | 2786 | | public static implicit operator AngularSpeed<T>((T, MeasurementUnitsSyntaxTypes.AngularSpeedBaseUnits) valueTuple) |
| | 2787 | | { |
| | 2788 | | return new AngularSpeed<T>(valueTuple.Item1, valueTuple.Item2); |
| | 2789 | | } |
| | 2790 | |
|
| | 2791 | | #endregion |
| | 2792 | |
|
| | 2793 | | #region Mathematics |
| | 2794 | |
|
| | 2795 | | #region Bases |
| | 2796 | |
|
| | 2797 | | internal static AngularSpeed<T> MathBase(AngularSpeed<T> a, T b, Func<T, T, T> func) |
| | 2798 | | { |
| | 2799 | | return new AngularSpeed<T>(func(a._measurement, b) |
| | 2800 | | , a._AngleUnits1 |
| | 2801 | | , a._TimeUnits2 |
| | 2802 | | ); |
| | 2803 | | } |
| | 2804 | |
|
| | 2805 | | internal static AngularSpeed<T> MathBase(AngularSpeed<T> a, AngularSpeed<T> b, Func<T, T, T> func) |
| | 2806 | | { |
| | 2807 | | Angle.Units AngleUnits1 = a._AngleUnits1 <= b._AngleUnits1 ? a._AngleUnits1 : b._AngleUnits1; |
| | 2808 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 2809 | | T A = a[AngleUnits1, TimeUnits2]; |
| | 2810 | | T B = b[AngleUnits1, TimeUnits2]; |
| | 2811 | | T C = func(A, B); |
| | 2812 | | return new AngularSpeed<T>(C, AngleUnits1, TimeUnits2); |
| | 2813 | | } |
| | 2814 | |
|
| | 2815 | | internal static bool LogicBase(AngularSpeed<T> a, AngularSpeed<T> b, Func<T, T, bool> func) |
| | 2816 | | { |
| | 2817 | | Angle.Units AngleUnits1 = a._AngleUnits1 <= b._AngleUnits1 ? a._AngleUnits1 : b._AngleUnits1; |
| | 2818 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 2819 | | T A = a[AngleUnits1, TimeUnits2]; |
| | 2820 | | T B = b[AngleUnits1, TimeUnits2]; |
| | 2821 | | return func(A, B); |
| | 2822 | | } |
| | 2823 | |
|
| | 2824 | | #endregion |
| | 2825 | |
|
| | 2826 | | #region Add |
| | 2827 | |
|
| | 2828 | | /// <summary>Adds two AngularSpeed measurements.</summary> |
| | 2829 | | /// <param name="a">The first operand of the addition.</param> |
| | 2830 | | /// <param name="b">The second operand of the addition.</param> |
| | 2831 | | /// <returns>The result of the addition operation.</returns> |
| | 2832 | | public static AngularSpeed<T> Add(AngularSpeed<T> a, AngularSpeed<T> b) |
| | 2833 | | { |
| | 2834 | | return MathBase(a, b, Statics.Addition); |
| | 2835 | | } |
| | 2836 | |
|
| | 2837 | | /// <summary>Adds two AngularSpeed measurements.</summary> |
| | 2838 | | /// <param name="a">The first operand of the addition.</param> |
| | 2839 | | /// <param name="b">The second operand of the addition.</param> |
| | 2840 | | /// <returns>The result of the addition operation.</returns> |
| | 2841 | | public static AngularSpeed<T> operator +(AngularSpeed<T> a, AngularSpeed<T> b) |
| | 2842 | | { |
| | 2843 | | return Add(a, b); |
| | 2844 | | } |
| | 2845 | |
|
| | 2846 | | /// <summary>Adds two AngularSpeed measurements.</summary> |
| | 2847 | | /// <param name="b">The second operand of the addition.</param> |
| | 2848 | | /// <returns>The result of the addition operation.</returns> |
| | 2849 | | public AngularSpeed<T> Add(AngularSpeed<T> b) |
| | 2850 | | { |
| | 2851 | | return this + b; |
| | 2852 | | } |
| | 2853 | |
|
| | 2854 | | #endregion |
| | 2855 | |
|
| | 2856 | | #region Subtract |
| | 2857 | |
|
| | 2858 | | /// <summary>Subtracts two AngularSpeed measurements.</summary> |
| | 2859 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 2860 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 2861 | | /// <returns>The result of the subtraction.</returns> |
| | 2862 | | public static AngularSpeed<T> Subtract(AngularSpeed<T> a, AngularSpeed<T> b) |
| | 2863 | | { |
| | 2864 | | return MathBase(a, b, Statics.Subtraction); |
| | 2865 | | } |
| | 2866 | |
|
| | 2867 | | /// <summary>Subtracts two AngularSpeed measurements.</summary> |
| | 2868 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 2869 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 2870 | | /// <returns>The result of the subtraction.</returns> |
| | 2871 | | public static AngularSpeed<T> operator -(AngularSpeed<T> a, AngularSpeed<T> b) |
| | 2872 | | { |
| | 2873 | | return Subtract(a, b); |
| | 2874 | | } |
| | 2875 | |
|
| | 2876 | | /// <summary>Subtracts two AngularSpeed measurements.</summary> |
| | 2877 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 2878 | | /// <returns>The result of the subtraction.</returns> |
| | 2879 | | public AngularSpeed<T> Subtract(AngularSpeed<T> b) |
| | 2880 | | { |
| | 2881 | | return this - b; |
| | 2882 | | } |
| | 2883 | |
|
| | 2884 | | #endregion |
| | 2885 | |
|
| | 2886 | | #region Multiply |
| | 2887 | |
|
| | 2888 | | /// <summary>Multiplies an AngularSpeed by a scalar numeric value.</summary> |
| | 2889 | | /// <param name="a">The AngularSpeed measurement to multiply.</param> |
| | 2890 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 2891 | | /// <returns>The result of the multiplication.</returns> |
| | 2892 | | public static AngularSpeed<T> Multiply(AngularSpeed<T> a, T b) |
| | 2893 | | { |
| | 2894 | | return MathBase(a, b, Statics.Multiplication); |
| | 2895 | | } |
| | 2896 | |
|
| | 2897 | | /// <summary>Multiplies an AngularSpeed by a scalar numeric value.</summary> |
| | 2898 | | /// <param name="a">The AngularSpeed measurement to multiply.</param> |
| | 2899 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 2900 | | /// <returns>The result of the multiplication.</returns> |
| | 2901 | | public static AngularSpeed<T> Multiply(T b, AngularSpeed<T> a) |
| | 2902 | | { |
| | 2903 | | return Multiply(a, b); |
| | 2904 | | } |
| | 2905 | |
|
| | 2906 | | /// <summary>Multiplies an AngularSpeed by a scalar numeric value.</summary> |
| | 2907 | | /// <param name="a">The AngularSpeed measurement to multiply.</param> |
| | 2908 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 2909 | | /// <returns>The result of the multiplication.</returns> |
| | 2910 | | public static AngularSpeed<T> operator *(AngularSpeed<T> a, T b) |
| | 2911 | | { |
| | 2912 | | return Multiply(a, b); |
| | 2913 | | } |
| | 2914 | |
|
| | 2915 | | /// <summary>Multiplies an AngularSpeed by a scalar numeric value.</summary> |
| | 2916 | | /// <param name="a">The AngularSpeed measurement to multiply.</param> |
| | 2917 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 2918 | | /// <returns>The result of the multiplication.</returns> |
| | 2919 | | public static AngularSpeed<T> operator *(T b, AngularSpeed<T> a) |
| | 2920 | | { |
| | 2921 | | return Multiply(b, a); |
| | 2922 | | } |
| | 2923 | |
|
| | 2924 | | /// <summary>Multiplies an AngularSpeed by a scalar numeric value.</summary> |
| | 2925 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 2926 | | /// <returns>The result of the multiplication.</returns> |
| | 2927 | | public AngularSpeed<T> Add(T b) |
| | 2928 | | { |
| | 2929 | | return this * b; |
| | 2930 | | } |
| | 2931 | |
|
| | 2932 | | #region AngularSpeed<T> * Time<T> = Angle<T> |
| | 2933 | |
|
| | 2934 | | /// <summary>Mulitplies AngularSpeed by Time resulting in Angle.</summary> |
| | 2935 | | /// <param name="a">The AngularSpeed to be multiplied.</param> |
| | 2936 | | /// <param name="b">The Time to multiply by.</param> |
| | 2937 | | /// <returns>The Angle result of the multiplication.</returns> |
| | 2938 | | public static Angle<T> Multiply(AngularSpeed<T> a, Time<T> b) |
| | 2939 | | { |
| | 2940 | | Time.Units TimeUnits1 = a._TimeUnits2 <= b._TimeUnits1 ? a._TimeUnits2 : b._TimeUnits1; |
| | 2941 | |
|
| | 2942 | | T A = a[a._AngleUnits1, TimeUnits1]; |
| | 2943 | | T B = b[TimeUnits1]; |
| | 2944 | | T C = Statics.Multiplication(A, B); |
| | 2945 | |
|
| | 2946 | | return new Angle<T>(C |
| | 2947 | | , a._AngleUnits1 |
| | 2948 | | ); |
| | 2949 | | } |
| | 2950 | |
|
| | 2951 | | /// <summary>Mulitplies AngularSpeed by Time resulting in Angle.</summary> |
| | 2952 | | /// <param name="a">The AngularSpeed to be multiplied.</param> |
| | 2953 | | /// <param name="b">The Time to multiply by.</param> |
| | 2954 | | /// <returns>The Angle result of the multiplication.</returns> |
| | 2955 | | public static Angle<T> operator *(AngularSpeed<T> a, Time<T> b) |
| | 2956 | | { |
| | 2957 | | return Multiply(a, b); |
| | 2958 | | } |
| | 2959 | |
|
| | 2960 | | /// <summary>Mulitplies AngularSpeed by Time resulting in Angle.</summary> |
| | 2961 | | /// <param name="b">The Time to multiply by.</param> |
| | 2962 | | /// <returns>The Angle result of the multiplication.</returns> |
| | 2963 | | public Angle<T> Multiply(Time<T> b) |
| | 2964 | | { |
| | 2965 | | return this * b; |
| | 2966 | | } |
| | 2967 | |
|
| | 2968 | | #endregion |
| | 2969 | |
|
| | 2970 | | #endregion |
| | 2971 | |
|
| | 2972 | | #region Divide |
| | 2973 | |
|
| | 2974 | | /// <summary>Divides an AngularSpeed measurement by another AngularSpeed measurement resulting in a scalar numeric v |
| | 2975 | | /// <param name="a">The first operand of the division operation.</param> |
| | 2976 | | /// <param name="b">The second operand of the division operation.</param> |
| | 2977 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 2978 | | public static T Divide(AngularSpeed<T> a, AngularSpeed<T> b) |
| | 2979 | | { |
| | 2980 | | Angle.Units AngleUnits1 = a._AngleUnits1 <= b._AngleUnits1 ? a._AngleUnits1 : b._AngleUnits1; |
| | 2981 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 2982 | | T A = a[AngleUnits1, TimeUnits2]; |
| | 2983 | | T B = b[AngleUnits1, TimeUnits2]; |
| | 2984 | | return Statics.Division(A, B); |
| | 2985 | | } |
| | 2986 | |
|
| | 2987 | | /// <summary>Divides this AngularSpeed measurement by a numaric scalar value.</summary> |
| | 2988 | | /// <param name="a">The AngularSpeed measurement to divide.</param> |
| | 2989 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 2990 | | /// <returns>The result of the division.</returns> |
| | 2991 | | public static AngularSpeed<T> Divide(AngularSpeed<T> a, T b) |
| | 2992 | | { |
| | 2993 | | return MathBase(a, b, Statics.Division); |
| | 2994 | | } |
| | 2995 | |
|
| | 2996 | | /// <summary>Divides this AngularSpeed measurement by a numaric scalar value.</summary> |
| | 2997 | | /// <param name="a">The AngularSpeed measurement to divide.</param> |
| | 2998 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 2999 | | /// <returns>The result of the division.</returns> |
| | 3000 | | public static AngularSpeed<T> operator /(AngularSpeed<T> a, T b) |
| | 3001 | | { |
| | 3002 | | return Divide(a, b); |
| | 3003 | | } |
| | 3004 | |
|
| | 3005 | | /// <summary>Divides this AngularSpeed measurement by a numaric scalar value.</summary> |
| | 3006 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 3007 | | /// <returns>The result of the division.</returns> |
| | 3008 | | public AngularSpeed<T> Divide(T b) |
| | 3009 | | { |
| | 3010 | | return this / b; |
| | 3011 | | } |
| | 3012 | |
|
| | 3013 | | /// <summary>Divides an AngularSpeed measurement by another AngularSpeed measurement resulting in a scalar numeric v |
| | 3014 | | /// <param name="a">The first operand of the division operation.</param> |
| | 3015 | | /// <param name="b">The second operand of the division operation.</param> |
| | 3016 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 3017 | | public static T operator /(AngularSpeed<T> a, AngularSpeed<T> b) |
| | 3018 | | { |
| | 3019 | | return Divide(a, b); |
| | 3020 | | } |
| | 3021 | |
|
| | 3022 | | /// <summary>Divides an AngularSpeed measurement by another AngularSpeed measurement resulting in a scalar numeric v |
| | 3023 | | /// <param name="b">The second operand of the division operation.</param> |
| | 3024 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 3025 | | public T Divide(AngularSpeed<T> b) |
| | 3026 | | { |
| | 3027 | | return this / b; |
| | 3028 | | } |
| | 3029 | |
|
| | 3030 | |
|
| | 3031 | | #region AngularSpeed<T> / AngularAcceleration<T> = Time<T> |
| | 3032 | |
|
| | 3033 | | /// <summary>Divides AngularSpeed by AngularAcceleration resulting in Time.</summary> |
| | 3034 | | /// <param name="a">The AngularSpeed to be divided.</param> |
| | 3035 | | /// <param name="b">The AngularAcceleration to divide by.</param> |
| | 3036 | | /// <returns>The Time result of the division.</returns> |
| | 3037 | | public static Time<T> Divide(AngularSpeed<T> a, AngularAcceleration<T> b) |
| | 3038 | | { |
| | 3039 | | Angle.Units AngleUnits1 = a._AngleUnits1 <= b._AngleUnits1 ? a._AngleUnits1 : b._AngleUnits1; |
| | 3040 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 3041 | |
|
| | 3042 | | T A = a[AngleUnits1, TimeUnits2]; |
| | 3043 | | T B = b[AngleUnits1, TimeUnits2, b._TimeUnits3]; |
| | 3044 | | T C = Statics.Division(A, B); |
| | 3045 | |
|
| | 3046 | | return new Time<T>(C |
| | 3047 | | , b._TimeUnits3 |
| | 3048 | | ); |
| | 3049 | | } |
| | 3050 | |
|
| | 3051 | | /// <summary>Divides AngularSpeed by AngularAcceleration resulting in Time.</summary> |
| | 3052 | | /// <param name="a">The AngularSpeed to be divided.</param> |
| | 3053 | | /// <param name="b">The AngularAcceleration to divide by.</param> |
| | 3054 | | /// <returns>The Time result of the division.</returns> |
| | 3055 | | public static Time<T> operator /(AngularSpeed<T> a, AngularAcceleration<T> b) |
| | 3056 | | { |
| | 3057 | | return Divide(a, b); |
| | 3058 | | } |
| | 3059 | |
|
| | 3060 | | /// <summary>Divides AngularSpeed by AngularAcceleration resulting in Time.</summary> |
| | 3061 | | /// <param name="b">The AngularAcceleration to divide by.</param> |
| | 3062 | | /// <returns>The Time result of the division.</returns> |
| | 3063 | | public Time<T> Divide(AngularAcceleration<T> b) |
| | 3064 | | { |
| | 3065 | | return this / b; |
| | 3066 | | } |
| | 3067 | |
|
| | 3068 | | #endregion |
| | 3069 | |
|
| | 3070 | |
|
| | 3071 | | #region AngularSpeed<T> / Time<T> = AngularAcceleration<T> |
| | 3072 | |
|
| | 3073 | | /// <summary>Divides AngularSpeed by Time resulting in AngularAcceleration.</summary> |
| | 3074 | | /// <param name="a">The AngularSpeed to be divided.</param> |
| | 3075 | | /// <param name="b">The Time to divide by.</param> |
| | 3076 | | /// <returns>The AngularAcceleration result of the division.</returns> |
| | 3077 | | public static AngularAcceleration<T> Divide(AngularSpeed<T> a, Time<T> b) |
| | 3078 | | { |
| | 3079 | |
|
| | 3080 | | T A = a[a._AngleUnits1, a._TimeUnits2]; |
| | 3081 | | T B = b[b._TimeUnits1]; |
| | 3082 | | T C = Statics.Division(A, B); |
| | 3083 | |
|
| | 3084 | | return new AngularAcceleration<T>(C |
| | 3085 | | , a._AngleUnits1 |
| | 3086 | | , a._TimeUnits2 |
| | 3087 | | , b._TimeUnits1 |
| | 3088 | | ); |
| | 3089 | | } |
| | 3090 | |
|
| | 3091 | | /// <summary>Divides AngularSpeed by Time resulting in AngularAcceleration.</summary> |
| | 3092 | | /// <param name="a">The AngularSpeed to be divided.</param> |
| | 3093 | | /// <param name="b">The Time to divide by.</param> |
| | 3094 | | /// <returns>The AngularAcceleration result of the division.</returns> |
| | 3095 | | public static AngularAcceleration<T> operator /(AngularSpeed<T> a, Time<T> b) |
| | 3096 | | { |
| | 3097 | | return Divide(a, b); |
| | 3098 | | } |
| | 3099 | |
|
| | 3100 | | /// <summary>Divides AngularSpeed by Time resulting in AngularAcceleration.</summary> |
| | 3101 | | /// <param name="b">The Time to divide by.</param> |
| | 3102 | | /// <returns>The AngularAcceleration result of the division.</returns> |
| | 3103 | | public AngularAcceleration<T> Divide(Time<T> b) |
| | 3104 | | { |
| | 3105 | | return this / b; |
| | 3106 | | } |
| | 3107 | |
|
| | 3108 | | #endregion |
| | 3109 | |
|
| | 3110 | | #endregion |
| | 3111 | |
|
| | 3112 | | #region LessThan |
| | 3113 | |
|
| | 3114 | | /// <summary>Determines if an AngularSpeed measurement is less than another AngularSpeed measurement.</summary> |
| | 3115 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 3116 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 3117 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 3118 | | public static bool LessThan(AngularSpeed<T> a, AngularSpeed<T> b) |
| | 3119 | | { |
| | 3120 | | return LogicBase(a, b, Statics.LessThan); |
| | 3121 | | } |
| | 3122 | |
|
| | 3123 | | /// <summary>Determines if an AngularSpeed measurement is less than another AngularSpeed measurement.</summary> |
| | 3124 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 3125 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 3126 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 3127 | | public static bool operator <(AngularSpeed<T> a, AngularSpeed<T> b) |
| | 3128 | | { |
| | 3129 | | return LessThan(a, b); |
| | 3130 | | } |
| | 3131 | |
|
| | 3132 | | /// <summary>Determines if an AngularSpeed measurement is less than another AngularSpeed measurement.</summary> |
| | 3133 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 3134 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 3135 | | public bool LessThan(AngularSpeed<T> b) |
| | 3136 | | { |
| | 3137 | | return this < b; |
| | 3138 | | } |
| | 3139 | |
|
| | 3140 | | #endregion |
| | 3141 | |
|
| | 3142 | | #region GreaterThan |
| | 3143 | |
|
| | 3144 | | /// <summary>Determines if an AngularSpeed measurement is greater than another AngularSpeed measurement.</summary> |
| | 3145 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 3146 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 3147 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 3148 | | public static bool GreaterThan(AngularSpeed<T> a, AngularSpeed<T> b) |
| | 3149 | | { |
| | 3150 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 3151 | | } |
| | 3152 | |
|
| | 3153 | | /// <summary>Determines if an AngularSpeed measurement is greater than another AngularSpeed measurement.</summary> |
| | 3154 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 3155 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 3156 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 3157 | | public static bool operator >(AngularSpeed<T> a, AngularSpeed<T> b) |
| | 3158 | | { |
| | 3159 | | return GreaterThan(a, b); |
| | 3160 | | } |
| | 3161 | |
|
| | 3162 | | /// <summary>Determines if an AngularSpeed measurement is greater than another AngularSpeed measurement.</summary> |
| | 3163 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 3164 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 3165 | | public bool GreaterThan(AngularSpeed<T> b) |
| | 3166 | | { |
| | 3167 | | return this > b; |
| | 3168 | | } |
| | 3169 | |
|
| | 3170 | | #endregion |
| | 3171 | |
|
| | 3172 | | #region LessThanOrEqual |
| | 3173 | |
|
| | 3174 | | /// <summary>Determines if an AngularSpeed measurement is less than or equal to another AngularSpeed measurement.</s |
| | 3175 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 3176 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 3177 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 3178 | | public static bool LessThanOrEqual(AngularSpeed<T> a, AngularSpeed<T> b) |
| | 3179 | | { |
| | 3180 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 3181 | | } |
| | 3182 | |
|
| | 3183 | | /// <summary>Determines if an AngularSpeed measurement is less than or equal to another AngularSpeed measurement.</s |
| | 3184 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 3185 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 3186 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 3187 | | public static bool operator <=(AngularSpeed<T> a, AngularSpeed<T> b) |
| | 3188 | | { |
| | 3189 | | return LessThanOrEqual(a, b); |
| | 3190 | | } |
| | 3191 | |
|
| | 3192 | | /// <summary>Determines if an AngularSpeed measurement is less than or equal to another AngularSpeed measurement.</s |
| | 3193 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 3194 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 3195 | | public bool LessThanOrEqual(AngularSpeed<T> b) |
| | 3196 | | { |
| | 3197 | | return this <= b; |
| | 3198 | | } |
| | 3199 | |
|
| | 3200 | | #endregion |
| | 3201 | |
|
| | 3202 | | #region GreaterThanOrEqual |
| | 3203 | |
|
| | 3204 | | /// <summary>Determines if an AngularSpeed measurement is greater than or equal to another AngularSpeed measurement. |
| | 3205 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 3206 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 3207 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 3208 | | public static bool GreaterThanOrEqual(AngularSpeed<T> a, AngularSpeed<T> b) |
| | 3209 | | { |
| | 3210 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 3211 | | } |
| | 3212 | |
|
| | 3213 | | /// <summary>Determines if an AngularSpeed measurement is greater than or equal to another AngularSpeed measurement. |
| | 3214 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 3215 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 3216 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 3217 | | public static bool operator >=(AngularSpeed<T> a, AngularSpeed<T> b) |
| | 3218 | | { |
| | 3219 | | return GreaterThanOrEqual(a, b); |
| | 3220 | | } |
| | 3221 | |
|
| | 3222 | | /// <summary>Determines if an AngularSpeed measurement is greater than or equal to another AngularSpeed measurement. |
| | 3223 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 3224 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 3225 | | public bool GreaterThanOrEqual(AngularSpeed<T> b) |
| | 3226 | | { |
| | 3227 | | return this >= b; |
| | 3228 | | } |
| | 3229 | |
|
| | 3230 | | #endregion |
| | 3231 | |
|
| | 3232 | | #region Equal |
| | 3233 | |
|
| | 3234 | | /// <summary>Determines if an AngularSpeed measurement is equal to another AngularSpeed measurement.</summary> |
| | 3235 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 3236 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 3237 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 3238 | | public static bool Equal(AngularSpeed<T> a, AngularSpeed<T> b) |
| | 3239 | | { |
| | 3240 | | return LogicBase(a, b, Statics.Equate); |
| | 3241 | | } |
| | 3242 | |
|
| | 3243 | | /// <summary>Determines if an AngularSpeed measurement is equal to another AngularSpeed measurement.</summary> |
| | 3244 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 3245 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 3246 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 3247 | | public static bool operator ==(AngularSpeed<T> a, AngularSpeed<T> b) |
| | 3248 | | { |
| | 3249 | | return Equal(a, b); |
| | 3250 | | } |
| | 3251 | |
|
| | 3252 | | /// <summary>Determines if an AngularSpeed measurement is equal to another AngularSpeed measurement.</summary> |
| | 3253 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 3254 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 3255 | | public bool Equal(AngularSpeed<T> b) |
| | 3256 | | { |
| | 3257 | | return this == b; |
| | 3258 | | } |
| | 3259 | |
|
| | 3260 | | #endregion |
| | 3261 | |
|
| | 3262 | | #region NotEqual |
| | 3263 | |
|
| | 3264 | | /// <summary>Determines if an AngularSpeed measurement is not equal to another AngularSpeed measurement.</summary> |
| | 3265 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 3266 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 3267 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 3268 | | public static bool NotEqual(AngularSpeed<T> a, AngularSpeed<T> b) |
| | 3269 | | { |
| | 3270 | | return LogicBase(a, b, Statics.Inequate); |
| | 3271 | | } |
| | 3272 | |
|
| | 3273 | | /// <summary>Determines if an AngularSpeed measurement is not equal to another AngularSpeed measurement.</summary> |
| | 3274 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 3275 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 3276 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 3277 | | public static bool operator !=(AngularSpeed<T> a, AngularSpeed<T> b) |
| | 3278 | | { |
| | 3279 | | return NotEqual(a, b); |
| | 3280 | | } |
| | 3281 | |
|
| | 3282 | | /// <summary>Determines if an AngularSpeed measurement is not equal to another AngularSpeed measurement.</summary> |
| | 3283 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 3284 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 3285 | | public bool NotEqual(AngularSpeed<T> b) |
| | 3286 | | { |
| | 3287 | | return this != b; |
| | 3288 | | } |
| | 3289 | |
|
| | 3290 | | #endregion |
| | 3291 | |
|
| | 3292 | | #endregion |
| | 3293 | |
|
| | 3294 | | #region Overrides |
| | 3295 | |
|
| | 3296 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 3297 | | /// <param name="obj">The object to check for equality with.</param> |
| | 3298 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 3299 | | public override bool Equals(object obj) |
| | 3300 | | { |
| | 3301 | | if (obj is AngularSpeed<T>) |
| | 3302 | | { |
| | 3303 | | return this == (AngularSpeed<T>)obj; |
| | 3304 | | } |
| | 3305 | | return false; |
| | 3306 | | } |
| | 3307 | |
|
| | 3308 | | /// <summary>Converts the AngularSpeed measurement to a string represenation.</summary> |
| | 3309 | | /// <returns>The string representation of the measurement.</returns> |
| | 3310 | | public override string ToString() |
| | 3311 | | { |
| | 3312 | | return _measurement + " " + |
| | 3313 | | _AngleUnits1 |
| | 3314 | | + "/" + |
| | 3315 | | _TimeUnits2 |
| | 3316 | | ; |
| | 3317 | | } |
| | 3318 | |
|
| | 3319 | | /// <summary>Base hashing function for AngularSpeed measurements.</summary> |
| | 3320 | | /// <returns>Computed hash code for this instance.</returns> |
| | 3321 | | public override int GetHashCode() => Hash(_measurement); |
| | 3322 | |
|
| | 3323 | | #endregion |
| | 3324 | | } |
| | 3325 | |
|
| | 3326 | | #endregion |
| | 3327 | |
|
| | 3328 | | #region Area |
| | 3329 | |
|
| | 3330 | | internal static partial class ParsingFunctions |
| | 3331 | | { |
| | 3332 | | [Measurement.Parseable("Length*Length")] |
| | 3333 | | public static object Area<T>(T value, object[] units) |
| | 3334 | | { |
| | 3335 | | if (units.Length != 2) |
| | 3336 | | { |
| | 3337 | | throw new Exception("Bug in Towel. Invalid parameters to Area Factory."); |
| | 3338 | | } |
| | 3339 | | if (!(units[0] is Length.Units)) |
| | 3340 | | { |
| | 3341 | | throw new Exception("Bug in Towel. Invalid parameters to Area Factory."); |
| | 3342 | | } |
| | 3343 | | if (!(units[1] is Length.Units)) |
| | 3344 | | { |
| | 3345 | | throw new Exception("Bug in Towel. Invalid parameters to Area Factory."); |
| | 3346 | | } |
| | 3347 | | return new Area<T>(value |
| | 3348 | | , (Length.Units)units[0] |
| | 3349 | | , (Length.Units)units[1] |
| | 3350 | | ); |
| | 3351 | | } |
| | 3352 | | } |
| | 3353 | |
|
| | 3354 | | /// <summary>Area measurement with a value and the units.</summary> |
| | 3355 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 3356 | | public struct Area<T> |
| | 3357 | | { |
| | 3358 | | internal T _measurement; |
| | 3359 | | internal Length.Units _LengthUnits1; |
| | 3360 | | internal Length.Units _LengthUnits2; |
| | 3361 | |
|
| | 3362 | | #region Statics |
| | 3363 | |
|
| | 3364 | | /// <summary>Converts a Area measurement from units to another.</summary> |
| | 3365 | | /// <param name="value">The value to convert the units of.</param> |
| | 3366 | | /// <param name="fromLengthUnits1">The current units of the measurement.</param> |
| | 3367 | | /// <param name="fromLengthUnits2">The current units of the measurement.</param> |
| | 3368 | | /// <param name="toLengthUnits1">The desired units of the measurement.</param> |
| | 3369 | | /// <param name="toLengthUnits2">The desired units of the measurement.</param> |
| | 3370 | | /// <returns>The Area measurement converted into the desired units.</returns> |
| | 3371 | | public static T Convert(T value |
| | 3372 | | , Length.Units fromLengthUnits1 |
| | 3373 | | , Length.Units fromLengthUnits2 |
| | 3374 | | , Length.Units toLengthUnits1 |
| | 3375 | | , Length.Units toLengthUnits2 |
| | 3376 | | ) |
| | 3377 | | { |
| | 3378 | | Area<T> measurement = new Area<T>(value |
| | 3379 | | , fromLengthUnits1 |
| | 3380 | | , fromLengthUnits2 |
| | 3381 | | ); |
| | 3382 | | return measurement[ |
| | 3383 | | toLengthUnits1 |
| | 3384 | | , toLengthUnits2 |
| | 3385 | | ]; |
| | 3386 | | } |
| | 3387 | |
|
| | 3388 | | /// <summary>Converts a Area measurement from units to another.</summary> |
| | 3389 | | /// <param name="value">The value to convert the units of.</param> |
| | 3390 | | /// <param name="from">The current units of the measurement.</param> |
| | 3391 | | /// <param name="to">The desired units of the measurement.</param> |
| | 3392 | | /// <returns>The Area measurement converted into the desired units.</returns> |
| | 3393 | | public static T Convert(T value, |
| | 3394 | | MeasurementUnitsSyntaxTypes.AreaBaseUnits from, |
| | 3395 | | MeasurementUnitsSyntaxTypes.AreaBaseUnits to) |
| | 3396 | | { |
| | 3397 | | return Convert(value |
| | 3398 | | , from._LengthUnits1 |
| | 3399 | | , from._LengthUnits2 |
| | 3400 | | , to._LengthUnits1 |
| | 3401 | | , to._LengthUnits2 |
| | 3402 | | ); |
| | 3403 | | } |
| | 3404 | |
|
| | 3405 | | /// <summary>Parses a Area measurement string.</summary> |
| | 3406 | | /// <param name="string">The string to be parsed.</param> |
| | 3407 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 3408 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 3409 | | public static (bool Success, Area<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value)> tryParse |
| | 3410 | |
|
| | 3411 | | #endregion |
| | 3412 | |
|
| | 3413 | | #region Constructors |
| | 3414 | |
|
| | 3415 | | /// <summary>Constructs an Area with the measurement value and units.</summary> |
| | 3416 | | /// <param name="measurement">The measurement value of the Area.</param> |
| | 3417 | | /// <param name="units">The units of the Area.</param> |
| | 3418 | | public Area(T measurement, MeasurementUnitsSyntaxTypes.AreaBaseUnits units) : this(measurement |
| | 3419 | | , units._LengthUnits1 |
| | 3420 | | , units._LengthUnits2 |
| | 3421 | | ) { } |
| | 3422 | |
|
| | 3423 | |
|
| | 3424 | | /// <summary>Constructs an Area with the measurement value and units.</summary> |
| | 3425 | | /// <param name="measurement">The measurement value of the Area.</param> |
| | 3426 | | /// <param name="LengthUnits1">The units of the Area.</param> |
| | 3427 | | /// <param name="LengthUnits2">The units of the Area.</param> |
| | 3428 | | public Area(T measurement |
| | 3429 | | , Length.Units LengthUnits1 |
| | 3430 | | , Length.Units LengthUnits2 |
| | 3431 | | ) |
| | 3432 | | { |
| | 3433 | | _measurement = measurement; |
| | 3434 | | _LengthUnits1 = LengthUnits1; |
| | 3435 | | _LengthUnits2 = LengthUnits2; |
| | 3436 | | } |
| | 3437 | |
|
| | 3438 | | #endregion |
| | 3439 | |
|
| | 3440 | | #region Properties |
| | 3441 | |
|
| | 3442 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 3443 | | public Length.Units LengthUnits1 |
| | 3444 | | { |
| | 3445 | | get { return _LengthUnits1; } |
| | 3446 | | set |
| | 3447 | | { |
| | 3448 | | if (value != _LengthUnits1) |
| | 3449 | | { |
| | 3450 | | _measurement = this[value, _LengthUnits2]; |
| | 3451 | | _LengthUnits1 = value; |
| | 3452 | | } |
| | 3453 | | } |
| | 3454 | | } |
| | 3455 | |
|
| | 3456 | | /// <summary>The #2 component of this measurements units.</summary> |
| | 3457 | | public Length.Units LengthUnits2 |
| | 3458 | | { |
| | 3459 | | get { return _LengthUnits2; } |
| | 3460 | | set |
| | 3461 | | { |
| | 3462 | | if (value != _LengthUnits2) |
| | 3463 | | { |
| | 3464 | | _measurement = this[_LengthUnits1, value]; |
| | 3465 | | _LengthUnits2 = value; |
| | 3466 | | } |
| | 3467 | | } |
| | 3468 | | } |
| | 3469 | |
|
| | 3470 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 3471 | | /// <param name="units">The units to get the measurement in.</param> |
| | 3472 | | /// <returns>The measurement value in the specified units.</returns> |
| | 3473 | | public T this[MeasurementUnitsSyntaxTypes.AreaBaseUnits units] |
| | 3474 | | { |
| | 3475 | | get { return this[units._LengthUnits1, units._LengthUnits2]; } |
| | 3476 | | } |
| | 3477 | |
|
| | 3478 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 3479 | | /// <param name="LengthUnits1">The #1 component of this measurements units.</param> |
| | 3480 | | /// <param name="LengthUnits2">The #2 component of this measurements units.</param> |
| | 3481 | | /// <returns>The measurement value in the specified units.</returns> |
| | 3482 | | public T this[Length.Units LengthUnits1, Length.Units LengthUnits2] |
| | 3483 | | { |
| | 3484 | | get |
| | 3485 | | { |
| | 3486 | | T measurement = _measurement; |
| | 3487 | | if (LengthUnits1 != _LengthUnits1) |
| | 3488 | | { |
| | 3489 | | measurement = Length<T>.Table[(int)_LengthUnits1][(int)LengthUnits1](measurement); |
| | 3490 | | //if (LengthUnits1 < _LengthUnits1) |
| | 3491 | | //{ |
| | 3492 | | // measurement = Length<T>.Table[(int)_LengthUnits1][(int)LengthUnits1](measurement); |
| | 3493 | | //} |
| | 3494 | | //else |
| | 3495 | | //{ |
| | 3496 | | // measurement = Length<T>.Table[(int)LengthUnits1][(int)_LengthUnits1](measurement); |
| | 3497 | | //} |
| | 3498 | | } |
| | 3499 | | if (LengthUnits2 != _LengthUnits2) |
| | 3500 | | { |
| | 3501 | | measurement = Length<T>.Table[(int)_LengthUnits2][(int)LengthUnits2](measurement); |
| | 3502 | | //if (LengthUnits2 < _LengthUnits2) |
| | 3503 | | //{ |
| | 3504 | | // measurement = Length<T>.Table[(int)_LengthUnits2][(int)LengthUnits2](measurement); |
| | 3505 | | //} |
| | 3506 | | //else |
| | 3507 | | //{ |
| | 3508 | | // measurement = Length<T>.Table[(int)LengthUnits2][(int)_LengthUnits2](measurement); |
| | 3509 | | //} |
| | 3510 | | } |
| | 3511 | | return measurement; |
| | 3512 | | } |
| | 3513 | | } |
| | 3514 | |
|
| | 3515 | | #endregion |
| | 3516 | |
|
| | 3517 | | #region Casting Operators |
| | 3518 | |
|
| | 3519 | | /// <summary>Converts a ValueTuple to a Area measurement.</summary> |
| | 3520 | | /// <param name="valueTuple">The ValueTuple to converted into a Area measurement.</param> |
| | 3521 | | public static implicit operator Area<T>((T, MeasurementUnitsSyntaxTypes.AreaBaseUnits) valueTuple) |
| | 3522 | | { |
| | 3523 | | return new Area<T>(valueTuple.Item1, valueTuple.Item2); |
| | 3524 | | } |
| | 3525 | |
|
| | 3526 | | #endregion |
| | 3527 | |
|
| | 3528 | | #region Mathematics |
| | 3529 | |
|
| | 3530 | | #region Bases |
| | 3531 | |
|
| | 3532 | | internal static Area<T> MathBase(Area<T> a, T b, Func<T, T, T> func) |
| | 3533 | | { |
| | 3534 | | return new Area<T>(func(a._measurement, b) |
| | 3535 | | , a._LengthUnits1 |
| | 3536 | | , a._LengthUnits2 |
| | 3537 | | ); |
| | 3538 | | } |
| | 3539 | |
|
| | 3540 | | internal static Area<T> MathBase(Area<T> a, Area<T> b, Func<T, T, T> func) |
| | 3541 | | { |
| | 3542 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 3543 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 3544 | | T A = a[LengthUnits1, LengthUnits2]; |
| | 3545 | | T B = b[LengthUnits1, LengthUnits2]; |
| | 3546 | | T C = func(A, B); |
| | 3547 | | return new Area<T>(C, LengthUnits1, LengthUnits2); |
| | 3548 | | } |
| | 3549 | |
|
| | 3550 | | internal static bool LogicBase(Area<T> a, Area<T> b, Func<T, T, bool> func) |
| | 3551 | | { |
| | 3552 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 3553 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 3554 | | T A = a[LengthUnits1, LengthUnits2]; |
| | 3555 | | T B = b[LengthUnits1, LengthUnits2]; |
| | 3556 | | return func(A, B); |
| | 3557 | | } |
| | 3558 | |
|
| | 3559 | | #endregion |
| | 3560 | |
|
| | 3561 | | #region Add |
| | 3562 | |
|
| | 3563 | | /// <summary>Adds two Area measurements.</summary> |
| | 3564 | | /// <param name="a">The first operand of the addition.</param> |
| | 3565 | | /// <param name="b">The second operand of the addition.</param> |
| | 3566 | | /// <returns>The result of the addition operation.</returns> |
| | 3567 | | public static Area<T> Add(Area<T> a, Area<T> b) |
| | 3568 | | { |
| | 3569 | | return MathBase(a, b, Statics.Addition); |
| | 3570 | | } |
| | 3571 | |
|
| | 3572 | | /// <summary>Adds two Area measurements.</summary> |
| | 3573 | | /// <param name="a">The first operand of the addition.</param> |
| | 3574 | | /// <param name="b">The second operand of the addition.</param> |
| | 3575 | | /// <returns>The result of the addition operation.</returns> |
| | 3576 | | public static Area<T> operator +(Area<T> a, Area<T> b) |
| | 3577 | | { |
| | 3578 | | return Add(a, b); |
| | 3579 | | } |
| | 3580 | |
|
| | 3581 | | /// <summary>Adds two Area measurements.</summary> |
| | 3582 | | /// <param name="b">The second operand of the addition.</param> |
| | 3583 | | /// <returns>The result of the addition operation.</returns> |
| | 3584 | | public Area<T> Add(Area<T> b) |
| | 3585 | | { |
| | 3586 | | return this + b; |
| | 3587 | | } |
| | 3588 | |
|
| | 3589 | | #endregion |
| | 3590 | |
|
| | 3591 | | #region Subtract |
| | 3592 | |
|
| | 3593 | | /// <summary>Subtracts two Area measurements.</summary> |
| | 3594 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 3595 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 3596 | | /// <returns>The result of the subtraction.</returns> |
| | 3597 | | public static Area<T> Subtract(Area<T> a, Area<T> b) |
| | 3598 | | { |
| | 3599 | | return MathBase(a, b, Statics.Subtraction); |
| | 3600 | | } |
| | 3601 | |
|
| | 3602 | | /// <summary>Subtracts two Area measurements.</summary> |
| | 3603 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 3604 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 3605 | | /// <returns>The result of the subtraction.</returns> |
| | 3606 | | public static Area<T> operator -(Area<T> a, Area<T> b) |
| | 3607 | | { |
| | 3608 | | return Subtract(a, b); |
| | 3609 | | } |
| | 3610 | |
|
| | 3611 | | /// <summary>Subtracts two Area measurements.</summary> |
| | 3612 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 3613 | | /// <returns>The result of the subtraction.</returns> |
| | 3614 | | public Area<T> Subtract(Area<T> b) |
| | 3615 | | { |
| | 3616 | | return this - b; |
| | 3617 | | } |
| | 3618 | |
|
| | 3619 | | #endregion |
| | 3620 | |
|
| | 3621 | | #region Multiply |
| | 3622 | |
|
| | 3623 | | /// <summary>Multiplies an Area by a scalar numeric value.</summary> |
| | 3624 | | /// <param name="a">The Area measurement to multiply.</param> |
| | 3625 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 3626 | | /// <returns>The result of the multiplication.</returns> |
| | 3627 | | public static Area<T> Multiply(Area<T> a, T b) |
| | 3628 | | { |
| | 3629 | | return MathBase(a, b, Statics.Multiplication); |
| | 3630 | | } |
| | 3631 | |
|
| | 3632 | | /// <summary>Multiplies an Area by a scalar numeric value.</summary> |
| | 3633 | | /// <param name="a">The Area measurement to multiply.</param> |
| | 3634 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 3635 | | /// <returns>The result of the multiplication.</returns> |
| | 3636 | | public static Area<T> Multiply(T b, Area<T> a) |
| | 3637 | | { |
| | 3638 | | return Multiply(a, b); |
| | 3639 | | } |
| | 3640 | |
|
| | 3641 | | /// <summary>Multiplies an Area by a scalar numeric value.</summary> |
| | 3642 | | /// <param name="a">The Area measurement to multiply.</param> |
| | 3643 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 3644 | | /// <returns>The result of the multiplication.</returns> |
| | 3645 | | public static Area<T> operator *(Area<T> a, T b) |
| | 3646 | | { |
| | 3647 | | return Multiply(a, b); |
| | 3648 | | } |
| | 3649 | |
|
| | 3650 | | /// <summary>Multiplies an Area by a scalar numeric value.</summary> |
| | 3651 | | /// <param name="a">The Area measurement to multiply.</param> |
| | 3652 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 3653 | | /// <returns>The result of the multiplication.</returns> |
| | 3654 | | public static Area<T> operator *(T b, Area<T> a) |
| | 3655 | | { |
| | 3656 | | return Multiply(b, a); |
| | 3657 | | } |
| | 3658 | |
|
| | 3659 | | /// <summary>Multiplies an Area by a scalar numeric value.</summary> |
| | 3660 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 3661 | | /// <returns>The result of the multiplication.</returns> |
| | 3662 | | public Area<T> Add(T b) |
| | 3663 | | { |
| | 3664 | | return this * b; |
| | 3665 | | } |
| | 3666 | |
|
| | 3667 | | #region Area<T> * AreaDensity<T> = Mass<T> |
| | 3668 | |
|
| | 3669 | | /// <summary>Mulitplies Area by AreaDensity resulting in Mass.</summary> |
| | 3670 | | /// <param name="a">The Area to be multiplied.</param> |
| | 3671 | | /// <param name="b">The AreaDensity to multiply by.</param> |
| | 3672 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 3673 | | public static Mass<T> Multiply(Area<T> a, AreaDensity<T> b) |
| | 3674 | | { |
| | 3675 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits2 ? a._LengthUnits1 : b._LengthUnits2; |
| | 3676 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits3 ? a._LengthUnits2 : b._LengthUnits3; |
| | 3677 | |
|
| | 3678 | | T A = a[LengthUnits1, LengthUnits2]; |
| | 3679 | | T B = b[b._MassUnits1, LengthUnits1, LengthUnits2]; |
| | 3680 | | T C = Statics.Multiplication(A, B); |
| | 3681 | |
|
| | 3682 | | return new Mass<T>(C |
| | 3683 | | , b._MassUnits1 |
| | 3684 | | ); |
| | 3685 | | } |
| | 3686 | |
|
| | 3687 | | /// <summary>Mulitplies Area by AreaDensity resulting in Mass.</summary> |
| | 3688 | | /// <param name="a">The Area to be multiplied.</param> |
| | 3689 | | /// <param name="b">The AreaDensity to multiply by.</param> |
| | 3690 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 3691 | | public static Mass<T> operator *(Area<T> a, AreaDensity<T> b) |
| | 3692 | | { |
| | 3693 | | return Multiply(a, b); |
| | 3694 | | } |
| | 3695 | |
|
| | 3696 | | /// <summary>Mulitplies Area by AreaDensity resulting in Mass.</summary> |
| | 3697 | | /// <param name="b">The AreaDensity to multiply by.</param> |
| | 3698 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 3699 | | public Mass<T> Multiply(AreaDensity<T> b) |
| | 3700 | | { |
| | 3701 | | return this * b; |
| | 3702 | | } |
| | 3703 | |
|
| | 3704 | | #endregion |
| | 3705 | |
|
| | 3706 | | #region Area<T> * Density<T> = LinearDensity<T> |
| | 3707 | |
|
| | 3708 | | /// <summary>Mulitplies Area by Density resulting in LinearDensity.</summary> |
| | 3709 | | /// <param name="a">The Area to be multiplied.</param> |
| | 3710 | | /// <param name="b">The Density to multiply by.</param> |
| | 3711 | | /// <returns>The LinearDensity result of the multiplication.</returns> |
| | 3712 | | public static LinearDensity<T> Multiply(Area<T> a, Density<T> b) |
| | 3713 | | { |
| | 3714 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits2 ? a._LengthUnits1 : b._LengthUnits2; |
| | 3715 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits3 ? a._LengthUnits2 : b._LengthUnits3; |
| | 3716 | |
|
| | 3717 | | T A = a[LengthUnits1, LengthUnits2]; |
| | 3718 | | T B = b[b._MassUnits1, LengthUnits1, LengthUnits2, b._LengthUnits4]; |
| | 3719 | | T C = Statics.Multiplication(A, B); |
| | 3720 | |
|
| | 3721 | | return new LinearDensity<T>(C |
| | 3722 | | , b._MassUnits1 |
| | 3723 | | , b._LengthUnits4 |
| | 3724 | | ); |
| | 3725 | | } |
| | 3726 | |
|
| | 3727 | | /// <summary>Mulitplies Area by Density resulting in LinearDensity.</summary> |
| | 3728 | | /// <param name="a">The Area to be multiplied.</param> |
| | 3729 | | /// <param name="b">The Density to multiply by.</param> |
| | 3730 | | /// <returns>The LinearDensity result of the multiplication.</returns> |
| | 3731 | | public static LinearDensity<T> operator *(Area<T> a, Density<T> b) |
| | 3732 | | { |
| | 3733 | | return Multiply(a, b); |
| | 3734 | | } |
| | 3735 | |
|
| | 3736 | | /// <summary>Mulitplies Area by Density resulting in LinearDensity.</summary> |
| | 3737 | | /// <param name="b">The Density to multiply by.</param> |
| | 3738 | | /// <returns>The LinearDensity result of the multiplication.</returns> |
| | 3739 | | public LinearDensity<T> Multiply(Density<T> b) |
| | 3740 | | { |
| | 3741 | | return this * b; |
| | 3742 | | } |
| | 3743 | |
|
| | 3744 | | #endregion |
| | 3745 | |
|
| | 3746 | | #region Area<T> * Length<T> = Volume<T> |
| | 3747 | |
|
| | 3748 | | /// <summary>Mulitplies Area by Length resulting in Volume.</summary> |
| | 3749 | | /// <param name="a">The Area to be multiplied.</param> |
| | 3750 | | /// <param name="b">The Length to multiply by.</param> |
| | 3751 | | /// <returns>The Volume result of the multiplication.</returns> |
| | 3752 | | public static Volume<T> Multiply(Area<T> a, Length<T> b) |
| | 3753 | | { |
| | 3754 | |
|
| | 3755 | | T A = a[a._LengthUnits1, a._LengthUnits2]; |
| | 3756 | | T B = b[b._LengthUnits1]; |
| | 3757 | | T C = Statics.Multiplication(A, B); |
| | 3758 | |
|
| | 3759 | | return new Volume<T>(C |
| | 3760 | | , a._LengthUnits1 |
| | 3761 | | , a._LengthUnits2 |
| | 3762 | | , b._LengthUnits1 |
| | 3763 | | ); |
| | 3764 | | } |
| | 3765 | |
|
| | 3766 | | /// <summary>Mulitplies Area by Length resulting in Volume.</summary> |
| | 3767 | | /// <param name="a">The Area to be multiplied.</param> |
| | 3768 | | /// <param name="b">The Length to multiply by.</param> |
| | 3769 | | /// <returns>The Volume result of the multiplication.</returns> |
| | 3770 | | public static Volume<T> operator *(Area<T> a, Length<T> b) |
| | 3771 | | { |
| | 3772 | | return Multiply(a, b); |
| | 3773 | | } |
| | 3774 | |
|
| | 3775 | | /// <summary>Mulitplies Area by Length resulting in Volume.</summary> |
| | 3776 | | /// <param name="b">The Length to multiply by.</param> |
| | 3777 | | /// <returns>The Volume result of the multiplication.</returns> |
| | 3778 | | public Volume<T> Multiply(Length<T> b) |
| | 3779 | | { |
| | 3780 | | return this * b; |
| | 3781 | | } |
| | 3782 | |
|
| | 3783 | | #endregion |
| | 3784 | |
|
| | 3785 | | #region Area<T> * LinearDensity<T> = LinearMass<T> |
| | 3786 | |
|
| | 3787 | | /// <summary>Mulitplies Area by LinearDensity resulting in LinearMass.</summary> |
| | 3788 | | /// <param name="a">The Area to be multiplied.</param> |
| | 3789 | | /// <param name="b">The LinearDensity to multiply by.</param> |
| | 3790 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 3791 | | public static LinearMass<T> Multiply(Area<T> a, LinearDensity<T> b) |
| | 3792 | | { |
| | 3793 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits2 ? a._LengthUnits1 : b._LengthUnits2; |
| | 3794 | |
|
| | 3795 | | T A = a[LengthUnits1, a._LengthUnits2]; |
| | 3796 | | T B = b[b._MassUnits1, LengthUnits1]; |
| | 3797 | | T C = Statics.Multiplication(A, B); |
| | 3798 | |
|
| | 3799 | | return new LinearMass<T>(C |
| | 3800 | | , b._MassUnits1 |
| | 3801 | | , a._LengthUnits2 |
| | 3802 | | ); |
| | 3803 | | } |
| | 3804 | |
|
| | 3805 | | /// <summary>Mulitplies Area by LinearDensity resulting in LinearMass.</summary> |
| | 3806 | | /// <param name="a">The Area to be multiplied.</param> |
| | 3807 | | /// <param name="b">The LinearDensity to multiply by.</param> |
| | 3808 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 3809 | | public static LinearMass<T> operator *(Area<T> a, LinearDensity<T> b) |
| | 3810 | | { |
| | 3811 | | return Multiply(a, b); |
| | 3812 | | } |
| | 3813 | |
|
| | 3814 | | /// <summary>Mulitplies Area by LinearDensity resulting in LinearMass.</summary> |
| | 3815 | | /// <param name="b">The LinearDensity to multiply by.</param> |
| | 3816 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 3817 | | public LinearMass<T> Multiply(LinearDensity<T> b) |
| | 3818 | | { |
| | 3819 | | return this * b; |
| | 3820 | | } |
| | 3821 | |
|
| | 3822 | | #endregion |
| | 3823 | |
|
| | 3824 | | #region Area<T> * Pressure<T> = Force<T> |
| | 3825 | |
|
| | 3826 | | /// <summary>Mulitplies Area by Pressure resulting in Force.</summary> |
| | 3827 | | /// <param name="a">The Area to be multiplied.</param> |
| | 3828 | | /// <param name="b">The Pressure to multiply by.</param> |
| | 3829 | | /// <returns>The Force result of the multiplication.</returns> |
| | 3830 | | public static Force<T> Multiply(Area<T> a, Pressure<T> b) |
| | 3831 | | { |
| | 3832 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits2 ? a._LengthUnits1 : b._LengthUnits2; |
| | 3833 | |
|
| | 3834 | | T A = a[LengthUnits1, a._LengthUnits2]; |
| | 3835 | | T B = b[b._MassUnits1, LengthUnits1, b._TimeUnits3, b._TimeUnits4]; |
| | 3836 | | T C = Statics.Multiplication(A, B); |
| | 3837 | |
|
| | 3838 | | return new Force<T>(C |
| | 3839 | | , b._MassUnits1 |
| | 3840 | | , a._LengthUnits2 |
| | 3841 | | , b._TimeUnits3 |
| | 3842 | | , b._TimeUnits4 |
| | 3843 | | ); |
| | 3844 | | } |
| | 3845 | |
|
| | 3846 | | /// <summary>Mulitplies Area by Pressure resulting in Force.</summary> |
| | 3847 | | /// <param name="a">The Area to be multiplied.</param> |
| | 3848 | | /// <param name="b">The Pressure to multiply by.</param> |
| | 3849 | | /// <returns>The Force result of the multiplication.</returns> |
| | 3850 | | public static Force<T> operator *(Area<T> a, Pressure<T> b) |
| | 3851 | | { |
| | 3852 | | return Multiply(a, b); |
| | 3853 | | } |
| | 3854 | |
|
| | 3855 | | /// <summary>Mulitplies Area by Pressure resulting in Force.</summary> |
| | 3856 | | /// <param name="b">The Pressure to multiply by.</param> |
| | 3857 | | /// <returns>The Force result of the multiplication.</returns> |
| | 3858 | | public Force<T> Multiply(Pressure<T> b) |
| | 3859 | | { |
| | 3860 | | return this * b; |
| | 3861 | | } |
| | 3862 | |
|
| | 3863 | | #endregion |
| | 3864 | |
|
| | 3865 | | #region Area<T> * Speed<T> = VolumeRate<T> |
| | 3866 | |
|
| | 3867 | | /// <summary>Mulitplies Area by Speed resulting in VolumeRate.</summary> |
| | 3868 | | /// <param name="a">The Area to be multiplied.</param> |
| | 3869 | | /// <param name="b">The Speed to multiply by.</param> |
| | 3870 | | /// <returns>The VolumeRate result of the multiplication.</returns> |
| | 3871 | | public static VolumeRate<T> Multiply(Area<T> a, Speed<T> b) |
| | 3872 | | { |
| | 3873 | |
|
| | 3874 | | T A = a[a._LengthUnits1, a._LengthUnits2]; |
| | 3875 | | T B = b[b._LengthUnits1, b._TimeUnits2]; |
| | 3876 | | T C = Statics.Multiplication(A, B); |
| | 3877 | |
|
| | 3878 | | return new VolumeRate<T>(C |
| | 3879 | | , a._LengthUnits1 |
| | 3880 | | , a._LengthUnits2 |
| | 3881 | | , b._LengthUnits1 |
| | 3882 | | , b._TimeUnits2 |
| | 3883 | | ); |
| | 3884 | | } |
| | 3885 | |
|
| | 3886 | | /// <summary>Mulitplies Area by Speed resulting in VolumeRate.</summary> |
| | 3887 | | /// <param name="a">The Area to be multiplied.</param> |
| | 3888 | | /// <param name="b">The Speed to multiply by.</param> |
| | 3889 | | /// <returns>The VolumeRate result of the multiplication.</returns> |
| | 3890 | | public static VolumeRate<T> operator *(Area<T> a, Speed<T> b) |
| | 3891 | | { |
| | 3892 | | return Multiply(a, b); |
| | 3893 | | } |
| | 3894 | |
|
| | 3895 | | /// <summary>Mulitplies Area by Speed resulting in VolumeRate.</summary> |
| | 3896 | | /// <param name="b">The Speed to multiply by.</param> |
| | 3897 | | /// <returns>The VolumeRate result of the multiplication.</returns> |
| | 3898 | | public VolumeRate<T> Multiply(Speed<T> b) |
| | 3899 | | { |
| | 3900 | | return this * b; |
| | 3901 | | } |
| | 3902 | |
|
| | 3903 | | #endregion |
| | 3904 | |
|
| | 3905 | | #endregion |
| | 3906 | |
|
| | 3907 | | #region Divide |
| | 3908 | |
|
| | 3909 | | /// <summary>Divides an Area measurement by another Area measurement resulting in a scalar numeric value.</summary> |
| | 3910 | | /// <param name="a">The first operand of the division operation.</param> |
| | 3911 | | /// <param name="b">The second operand of the division operation.</param> |
| | 3912 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 3913 | | public static T Divide(Area<T> a, Area<T> b) |
| | 3914 | | { |
| | 3915 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 3916 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 3917 | | T A = a[LengthUnits1, LengthUnits2]; |
| | 3918 | | T B = b[LengthUnits1, LengthUnits2]; |
| | 3919 | | return Statics.Division(A, B); |
| | 3920 | | } |
| | 3921 | |
|
| | 3922 | | /// <summary>Divides this Area measurement by a numaric scalar value.</summary> |
| | 3923 | | /// <param name="a">The Area measurement to divide.</param> |
| | 3924 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 3925 | | /// <returns>The result of the division.</returns> |
| | 3926 | | public static Area<T> Divide(Area<T> a, T b) |
| | 3927 | | { |
| | 3928 | | return MathBase(a, b, Statics.Division); |
| | 3929 | | } |
| | 3930 | |
|
| | 3931 | | /// <summary>Divides this Area measurement by a numaric scalar value.</summary> |
| | 3932 | | /// <param name="a">The Area measurement to divide.</param> |
| | 3933 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 3934 | | /// <returns>The result of the division.</returns> |
| | 3935 | | public static Area<T> operator /(Area<T> a, T b) |
| | 3936 | | { |
| | 3937 | | return Divide(a, b); |
| | 3938 | | } |
| | 3939 | |
|
| | 3940 | | /// <summary>Divides this Area measurement by a numaric scalar value.</summary> |
| | 3941 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 3942 | | /// <returns>The result of the division.</returns> |
| | 3943 | | public Area<T> Divide(T b) |
| | 3944 | | { |
| | 3945 | | return this / b; |
| | 3946 | | } |
| | 3947 | |
|
| | 3948 | | /// <summary>Divides an Area measurement by another Area measurement resulting in a scalar numeric value.</summary> |
| | 3949 | | /// <param name="a">The first operand of the division operation.</param> |
| | 3950 | | /// <param name="b">The second operand of the division operation.</param> |
| | 3951 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 3952 | | public static T operator /(Area<T> a, Area<T> b) |
| | 3953 | | { |
| | 3954 | | return Divide(a, b); |
| | 3955 | | } |
| | 3956 | |
|
| | 3957 | | /// <summary>Divides an Area measurement by another Area measurement resulting in a scalar numeric value.</summary> |
| | 3958 | | /// <param name="b">The second operand of the division operation.</param> |
| | 3959 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 3960 | | public T Divide(Area<T> b) |
| | 3961 | | { |
| | 3962 | | return this / b; |
| | 3963 | | } |
| | 3964 | |
|
| | 3965 | |
|
| | 3966 | | #region Area<T> / Length<T> = Length<T> |
| | 3967 | |
|
| | 3968 | | /// <summary>Divides Area by Length resulting in Length.</summary> |
| | 3969 | | /// <param name="a">The Area to be divided.</param> |
| | 3970 | | /// <param name="b">The Length to divide by.</param> |
| | 3971 | | /// <returns>The Length result of the division.</returns> |
| | 3972 | | public static Length<T> Divide(Area<T> a, Length<T> b) |
| | 3973 | | { |
| | 3974 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 3975 | |
|
| | 3976 | | T A = a[LengthUnits1, a._LengthUnits2]; |
| | 3977 | | T B = b[LengthUnits1]; |
| | 3978 | | T C = Statics.Division(A, B); |
| | 3979 | |
|
| | 3980 | | return new Length<T>(C |
| | 3981 | | , a._LengthUnits2 |
| | 3982 | | ); |
| | 3983 | | } |
| | 3984 | |
|
| | 3985 | | /// <summary>Divides Area by Length resulting in Length.</summary> |
| | 3986 | | /// <param name="a">The Area to be divided.</param> |
| | 3987 | | /// <param name="b">The Length to divide by.</param> |
| | 3988 | | /// <returns>The Length result of the division.</returns> |
| | 3989 | | public static Length<T> operator /(Area<T> a, Length<T> b) |
| | 3990 | | { |
| | 3991 | | return Divide(a, b); |
| | 3992 | | } |
| | 3993 | |
|
| | 3994 | | /// <summary>Divides Area by Length resulting in Length.</summary> |
| | 3995 | | /// <param name="b">The Length to divide by.</param> |
| | 3996 | | /// <returns>The Length result of the division.</returns> |
| | 3997 | | public Length<T> Divide(Length<T> b) |
| | 3998 | | { |
| | 3999 | | return this / b; |
| | 4000 | | } |
| | 4001 | |
|
| | 4002 | | #endregion |
| | 4003 | |
|
| | 4004 | | #endregion |
| | 4005 | |
|
| | 4006 | | #region LessThan |
| | 4007 | |
|
| | 4008 | | /// <summary>Determines if an Area measurement is less than another Area measurement.</summary> |
| | 4009 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 4010 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 4011 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 4012 | | public static bool LessThan(Area<T> a, Area<T> b) |
| | 4013 | | { |
| | 4014 | | return LogicBase(a, b, Statics.LessThan); |
| | 4015 | | } |
| | 4016 | |
|
| | 4017 | | /// <summary>Determines if an Area measurement is less than another Area measurement.</summary> |
| | 4018 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 4019 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 4020 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 4021 | | public static bool operator <(Area<T> a, Area<T> b) |
| | 4022 | | { |
| | 4023 | | return LessThan(a, b); |
| | 4024 | | } |
| | 4025 | |
|
| | 4026 | | /// <summary>Determines if an Area measurement is less than another Area measurement.</summary> |
| | 4027 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 4028 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 4029 | | public bool LessThan(Area<T> b) |
| | 4030 | | { |
| | 4031 | | return this < b; |
| | 4032 | | } |
| | 4033 | |
|
| | 4034 | | #endregion |
| | 4035 | |
|
| | 4036 | | #region GreaterThan |
| | 4037 | |
|
| | 4038 | | /// <summary>Determines if an Area measurement is greater than another Area measurement.</summary> |
| | 4039 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 4040 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 4041 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 4042 | | public static bool GreaterThan(Area<T> a, Area<T> b) |
| | 4043 | | { |
| | 4044 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 4045 | | } |
| | 4046 | |
|
| | 4047 | | /// <summary>Determines if an Area measurement is greater than another Area measurement.</summary> |
| | 4048 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 4049 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 4050 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 4051 | | public static bool operator >(Area<T> a, Area<T> b) |
| | 4052 | | { |
| | 4053 | | return GreaterThan(a, b); |
| | 4054 | | } |
| | 4055 | |
|
| | 4056 | | /// <summary>Determines if an Area measurement is greater than another Area measurement.</summary> |
| | 4057 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 4058 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 4059 | | public bool GreaterThan(Area<T> b) |
| | 4060 | | { |
| | 4061 | | return this > b; |
| | 4062 | | } |
| | 4063 | |
|
| | 4064 | | #endregion |
| | 4065 | |
|
| | 4066 | | #region LessThanOrEqual |
| | 4067 | |
|
| | 4068 | | /// <summary>Determines if an Area measurement is less than or equal to another Area measurement.</summary> |
| | 4069 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 4070 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 4071 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 4072 | | public static bool LessThanOrEqual(Area<T> a, Area<T> b) |
| | 4073 | | { |
| | 4074 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 4075 | | } |
| | 4076 | |
|
| | 4077 | | /// <summary>Determines if an Area measurement is less than or equal to another Area measurement.</summary> |
| | 4078 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 4079 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 4080 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 4081 | | public static bool operator <=(Area<T> a, Area<T> b) |
| | 4082 | | { |
| | 4083 | | return LessThanOrEqual(a, b); |
| | 4084 | | } |
| | 4085 | |
|
| | 4086 | | /// <summary>Determines if an Area measurement is less than or equal to another Area measurement.</summary> |
| | 4087 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 4088 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 4089 | | public bool LessThanOrEqual(Area<T> b) |
| | 4090 | | { |
| | 4091 | | return this <= b; |
| | 4092 | | } |
| | 4093 | |
|
| | 4094 | | #endregion |
| | 4095 | |
|
| | 4096 | | #region GreaterThanOrEqual |
| | 4097 | |
|
| | 4098 | | /// <summary>Determines if an Area measurement is greater than or equal to another Area measurement.</summary> |
| | 4099 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 4100 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 4101 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 4102 | | public static bool GreaterThanOrEqual(Area<T> a, Area<T> b) |
| | 4103 | | { |
| | 4104 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 4105 | | } |
| | 4106 | |
|
| | 4107 | | /// <summary>Determines if an Area measurement is greater than or equal to another Area measurement.</summary> |
| | 4108 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 4109 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 4110 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 4111 | | public static bool operator >=(Area<T> a, Area<T> b) |
| | 4112 | | { |
| | 4113 | | return GreaterThanOrEqual(a, b); |
| | 4114 | | } |
| | 4115 | |
|
| | 4116 | | /// <summary>Determines if an Area measurement is greater than or equal to another Area measurement.</summary> |
| | 4117 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 4118 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 4119 | | public bool GreaterThanOrEqual(Area<T> b) |
| | 4120 | | { |
| | 4121 | | return this >= b; |
| | 4122 | | } |
| | 4123 | |
|
| | 4124 | | #endregion |
| | 4125 | |
|
| | 4126 | | #region Equal |
| | 4127 | |
|
| | 4128 | | /// <summary>Determines if an Area measurement is equal to another Area measurement.</summary> |
| | 4129 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 4130 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 4131 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 4132 | | public static bool Equal(Area<T> a, Area<T> b) |
| | 4133 | | { |
| | 4134 | | return LogicBase(a, b, Statics.Equate); |
| | 4135 | | } |
| | 4136 | |
|
| | 4137 | | /// <summary>Determines if an Area measurement is equal to another Area measurement.</summary> |
| | 4138 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 4139 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 4140 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 4141 | | public static bool operator ==(Area<T> a, Area<T> b) |
| | 4142 | | { |
| | 4143 | | return Equal(a, b); |
| | 4144 | | } |
| | 4145 | |
|
| | 4146 | | /// <summary>Determines if an Area measurement is equal to another Area measurement.</summary> |
| | 4147 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 4148 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 4149 | | public bool Equal(Area<T> b) |
| | 4150 | | { |
| | 4151 | | return this == b; |
| | 4152 | | } |
| | 4153 | |
|
| | 4154 | | #endregion |
| | 4155 | |
|
| | 4156 | | #region NotEqual |
| | 4157 | |
|
| | 4158 | | /// <summary>Determines if an Area measurement is not equal to another Area measurement.</summary> |
| | 4159 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 4160 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 4161 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 4162 | | public static bool NotEqual(Area<T> a, Area<T> b) |
| | 4163 | | { |
| | 4164 | | return LogicBase(a, b, Statics.Inequate); |
| | 4165 | | } |
| | 4166 | |
|
| | 4167 | | /// <summary>Determines if an Area measurement is not equal to another Area measurement.</summary> |
| | 4168 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 4169 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 4170 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 4171 | | public static bool operator !=(Area<T> a, Area<T> b) |
| | 4172 | | { |
| | 4173 | | return NotEqual(a, b); |
| | 4174 | | } |
| | 4175 | |
|
| | 4176 | | /// <summary>Determines if an Area measurement is not equal to another Area measurement.</summary> |
| | 4177 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 4178 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 4179 | | public bool NotEqual(Area<T> b) |
| | 4180 | | { |
| | 4181 | | return this != b; |
| | 4182 | | } |
| | 4183 | |
|
| | 4184 | | #endregion |
| | 4185 | |
|
| | 4186 | | #endregion |
| | 4187 | |
|
| | 4188 | | #region Overrides |
| | 4189 | |
|
| | 4190 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 4191 | | /// <param name="obj">The object to check for equality with.</param> |
| | 4192 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 4193 | | public override bool Equals(object obj) |
| | 4194 | | { |
| | 4195 | | if (obj is Area<T>) |
| | 4196 | | { |
| | 4197 | | return this == (Area<T>)obj; |
| | 4198 | | } |
| | 4199 | | return false; |
| | 4200 | | } |
| | 4201 | |
|
| | 4202 | | /// <summary>Converts the Area measurement to a string represenation.</summary> |
| | 4203 | | /// <returns>The string representation of the measurement.</returns> |
| | 4204 | | public override string ToString() |
| | 4205 | | { |
| | 4206 | | return _measurement + " " + |
| | 4207 | | _LengthUnits1 + "*" + _LengthUnits2 |
| | 4208 | |
|
| | 4209 | | ; |
| | 4210 | | } |
| | 4211 | |
|
| | 4212 | | /// <summary>Base hashing function for Area measurements.</summary> |
| | 4213 | | /// <returns>Computed hash code for this instance.</returns> |
| | 4214 | | public override int GetHashCode() => Hash(_measurement); |
| | 4215 | |
|
| | 4216 | | #endregion |
| | 4217 | | } |
| | 4218 | |
|
| | 4219 | | #endregion |
| | 4220 | |
|
| | 4221 | | #region AreaDensity |
| | 4222 | |
|
| | 4223 | | internal static partial class ParsingFunctions |
| | 4224 | | { |
| | 4225 | | [Measurement.Parseable("Mass/Length/Length")] |
| | 4226 | | public static object AreaDensity<T>(T value, object[] units) |
| | 4227 | | { |
| | 4228 | | if (units.Length != 3) |
| | 4229 | | { |
| | 4230 | | throw new Exception("Bug in Towel. Invalid parameters to AreaDensity Factory."); |
| | 4231 | | } |
| | 4232 | | if (!(units[0] is Mass.Units)) |
| | 4233 | | { |
| | 4234 | | throw new Exception("Bug in Towel. Invalid parameters to AreaDensity Factory."); |
| | 4235 | | } |
| | 4236 | | if (!(units[1] is Length.Units)) |
| | 4237 | | { |
| | 4238 | | throw new Exception("Bug in Towel. Invalid parameters to AreaDensity Factory."); |
| | 4239 | | } |
| | 4240 | | if (!(units[2] is Length.Units)) |
| | 4241 | | { |
| | 4242 | | throw new Exception("Bug in Towel. Invalid parameters to AreaDensity Factory."); |
| | 4243 | | } |
| | 4244 | | return new AreaDensity<T>(value |
| | 4245 | | , (Mass.Units)units[0] |
| | 4246 | | , (Length.Units)units[1] |
| | 4247 | | , (Length.Units)units[2] |
| | 4248 | | ); |
| | 4249 | | } |
| | 4250 | | } |
| | 4251 | |
|
| | 4252 | | /// <summary>AreaDensity measurement with a value and the units.</summary> |
| | 4253 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 4254 | | public struct AreaDensity<T> |
| | 4255 | | { |
| | 4256 | | internal T _measurement; |
| | 4257 | | internal Mass.Units _MassUnits1; |
| | 4258 | | internal Length.Units _LengthUnits2; |
| | 4259 | | internal Length.Units _LengthUnits3; |
| | 4260 | |
|
| | 4261 | | #region Statics |
| | 4262 | |
|
| | 4263 | | /// <summary>Converts a AreaDensity measurement from units to another.</summary> |
| | 4264 | | /// <param name="value">The value to convert the units of.</param> |
| | 4265 | | /// <param name="fromMassUnits1">The current units of the measurement.</param> |
| | 4266 | | /// <param name="fromLengthUnits2">The current units of the measurement.</param> |
| | 4267 | | /// <param name="fromLengthUnits3">The current units of the measurement.</param> |
| | 4268 | | /// <param name="toMassUnits1">The desired units of the measurement.</param> |
| | 4269 | | /// <param name="toLengthUnits2">The desired units of the measurement.</param> |
| | 4270 | | /// <param name="toLengthUnits3">The desired units of the measurement.</param> |
| | 4271 | | /// <returns>The AreaDensity measurement converted into the desired units.</returns> |
| | 4272 | | public static T Convert(T value |
| | 4273 | | , Mass.Units fromMassUnits1 |
| | 4274 | | , Length.Units fromLengthUnits2 |
| | 4275 | | , Length.Units fromLengthUnits3 |
| | 4276 | | , Mass.Units toMassUnits1 |
| | 4277 | | , Length.Units toLengthUnits2 |
| | 4278 | | , Length.Units toLengthUnits3 |
| | 4279 | | ) |
| | 4280 | | { |
| | 4281 | | AreaDensity<T> measurement = new AreaDensity<T>(value |
| | 4282 | | , fromMassUnits1 |
| | 4283 | | , fromLengthUnits2 |
| | 4284 | | , fromLengthUnits3 |
| | 4285 | | ); |
| | 4286 | | return measurement[ |
| | 4287 | | toMassUnits1 |
| | 4288 | | , toLengthUnits2 |
| | 4289 | | , toLengthUnits3 |
| | 4290 | | ]; |
| | 4291 | | } |
| | 4292 | |
|
| | 4293 | | /// <summary>Converts a AreaDensity measurement from units to another.</summary> |
| | 4294 | | /// <param name="value">The value to convert the units of.</param> |
| | 4295 | | /// <param name="from">The current units of the measurement.</param> |
| | 4296 | | /// <param name="to">The desired units of the measurement.</param> |
| | 4297 | | /// <returns>The AreaDensity measurement converted into the desired units.</returns> |
| | 4298 | | public static T Convert(T value, |
| | 4299 | | MeasurementUnitsSyntaxTypes.AreaDensityBaseUnits from, |
| | 4300 | | MeasurementUnitsSyntaxTypes.AreaDensityBaseUnits to) |
| | 4301 | | { |
| | 4302 | | return Convert(value |
| | 4303 | | , from._MassUnits1 |
| | 4304 | | , from._LengthUnits2 |
| | 4305 | | , from._LengthUnits3 |
| | 4306 | | , to._MassUnits1 |
| | 4307 | | , to._LengthUnits2 |
| | 4308 | | , to._LengthUnits3 |
| | 4309 | | ); |
| | 4310 | | } |
| | 4311 | |
|
| | 4312 | | /// <summary>Parses a AreaDensity measurement string.</summary> |
| | 4313 | | /// <param name="string">The string to be parsed.</param> |
| | 4314 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 4315 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 4316 | | public static (bool Success, AreaDensity<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value)> t |
| | 4317 | |
|
| | 4318 | | #endregion |
| | 4319 | |
|
| | 4320 | | #region Constructors |
| | 4321 | |
|
| | 4322 | | /// <summary>Constructs an AreaDensity with the measurement value and units.</summary> |
| | 4323 | | /// <param name="measurement">The measurement value of the AreaDensity.</param> |
| | 4324 | | /// <param name="units">The units of the AreaDensity.</param> |
| | 4325 | | public AreaDensity(T measurement, MeasurementUnitsSyntaxTypes.AreaDensityBaseUnits units) : this(measurement |
| | 4326 | | , units._MassUnits1 |
| | 4327 | | , units._LengthUnits2 |
| | 4328 | | , units._LengthUnits3 |
| | 4329 | | ) { } |
| | 4330 | |
|
| | 4331 | |
|
| | 4332 | | /// <summary>Constructs an AreaDensity with the measurement value and units.</summary> |
| | 4333 | | /// <param name="measurement">The measurement value of the AreaDensity.</param> |
| | 4334 | | /// <param name="MassUnits1">The units of the AreaDensity.</param> |
| | 4335 | | /// <param name="LengthUnits2">The units of the AreaDensity.</param> |
| | 4336 | | /// <param name="LengthUnits3">The units of the AreaDensity.</param> |
| | 4337 | | public AreaDensity(T measurement |
| | 4338 | | , Mass.Units MassUnits1 |
| | 4339 | | , Length.Units LengthUnits2 |
| | 4340 | | , Length.Units LengthUnits3 |
| | 4341 | | ) |
| | 4342 | | { |
| | 4343 | | _measurement = measurement; |
| | 4344 | | _MassUnits1 = MassUnits1; |
| | 4345 | | _LengthUnits2 = LengthUnits2; |
| | 4346 | | _LengthUnits3 = LengthUnits3; |
| | 4347 | | } |
| | 4348 | |
|
| | 4349 | | #endregion |
| | 4350 | |
|
| | 4351 | | #region Properties |
| | 4352 | |
|
| | 4353 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 4354 | | public Mass.Units MassUnits1 |
| | 4355 | | { |
| | 4356 | | get { return _MassUnits1; } |
| | 4357 | | set |
| | 4358 | | { |
| | 4359 | | if (value != _MassUnits1) |
| | 4360 | | { |
| | 4361 | | _measurement = this[value, _LengthUnits2, _LengthUnits3]; |
| | 4362 | | _MassUnits1 = value; |
| | 4363 | | } |
| | 4364 | | } |
| | 4365 | | } |
| | 4366 | |
|
| | 4367 | | /// <summary>The #2 component of this measurements units.</summary> |
| | 4368 | | public Length.Units LengthUnits2 |
| | 4369 | | { |
| | 4370 | | get { return _LengthUnits2; } |
| | 4371 | | set |
| | 4372 | | { |
| | 4373 | | if (value != _LengthUnits2) |
| | 4374 | | { |
| | 4375 | | _measurement = this[_MassUnits1, value, _LengthUnits3]; |
| | 4376 | | _LengthUnits2 = value; |
| | 4377 | | } |
| | 4378 | | } |
| | 4379 | | } |
| | 4380 | |
|
| | 4381 | | /// <summary>The #3 component of this measurements units.</summary> |
| | 4382 | | public Length.Units LengthUnits3 |
| | 4383 | | { |
| | 4384 | | get { return _LengthUnits3; } |
| | 4385 | | set |
| | 4386 | | { |
| | 4387 | | if (value != _LengthUnits3) |
| | 4388 | | { |
| | 4389 | | _measurement = this[_MassUnits1, _LengthUnits2, value]; |
| | 4390 | | _LengthUnits3 = value; |
| | 4391 | | } |
| | 4392 | | } |
| | 4393 | | } |
| | 4394 | |
|
| | 4395 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 4396 | | /// <param name="units">The units to get the measurement in.</param> |
| | 4397 | | /// <returns>The measurement value in the specified units.</returns> |
| | 4398 | | public T this[MeasurementUnitsSyntaxTypes.AreaDensityBaseUnits units] |
| | 4399 | | { |
| | 4400 | | get { return this[units._MassUnits1, units._LengthUnits2, units._LengthUnits3]; } |
| | 4401 | | } |
| | 4402 | |
|
| | 4403 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 4404 | | /// <param name="MassUnits1">The #1 component of this measurements units.</param> |
| | 4405 | | /// <param name="LengthUnits2">The #2 component of this measurements units.</param> |
| | 4406 | | /// <param name="LengthUnits3">The #3 component of this measurements units.</param> |
| | 4407 | | /// <returns>The measurement value in the specified units.</returns> |
| | 4408 | | public T this[Mass.Units MassUnits1, Length.Units LengthUnits2, Length.Units LengthUnits3] |
| | 4409 | | { |
| | 4410 | | get |
| | 4411 | | { |
| | 4412 | | T measurement = _measurement; |
| | 4413 | | if (MassUnits1 != _MassUnits1) |
| | 4414 | | { |
| | 4415 | | measurement = Mass<T>.Table[(int)_MassUnits1][(int)MassUnits1](measurement); |
| | 4416 | | //if (MassUnits1 < _MassUnits1) |
| | 4417 | | //{ |
| | 4418 | | // measurement = Mass<T>.Table[(int)_MassUnits1][(int)MassUnits1](measurement); |
| | 4419 | | //} |
| | 4420 | | //else |
| | 4421 | | //{ |
| | 4422 | | // measurement = Mass<T>.Table[(int)MassUnits1][(int)_MassUnits1](measurement); |
| | 4423 | | //} |
| | 4424 | | } |
| | 4425 | | if (LengthUnits2 != _LengthUnits2) |
| | 4426 | | { |
| | 4427 | | measurement = Length<T>.Table[(int)LengthUnits2][(int)_LengthUnits2](measurement); |
| | 4428 | | //if (LengthUnits2 > _LengthUnits2) |
| | 4429 | | //{ |
| | 4430 | | // measurement = Length<T>.Table[(int)_LengthUnits2][(int)LengthUnits2](measurement); |
| | 4431 | | //} |
| | 4432 | | //else |
| | 4433 | | //{ |
| | 4434 | | // measurement = Length<T>.Table[(int)LengthUnits2][(int)_LengthUnits2](measurement); |
| | 4435 | | //} |
| | 4436 | | } |
| | 4437 | | if (LengthUnits3 != _LengthUnits3) |
| | 4438 | | { |
| | 4439 | | measurement = Length<T>.Table[(int)LengthUnits3][(int)_LengthUnits3](measurement); |
| | 4440 | | //if (LengthUnits3 > _LengthUnits3) |
| | 4441 | | //{ |
| | 4442 | | // measurement = Length<T>.Table[(int)_LengthUnits3][(int)LengthUnits3](measurement); |
| | 4443 | | //} |
| | 4444 | | //else |
| | 4445 | | //{ |
| | 4446 | | // measurement = Length<T>.Table[(int)LengthUnits3][(int)_LengthUnits3](measurement); |
| | 4447 | | //} |
| | 4448 | | } |
| | 4449 | | return measurement; |
| | 4450 | | } |
| | 4451 | | } |
| | 4452 | |
|
| | 4453 | | #endregion |
| | 4454 | |
|
| | 4455 | | #region Casting Operators |
| | 4456 | |
|
| | 4457 | | /// <summary>Converts a ValueTuple to a AreaDensity measurement.</summary> |
| | 4458 | | /// <param name="valueTuple">The ValueTuple to converted into a AreaDensity measurement.</param> |
| | 4459 | | public static implicit operator AreaDensity<T>((T, MeasurementUnitsSyntaxTypes.AreaDensityBaseUnits) valueTuple) |
| | 4460 | | { |
| | 4461 | | return new AreaDensity<T>(valueTuple.Item1, valueTuple.Item2); |
| | 4462 | | } |
| | 4463 | |
|
| | 4464 | | #endregion |
| | 4465 | |
|
| | 4466 | | #region Mathematics |
| | 4467 | |
|
| | 4468 | | #region Bases |
| | 4469 | |
|
| | 4470 | | internal static AreaDensity<T> MathBase(AreaDensity<T> a, T b, Func<T, T, T> func) |
| | 4471 | | { |
| | 4472 | | return new AreaDensity<T>(func(a._measurement, b) |
| | 4473 | | , a._MassUnits1 |
| | 4474 | | , a._LengthUnits2 |
| | 4475 | | , a._LengthUnits3 |
| | 4476 | | ); |
| | 4477 | | } |
| | 4478 | |
|
| | 4479 | | internal static AreaDensity<T> MathBase(AreaDensity<T> a, AreaDensity<T> b, Func<T, T, T> func) |
| | 4480 | | { |
| | 4481 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 4482 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 4483 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits3 ? a._LengthUnits3 : b._LengthUnits3; |
| | 4484 | | T A = a[MassUnits1, LengthUnits2, LengthUnits3]; |
| | 4485 | | T B = b[MassUnits1, LengthUnits2, LengthUnits3]; |
| | 4486 | | T C = func(A, B); |
| | 4487 | | return new AreaDensity<T>(C, MassUnits1, LengthUnits2, LengthUnits3); |
| | 4488 | | } |
| | 4489 | |
|
| | 4490 | | internal static bool LogicBase(AreaDensity<T> a, AreaDensity<T> b, Func<T, T, bool> func) |
| | 4491 | | { |
| | 4492 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 4493 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 4494 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits3 ? a._LengthUnits3 : b._LengthUnits3; |
| | 4495 | | T A = a[MassUnits1, LengthUnits2, LengthUnits3]; |
| | 4496 | | T B = b[MassUnits1, LengthUnits2, LengthUnits3]; |
| | 4497 | | return func(A, B); |
| | 4498 | | } |
| | 4499 | |
|
| | 4500 | | #endregion |
| | 4501 | |
|
| | 4502 | | #region Add |
| | 4503 | |
|
| | 4504 | | /// <summary>Adds two AreaDensity measurements.</summary> |
| | 4505 | | /// <param name="a">The first operand of the addition.</param> |
| | 4506 | | /// <param name="b">The second operand of the addition.</param> |
| | 4507 | | /// <returns>The result of the addition operation.</returns> |
| | 4508 | | public static AreaDensity<T> Add(AreaDensity<T> a, AreaDensity<T> b) |
| | 4509 | | { |
| | 4510 | | return MathBase(a, b, Statics.Addition); |
| | 4511 | | } |
| | 4512 | |
|
| | 4513 | | /// <summary>Adds two AreaDensity measurements.</summary> |
| | 4514 | | /// <param name="a">The first operand of the addition.</param> |
| | 4515 | | /// <param name="b">The second operand of the addition.</param> |
| | 4516 | | /// <returns>The result of the addition operation.</returns> |
| | 4517 | | public static AreaDensity<T> operator +(AreaDensity<T> a, AreaDensity<T> b) |
| | 4518 | | { |
| | 4519 | | return Add(a, b); |
| | 4520 | | } |
| | 4521 | |
|
| | 4522 | | /// <summary>Adds two AreaDensity measurements.</summary> |
| | 4523 | | /// <param name="b">The second operand of the addition.</param> |
| | 4524 | | /// <returns>The result of the addition operation.</returns> |
| | 4525 | | public AreaDensity<T> Add(AreaDensity<T> b) |
| | 4526 | | { |
| | 4527 | | return this + b; |
| | 4528 | | } |
| | 4529 | |
|
| | 4530 | | #endregion |
| | 4531 | |
|
| | 4532 | | #region Subtract |
| | 4533 | |
|
| | 4534 | | /// <summary>Subtracts two AreaDensity measurements.</summary> |
| | 4535 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 4536 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 4537 | | /// <returns>The result of the subtraction.</returns> |
| | 4538 | | public static AreaDensity<T> Subtract(AreaDensity<T> a, AreaDensity<T> b) |
| | 4539 | | { |
| | 4540 | | return MathBase(a, b, Statics.Subtraction); |
| | 4541 | | } |
| | 4542 | |
|
| | 4543 | | /// <summary>Subtracts two AreaDensity measurements.</summary> |
| | 4544 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 4545 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 4546 | | /// <returns>The result of the subtraction.</returns> |
| | 4547 | | public static AreaDensity<T> operator -(AreaDensity<T> a, AreaDensity<T> b) |
| | 4548 | | { |
| | 4549 | | return Subtract(a, b); |
| | 4550 | | } |
| | 4551 | |
|
| | 4552 | | /// <summary>Subtracts two AreaDensity measurements.</summary> |
| | 4553 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 4554 | | /// <returns>The result of the subtraction.</returns> |
| | 4555 | | public AreaDensity<T> Subtract(AreaDensity<T> b) |
| | 4556 | | { |
| | 4557 | | return this - b; |
| | 4558 | | } |
| | 4559 | |
|
| | 4560 | | #endregion |
| | 4561 | |
|
| | 4562 | | #region Multiply |
| | 4563 | |
|
| | 4564 | | /// <summary>Multiplies an AreaDensity by a scalar numeric value.</summary> |
| | 4565 | | /// <param name="a">The AreaDensity measurement to multiply.</param> |
| | 4566 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 4567 | | /// <returns>The result of the multiplication.</returns> |
| | 4568 | | public static AreaDensity<T> Multiply(AreaDensity<T> a, T b) |
| | 4569 | | { |
| | 4570 | | return MathBase(a, b, Statics.Multiplication); |
| | 4571 | | } |
| | 4572 | |
|
| | 4573 | | /// <summary>Multiplies an AreaDensity by a scalar numeric value.</summary> |
| | 4574 | | /// <param name="a">The AreaDensity measurement to multiply.</param> |
| | 4575 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 4576 | | /// <returns>The result of the multiplication.</returns> |
| | 4577 | | public static AreaDensity<T> Multiply(T b, AreaDensity<T> a) |
| | 4578 | | { |
| | 4579 | | return Multiply(a, b); |
| | 4580 | | } |
| | 4581 | |
|
| | 4582 | | /// <summary>Multiplies an AreaDensity by a scalar numeric value.</summary> |
| | 4583 | | /// <param name="a">The AreaDensity measurement to multiply.</param> |
| | 4584 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 4585 | | /// <returns>The result of the multiplication.</returns> |
| | 4586 | | public static AreaDensity<T> operator *(AreaDensity<T> a, T b) |
| | 4587 | | { |
| | 4588 | | return Multiply(a, b); |
| | 4589 | | } |
| | 4590 | |
|
| | 4591 | | /// <summary>Multiplies an AreaDensity by a scalar numeric value.</summary> |
| | 4592 | | /// <param name="a">The AreaDensity measurement to multiply.</param> |
| | 4593 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 4594 | | /// <returns>The result of the multiplication.</returns> |
| | 4595 | | public static AreaDensity<T> operator *(T b, AreaDensity<T> a) |
| | 4596 | | { |
| | 4597 | | return Multiply(b, a); |
| | 4598 | | } |
| | 4599 | |
|
| | 4600 | | /// <summary>Multiplies an AreaDensity by a scalar numeric value.</summary> |
| | 4601 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 4602 | | /// <returns>The result of the multiplication.</returns> |
| | 4603 | | public AreaDensity<T> Add(T b) |
| | 4604 | | { |
| | 4605 | | return this * b; |
| | 4606 | | } |
| | 4607 | |
|
| | 4608 | | #region AreaDensity<T> * Acceleration<T> = Pressure<T> |
| | 4609 | |
|
| | 4610 | | /// <summary>Mulitplies AreaDensity by Acceleration resulting in Pressure.</summary> |
| | 4611 | | /// <param name="a">The AreaDensity to be multiplied.</param> |
| | 4612 | | /// <param name="b">The Acceleration to multiply by.</param> |
| | 4613 | | /// <returns>The Pressure result of the multiplication.</returns> |
| | 4614 | | public static Pressure<T> Multiply(AreaDensity<T> a, Acceleration<T> b) |
| | 4615 | | { |
| | 4616 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 4617 | |
|
| | 4618 | | T A = a[a._MassUnits1, LengthUnits1, a._LengthUnits3]; |
| | 4619 | | T B = b[LengthUnits1, b._TimeUnits2, b._TimeUnits3]; |
| | 4620 | | T C = Statics.Multiplication(A, B); |
| | 4621 | |
|
| | 4622 | | return new Pressure<T>(C |
| | 4623 | | , a._MassUnits1 |
| | 4624 | | , a._LengthUnits3 |
| | 4625 | | , b._TimeUnits2 |
| | 4626 | | , b._TimeUnits3 |
| | 4627 | | ); |
| | 4628 | | } |
| | 4629 | |
|
| | 4630 | | /// <summary>Mulitplies AreaDensity by Acceleration resulting in Pressure.</summary> |
| | 4631 | | /// <param name="a">The AreaDensity to be multiplied.</param> |
| | 4632 | | /// <param name="b">The Acceleration to multiply by.</param> |
| | 4633 | | /// <returns>The Pressure result of the multiplication.</returns> |
| | 4634 | | public static Pressure<T> operator *(AreaDensity<T> a, Acceleration<T> b) |
| | 4635 | | { |
| | 4636 | | return Multiply(a, b); |
| | 4637 | | } |
| | 4638 | |
|
| | 4639 | | /// <summary>Mulitplies AreaDensity by Acceleration resulting in Pressure.</summary> |
| | 4640 | | /// <param name="b">The Acceleration to multiply by.</param> |
| | 4641 | | /// <returns>The Pressure result of the multiplication.</returns> |
| | 4642 | | public Pressure<T> Multiply(Acceleration<T> b) |
| | 4643 | | { |
| | 4644 | | return this * b; |
| | 4645 | | } |
| | 4646 | |
|
| | 4647 | | #endregion |
| | 4648 | |
|
| | 4649 | | #region AreaDensity<T> * Area<T> = Mass<T> |
| | 4650 | |
|
| | 4651 | | /// <summary>Mulitplies AreaDensity by Area resulting in Mass.</summary> |
| | 4652 | | /// <param name="a">The AreaDensity to be multiplied.</param> |
| | 4653 | | /// <param name="b">The Area to multiply by.</param> |
| | 4654 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 4655 | | public static Mass<T> Multiply(AreaDensity<T> a, Area<T> b) |
| | 4656 | | { |
| | 4657 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 4658 | | Length.Units LengthUnits2 = a._LengthUnits3 <= b._LengthUnits2 ? a._LengthUnits3 : b._LengthUnits2; |
| | 4659 | |
|
| | 4660 | | T A = a[a._MassUnits1, LengthUnits1, LengthUnits2]; |
| | 4661 | | T B = b[LengthUnits1, LengthUnits2]; |
| | 4662 | | T C = Statics.Multiplication(A, B); |
| | 4663 | |
|
| | 4664 | | return new Mass<T>(C |
| | 4665 | | , a._MassUnits1 |
| | 4666 | | ); |
| | 4667 | | } |
| | 4668 | |
|
| | 4669 | | /// <summary>Mulitplies AreaDensity by Area resulting in Mass.</summary> |
| | 4670 | | /// <param name="a">The AreaDensity to be multiplied.</param> |
| | 4671 | | /// <param name="b">The Area to multiply by.</param> |
| | 4672 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 4673 | | public static Mass<T> operator *(AreaDensity<T> a, Area<T> b) |
| | 4674 | | { |
| | 4675 | | return Multiply(a, b); |
| | 4676 | | } |
| | 4677 | |
|
| | 4678 | | /// <summary>Mulitplies AreaDensity by Area resulting in Mass.</summary> |
| | 4679 | | /// <param name="b">The Area to multiply by.</param> |
| | 4680 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 4681 | | public Mass<T> Multiply(Area<T> b) |
| | 4682 | | { |
| | 4683 | | return this * b; |
| | 4684 | | } |
| | 4685 | |
|
| | 4686 | | #endregion |
| | 4687 | |
|
| | 4688 | | #region AreaDensity<T> * Length<T> = LinearDensity<T> |
| | 4689 | |
|
| | 4690 | | /// <summary>Mulitplies AreaDensity by Length resulting in LinearDensity.</summary> |
| | 4691 | | /// <param name="a">The AreaDensity to be multiplied.</param> |
| | 4692 | | /// <param name="b">The Length to multiply by.</param> |
| | 4693 | | /// <returns>The LinearDensity result of the multiplication.</returns> |
| | 4694 | | public static LinearDensity<T> Multiply(AreaDensity<T> a, Length<T> b) |
| | 4695 | | { |
| | 4696 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 4697 | |
|
| | 4698 | | T A = a[a._MassUnits1, LengthUnits1, a._LengthUnits3]; |
| | 4699 | | T B = b[LengthUnits1]; |
| | 4700 | | T C = Statics.Multiplication(A, B); |
| | 4701 | |
|
| | 4702 | | return new LinearDensity<T>(C |
| | 4703 | | , a._MassUnits1 |
| | 4704 | | , a._LengthUnits3 |
| | 4705 | | ); |
| | 4706 | | } |
| | 4707 | |
|
| | 4708 | | /// <summary>Mulitplies AreaDensity by Length resulting in LinearDensity.</summary> |
| | 4709 | | /// <param name="a">The AreaDensity to be multiplied.</param> |
| | 4710 | | /// <param name="b">The Length to multiply by.</param> |
| | 4711 | | /// <returns>The LinearDensity result of the multiplication.</returns> |
| | 4712 | | public static LinearDensity<T> operator *(AreaDensity<T> a, Length<T> b) |
| | 4713 | | { |
| | 4714 | | return Multiply(a, b); |
| | 4715 | | } |
| | 4716 | |
|
| | 4717 | | /// <summary>Mulitplies AreaDensity by Length resulting in LinearDensity.</summary> |
| | 4718 | | /// <param name="b">The Length to multiply by.</param> |
| | 4719 | | /// <returns>The LinearDensity result of the multiplication.</returns> |
| | 4720 | | public LinearDensity<T> Multiply(Length<T> b) |
| | 4721 | | { |
| | 4722 | | return this * b; |
| | 4723 | | } |
| | 4724 | |
|
| | 4725 | | #endregion |
| | 4726 | |
|
| | 4727 | | #region AreaDensity<T> * Volume<T> = LinearMass<T> |
| | 4728 | |
|
| | 4729 | | /// <summary>Mulitplies AreaDensity by Volume resulting in LinearMass.</summary> |
| | 4730 | | /// <param name="a">The AreaDensity to be multiplied.</param> |
| | 4731 | | /// <param name="b">The Volume to multiply by.</param> |
| | 4732 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 4733 | | public static LinearMass<T> Multiply(AreaDensity<T> a, Volume<T> b) |
| | 4734 | | { |
| | 4735 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 4736 | | Length.Units LengthUnits2 = a._LengthUnits3 <= b._LengthUnits2 ? a._LengthUnits3 : b._LengthUnits2; |
| | 4737 | |
|
| | 4738 | | T A = a[a._MassUnits1, LengthUnits1, LengthUnits2]; |
| | 4739 | | T B = b[LengthUnits1, LengthUnits2, b._LengthUnits3]; |
| | 4740 | | T C = Statics.Multiplication(A, B); |
| | 4741 | |
|
| | 4742 | | return new LinearMass<T>(C |
| | 4743 | | , a._MassUnits1 |
| | 4744 | | , b._LengthUnits3 |
| | 4745 | | ); |
| | 4746 | | } |
| | 4747 | |
|
| | 4748 | | /// <summary>Mulitplies AreaDensity by Volume resulting in LinearMass.</summary> |
| | 4749 | | /// <param name="a">The AreaDensity to be multiplied.</param> |
| | 4750 | | /// <param name="b">The Volume to multiply by.</param> |
| | 4751 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 4752 | | public static LinearMass<T> operator *(AreaDensity<T> a, Volume<T> b) |
| | 4753 | | { |
| | 4754 | | return Multiply(a, b); |
| | 4755 | | } |
| | 4756 | |
|
| | 4757 | | /// <summary>Mulitplies AreaDensity by Volume resulting in LinearMass.</summary> |
| | 4758 | | /// <param name="b">The Volume to multiply by.</param> |
| | 4759 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 4760 | | public LinearMass<T> Multiply(Volume<T> b) |
| | 4761 | | { |
| | 4762 | | return this * b; |
| | 4763 | | } |
| | 4764 | |
|
| | 4765 | | #endregion |
| | 4766 | |
|
| | 4767 | | #region AreaDensity<T> * VolumeRate<T> = LinearMassFlow<T> |
| | 4768 | |
|
| | 4769 | | /// <summary>Mulitplies AreaDensity by VolumeRate resulting in LinearMassFlow.</summary> |
| | 4770 | | /// <param name="a">The AreaDensity to be multiplied.</param> |
| | 4771 | | /// <param name="b">The VolumeRate to multiply by.</param> |
| | 4772 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 4773 | | public static LinearMassFlow<T> Multiply(AreaDensity<T> a, VolumeRate<T> b) |
| | 4774 | | { |
| | 4775 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 4776 | | Length.Units LengthUnits2 = a._LengthUnits3 <= b._LengthUnits2 ? a._LengthUnits3 : b._LengthUnits2; |
| | 4777 | |
|
| | 4778 | | T A = a[a._MassUnits1, LengthUnits1, LengthUnits2]; |
| | 4779 | | T B = b[LengthUnits1, LengthUnits2, b._LengthUnits3, b._TimeUnits4]; |
| | 4780 | | T C = Statics.Multiplication(A, B); |
| | 4781 | |
|
| | 4782 | | return new LinearMassFlow<T>(C |
| | 4783 | | , a._MassUnits1 |
| | 4784 | | , b._LengthUnits3 |
| | 4785 | | , b._TimeUnits4 |
| | 4786 | | ); |
| | 4787 | | } |
| | 4788 | |
|
| | 4789 | | /// <summary>Mulitplies AreaDensity by VolumeRate resulting in LinearMassFlow.</summary> |
| | 4790 | | /// <param name="a">The AreaDensity to be multiplied.</param> |
| | 4791 | | /// <param name="b">The VolumeRate to multiply by.</param> |
| | 4792 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 4793 | | public static LinearMassFlow<T> operator *(AreaDensity<T> a, VolumeRate<T> b) |
| | 4794 | | { |
| | 4795 | | return Multiply(a, b); |
| | 4796 | | } |
| | 4797 | |
|
| | 4798 | | /// <summary>Mulitplies AreaDensity by VolumeRate resulting in LinearMassFlow.</summary> |
| | 4799 | | /// <param name="b">The VolumeRate to multiply by.</param> |
| | 4800 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 4801 | | public LinearMassFlow<T> Multiply(VolumeRate<T> b) |
| | 4802 | | { |
| | 4803 | | return this * b; |
| | 4804 | | } |
| | 4805 | |
|
| | 4806 | | #endregion |
| | 4807 | |
|
| | 4808 | | #endregion |
| | 4809 | |
|
| | 4810 | | #region Divide |
| | 4811 | |
|
| | 4812 | | /// <summary>Divides an AreaDensity measurement by another AreaDensity measurement resulting in a scalar numeric val |
| | 4813 | | /// <param name="a">The first operand of the division operation.</param> |
| | 4814 | | /// <param name="b">The second operand of the division operation.</param> |
| | 4815 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 4816 | | public static T Divide(AreaDensity<T> a, AreaDensity<T> b) |
| | 4817 | | { |
| | 4818 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 4819 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 4820 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits3 ? a._LengthUnits3 : b._LengthUnits3; |
| | 4821 | | T A = a[MassUnits1, LengthUnits2, LengthUnits3]; |
| | 4822 | | T B = b[MassUnits1, LengthUnits2, LengthUnits3]; |
| | 4823 | | return Statics.Division(A, B); |
| | 4824 | | } |
| | 4825 | |
|
| | 4826 | | /// <summary>Divides this AreaDensity measurement by a numaric scalar value.</summary> |
| | 4827 | | /// <param name="a">The AreaDensity measurement to divide.</param> |
| | 4828 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 4829 | | /// <returns>The result of the division.</returns> |
| | 4830 | | public static AreaDensity<T> Divide(AreaDensity<T> a, T b) |
| | 4831 | | { |
| | 4832 | | return MathBase(a, b, Statics.Division); |
| | 4833 | | } |
| | 4834 | |
|
| | 4835 | | /// <summary>Divides this AreaDensity measurement by a numaric scalar value.</summary> |
| | 4836 | | /// <param name="a">The AreaDensity measurement to divide.</param> |
| | 4837 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 4838 | | /// <returns>The result of the division.</returns> |
| | 4839 | | public static AreaDensity<T> operator /(AreaDensity<T> a, T b) |
| | 4840 | | { |
| | 4841 | | return Divide(a, b); |
| | 4842 | | } |
| | 4843 | |
|
| | 4844 | | /// <summary>Divides this AreaDensity measurement by a numaric scalar value.</summary> |
| | 4845 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 4846 | | /// <returns>The result of the division.</returns> |
| | 4847 | | public AreaDensity<T> Divide(T b) |
| | 4848 | | { |
| | 4849 | | return this / b; |
| | 4850 | | } |
| | 4851 | |
|
| | 4852 | | /// <summary>Divides an AreaDensity measurement by another AreaDensity measurement resulting in a scalar numeric val |
| | 4853 | | /// <param name="a">The first operand of the division operation.</param> |
| | 4854 | | /// <param name="b">The second operand of the division operation.</param> |
| | 4855 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 4856 | | public static T operator /(AreaDensity<T> a, AreaDensity<T> b) |
| | 4857 | | { |
| | 4858 | | return Divide(a, b); |
| | 4859 | | } |
| | 4860 | |
|
| | 4861 | | /// <summary>Divides an AreaDensity measurement by another AreaDensity measurement resulting in a scalar numeric val |
| | 4862 | | /// <param name="b">The second operand of the division operation.</param> |
| | 4863 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 4864 | | public T Divide(AreaDensity<T> b) |
| | 4865 | | { |
| | 4866 | | return this / b; |
| | 4867 | | } |
| | 4868 | |
|
| | 4869 | |
|
| | 4870 | | #region AreaDensity<T> / Density<T> = Length<T> |
| | 4871 | |
|
| | 4872 | | /// <summary>Divides AreaDensity by Density resulting in Length.</summary> |
| | 4873 | | /// <param name="a">The AreaDensity to be divided.</param> |
| | 4874 | | /// <param name="b">The Density to divide by.</param> |
| | 4875 | | /// <returns>The Length result of the division.</returns> |
| | 4876 | | public static Length<T> Divide(AreaDensity<T> a, Density<T> b) |
| | 4877 | | { |
| | 4878 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 4879 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 4880 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits3 ? a._LengthUnits3 : b._LengthUnits3; |
| | 4881 | |
|
| | 4882 | | T A = a[MassUnits1, LengthUnits2, LengthUnits3]; |
| | 4883 | | T B = b[MassUnits1, LengthUnits2, LengthUnits3, b._LengthUnits4]; |
| | 4884 | | T C = Statics.Division(A, B); |
| | 4885 | |
|
| | 4886 | | return new Length<T>(C |
| | 4887 | | , b._LengthUnits4 |
| | 4888 | | ); |
| | 4889 | | } |
| | 4890 | |
|
| | 4891 | | /// <summary>Divides AreaDensity by Density resulting in Length.</summary> |
| | 4892 | | /// <param name="a">The AreaDensity to be divided.</param> |
| | 4893 | | /// <param name="b">The Density to divide by.</param> |
| | 4894 | | /// <returns>The Length result of the division.</returns> |
| | 4895 | | public static Length<T> operator /(AreaDensity<T> a, Density<T> b) |
| | 4896 | | { |
| | 4897 | | return Divide(a, b); |
| | 4898 | | } |
| | 4899 | |
|
| | 4900 | | /// <summary>Divides AreaDensity by Density resulting in Length.</summary> |
| | 4901 | | /// <param name="b">The Density to divide by.</param> |
| | 4902 | | /// <returns>The Length result of the division.</returns> |
| | 4903 | | public Length<T> Divide(Density<T> b) |
| | 4904 | | { |
| | 4905 | | return this / b; |
| | 4906 | | } |
| | 4907 | |
|
| | 4908 | | #endregion |
| | 4909 | |
|
| | 4910 | |
|
| | 4911 | | #region AreaDensity<T> / Length<T> = Density<T> |
| | 4912 | |
|
| | 4913 | | /// <summary>Divides AreaDensity by Length resulting in Density.</summary> |
| | 4914 | | /// <param name="a">The AreaDensity to be divided.</param> |
| | 4915 | | /// <param name="b">The Length to divide by.</param> |
| | 4916 | | /// <returns>The Density result of the division.</returns> |
| | 4917 | | public static Density<T> Divide(AreaDensity<T> a, Length<T> b) |
| | 4918 | | { |
| | 4919 | |
|
| | 4920 | | T A = a[a._MassUnits1, a._LengthUnits2, a._LengthUnits3]; |
| | 4921 | | T B = b[b._LengthUnits1]; |
| | 4922 | | T C = Statics.Division(A, B); |
| | 4923 | |
|
| | 4924 | | return new Density<T>(C |
| | 4925 | | , a._MassUnits1 |
| | 4926 | | , a._LengthUnits2 |
| | 4927 | | , a._LengthUnits3 |
| | 4928 | | , b._LengthUnits1 |
| | 4929 | | ); |
| | 4930 | | } |
| | 4931 | |
|
| | 4932 | | /// <summary>Divides AreaDensity by Length resulting in Density.</summary> |
| | 4933 | | /// <param name="a">The AreaDensity to be divided.</param> |
| | 4934 | | /// <param name="b">The Length to divide by.</param> |
| | 4935 | | /// <returns>The Density result of the division.</returns> |
| | 4936 | | public static Density<T> operator /(AreaDensity<T> a, Length<T> b) |
| | 4937 | | { |
| | 4938 | | return Divide(a, b); |
| | 4939 | | } |
| | 4940 | |
|
| | 4941 | | /// <summary>Divides AreaDensity by Length resulting in Density.</summary> |
| | 4942 | | /// <param name="b">The Length to divide by.</param> |
| | 4943 | | /// <returns>The Density result of the division.</returns> |
| | 4944 | | public Density<T> Divide(Length<T> b) |
| | 4945 | | { |
| | 4946 | | return this / b; |
| | 4947 | | } |
| | 4948 | |
|
| | 4949 | | #endregion |
| | 4950 | |
|
| | 4951 | | #endregion |
| | 4952 | |
|
| | 4953 | | #region LessThan |
| | 4954 | |
|
| | 4955 | | /// <summary>Determines if an AreaDensity measurement is less than another AreaDensity measurement.</summary> |
| | 4956 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 4957 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 4958 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 4959 | | public static bool LessThan(AreaDensity<T> a, AreaDensity<T> b) |
| | 4960 | | { |
| | 4961 | | return LogicBase(a, b, Statics.LessThan); |
| | 4962 | | } |
| | 4963 | |
|
| | 4964 | | /// <summary>Determines if an AreaDensity measurement is less than another AreaDensity measurement.</summary> |
| | 4965 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 4966 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 4967 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 4968 | | public static bool operator <(AreaDensity<T> a, AreaDensity<T> b) |
| | 4969 | | { |
| | 4970 | | return LessThan(a, b); |
| | 4971 | | } |
| | 4972 | |
|
| | 4973 | | /// <summary>Determines if an AreaDensity measurement is less than another AreaDensity measurement.</summary> |
| | 4974 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 4975 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 4976 | | public bool LessThan(AreaDensity<T> b) |
| | 4977 | | { |
| | 4978 | | return this < b; |
| | 4979 | | } |
| | 4980 | |
|
| | 4981 | | #endregion |
| | 4982 | |
|
| | 4983 | | #region GreaterThan |
| | 4984 | |
|
| | 4985 | | /// <summary>Determines if an AreaDensity measurement is greater than another AreaDensity measurement.</summary> |
| | 4986 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 4987 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 4988 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 4989 | | public static bool GreaterThan(AreaDensity<T> a, AreaDensity<T> b) |
| | 4990 | | { |
| | 4991 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 4992 | | } |
| | 4993 | |
|
| | 4994 | | /// <summary>Determines if an AreaDensity measurement is greater than another AreaDensity measurement.</summary> |
| | 4995 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 4996 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 4997 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 4998 | | public static bool operator >(AreaDensity<T> a, AreaDensity<T> b) |
| | 4999 | | { |
| | 5000 | | return GreaterThan(a, b); |
| | 5001 | | } |
| | 5002 | |
|
| | 5003 | | /// <summary>Determines if an AreaDensity measurement is greater than another AreaDensity measurement.</summary> |
| | 5004 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 5005 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 5006 | | public bool GreaterThan(AreaDensity<T> b) |
| | 5007 | | { |
| | 5008 | | return this > b; |
| | 5009 | | } |
| | 5010 | |
|
| | 5011 | | #endregion |
| | 5012 | |
|
| | 5013 | | #region LessThanOrEqual |
| | 5014 | |
|
| | 5015 | | /// <summary>Determines if an AreaDensity measurement is less than or equal to another AreaDensity measurement.</sum |
| | 5016 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 5017 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 5018 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 5019 | | public static bool LessThanOrEqual(AreaDensity<T> a, AreaDensity<T> b) |
| | 5020 | | { |
| | 5021 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 5022 | | } |
| | 5023 | |
|
| | 5024 | | /// <summary>Determines if an AreaDensity measurement is less than or equal to another AreaDensity measurement.</sum |
| | 5025 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 5026 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 5027 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 5028 | | public static bool operator <=(AreaDensity<T> a, AreaDensity<T> b) |
| | 5029 | | { |
| | 5030 | | return LessThanOrEqual(a, b); |
| | 5031 | | } |
| | 5032 | |
|
| | 5033 | | /// <summary>Determines if an AreaDensity measurement is less than or equal to another AreaDensity measurement.</sum |
| | 5034 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 5035 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 5036 | | public bool LessThanOrEqual(AreaDensity<T> b) |
| | 5037 | | { |
| | 5038 | | return this <= b; |
| | 5039 | | } |
| | 5040 | |
|
| | 5041 | | #endregion |
| | 5042 | |
|
| | 5043 | | #region GreaterThanOrEqual |
| | 5044 | |
|
| | 5045 | | /// <summary>Determines if an AreaDensity measurement is greater than or equal to another AreaDensity measurement.</ |
| | 5046 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 5047 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 5048 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 5049 | | public static bool GreaterThanOrEqual(AreaDensity<T> a, AreaDensity<T> b) |
| | 5050 | | { |
| | 5051 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 5052 | | } |
| | 5053 | |
|
| | 5054 | | /// <summary>Determines if an AreaDensity measurement is greater than or equal to another AreaDensity measurement.</ |
| | 5055 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 5056 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 5057 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 5058 | | public static bool operator >=(AreaDensity<T> a, AreaDensity<T> b) |
| | 5059 | | { |
| | 5060 | | return GreaterThanOrEqual(a, b); |
| | 5061 | | } |
| | 5062 | |
|
| | 5063 | | /// <summary>Determines if an AreaDensity measurement is greater than or equal to another AreaDensity measurement.</ |
| | 5064 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 5065 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 5066 | | public bool GreaterThanOrEqual(AreaDensity<T> b) |
| | 5067 | | { |
| | 5068 | | return this >= b; |
| | 5069 | | } |
| | 5070 | |
|
| | 5071 | | #endregion |
| | 5072 | |
|
| | 5073 | | #region Equal |
| | 5074 | |
|
| | 5075 | | /// <summary>Determines if an AreaDensity measurement is equal to another AreaDensity measurement.</summary> |
| | 5076 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 5077 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 5078 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 5079 | | public static bool Equal(AreaDensity<T> a, AreaDensity<T> b) |
| | 5080 | | { |
| | 5081 | | return LogicBase(a, b, Statics.Equate); |
| | 5082 | | } |
| | 5083 | |
|
| | 5084 | | /// <summary>Determines if an AreaDensity measurement is equal to another AreaDensity measurement.</summary> |
| | 5085 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 5086 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 5087 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 5088 | | public static bool operator ==(AreaDensity<T> a, AreaDensity<T> b) |
| | 5089 | | { |
| | 5090 | | return Equal(a, b); |
| | 5091 | | } |
| | 5092 | |
|
| | 5093 | | /// <summary>Determines if an AreaDensity measurement is equal to another AreaDensity measurement.</summary> |
| | 5094 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 5095 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 5096 | | public bool Equal(AreaDensity<T> b) |
| | 5097 | | { |
| | 5098 | | return this == b; |
| | 5099 | | } |
| | 5100 | |
|
| | 5101 | | #endregion |
| | 5102 | |
|
| | 5103 | | #region NotEqual |
| | 5104 | |
|
| | 5105 | | /// <summary>Determines if an AreaDensity measurement is not equal to another AreaDensity measurement.</summary> |
| | 5106 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 5107 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 5108 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 5109 | | public static bool NotEqual(AreaDensity<T> a, AreaDensity<T> b) |
| | 5110 | | { |
| | 5111 | | return LogicBase(a, b, Statics.Inequate); |
| | 5112 | | } |
| | 5113 | |
|
| | 5114 | | /// <summary>Determines if an AreaDensity measurement is not equal to another AreaDensity measurement.</summary> |
| | 5115 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 5116 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 5117 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 5118 | | public static bool operator !=(AreaDensity<T> a, AreaDensity<T> b) |
| | 5119 | | { |
| | 5120 | | return NotEqual(a, b); |
| | 5121 | | } |
| | 5122 | |
|
| | 5123 | | /// <summary>Determines if an AreaDensity measurement is not equal to another AreaDensity measurement.</summary> |
| | 5124 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 5125 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 5126 | | public bool NotEqual(AreaDensity<T> b) |
| | 5127 | | { |
| | 5128 | | return this != b; |
| | 5129 | | } |
| | 5130 | |
|
| | 5131 | | #endregion |
| | 5132 | |
|
| | 5133 | | #endregion |
| | 5134 | |
|
| | 5135 | | #region Overrides |
| | 5136 | |
|
| | 5137 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 5138 | | /// <param name="obj">The object to check for equality with.</param> |
| | 5139 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 5140 | | public override bool Equals(object obj) |
| | 5141 | | { |
| | 5142 | | if (obj is AreaDensity<T>) |
| | 5143 | | { |
| | 5144 | | return this == (AreaDensity<T>)obj; |
| | 5145 | | } |
| | 5146 | | return false; |
| | 5147 | | } |
| | 5148 | |
|
| | 5149 | | /// <summary>Converts the AreaDensity measurement to a string represenation.</summary> |
| | 5150 | | /// <returns>The string representation of the measurement.</returns> |
| | 5151 | | public override string ToString() |
| | 5152 | | { |
| | 5153 | | return _measurement + " " + |
| | 5154 | | _MassUnits1 |
| | 5155 | | + "/" + |
| | 5156 | | _LengthUnits2 + "/" + _LengthUnits3 |
| | 5157 | | ; |
| | 5158 | | } |
| | 5159 | |
|
| | 5160 | | /// <summary>Base hashing function for AreaDensity measurements.</summary> |
| | 5161 | | /// <returns>Computed hash code for this instance.</returns> |
| | 5162 | | public override int GetHashCode() => Hash(_measurement); |
| | 5163 | |
|
| | 5164 | | #endregion |
| | 5165 | | } |
| | 5166 | |
|
| | 5167 | | #endregion |
| | 5168 | |
|
| | 5169 | | #region Density |
| | 5170 | |
|
| | 5171 | | internal static partial class ParsingFunctions |
| | 5172 | | { |
| | 5173 | | [Measurement.Parseable("Mass/Length/Length/Length")] |
| | 5174 | | public static object Density<T>(T value, object[] units) |
| | 5175 | | { |
| | 5176 | | if (units.Length != 4) |
| | 5177 | | { |
| | 5178 | | throw new Exception("Bug in Towel. Invalid parameters to Density Factory."); |
| | 5179 | | } |
| | 5180 | | if (!(units[0] is Mass.Units)) |
| | 5181 | | { |
| | 5182 | | throw new Exception("Bug in Towel. Invalid parameters to Density Factory."); |
| | 5183 | | } |
| | 5184 | | if (!(units[1] is Length.Units)) |
| | 5185 | | { |
| | 5186 | | throw new Exception("Bug in Towel. Invalid parameters to Density Factory."); |
| | 5187 | | } |
| | 5188 | | if (!(units[2] is Length.Units)) |
| | 5189 | | { |
| | 5190 | | throw new Exception("Bug in Towel. Invalid parameters to Density Factory."); |
| | 5191 | | } |
| | 5192 | | if (!(units[3] is Length.Units)) |
| | 5193 | | { |
| | 5194 | | throw new Exception("Bug in Towel. Invalid parameters to Density Factory."); |
| | 5195 | | } |
| | 5196 | | return new Density<T>(value |
| | 5197 | | , (Mass.Units)units[0] |
| | 5198 | | , (Length.Units)units[1] |
| | 5199 | | , (Length.Units)units[2] |
| | 5200 | | , (Length.Units)units[3] |
| | 5201 | | ); |
| | 5202 | | } |
| | 5203 | | } |
| | 5204 | |
|
| | 5205 | | /// <summary>Density measurement with a value and the units.</summary> |
| | 5206 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 5207 | | public struct Density<T> |
| | 5208 | | { |
| | 5209 | | internal T _measurement; |
| | 5210 | | internal Mass.Units _MassUnits1; |
| | 5211 | | internal Length.Units _LengthUnits2; |
| | 5212 | | internal Length.Units _LengthUnits3; |
| | 5213 | | internal Length.Units _LengthUnits4; |
| | 5214 | |
|
| | 5215 | | #region Statics |
| | 5216 | |
|
| | 5217 | | /// <summary>Converts a Density measurement from units to another.</summary> |
| | 5218 | | /// <param name="value">The value to convert the units of.</param> |
| | 5219 | | /// <param name="fromMassUnits1">The current units of the measurement.</param> |
| | 5220 | | /// <param name="fromLengthUnits2">The current units of the measurement.</param> |
| | 5221 | | /// <param name="fromLengthUnits3">The current units of the measurement.</param> |
| | 5222 | | /// <param name="fromLengthUnits4">The current units of the measurement.</param> |
| | 5223 | | /// <param name="toMassUnits1">The desired units of the measurement.</param> |
| | 5224 | | /// <param name="toLengthUnits2">The desired units of the measurement.</param> |
| | 5225 | | /// <param name="toLengthUnits3">The desired units of the measurement.</param> |
| | 5226 | | /// <param name="toLengthUnits4">The desired units of the measurement.</param> |
| | 5227 | | /// <returns>The Density measurement converted into the desired units.</returns> |
| | 5228 | | public static T Convert(T value |
| | 5229 | | , Mass.Units fromMassUnits1 |
| | 5230 | | , Length.Units fromLengthUnits2 |
| | 5231 | | , Length.Units fromLengthUnits3 |
| | 5232 | | , Length.Units fromLengthUnits4 |
| | 5233 | | , Mass.Units toMassUnits1 |
| | 5234 | | , Length.Units toLengthUnits2 |
| | 5235 | | , Length.Units toLengthUnits3 |
| | 5236 | | , Length.Units toLengthUnits4 |
| | 5237 | | ) |
| | 5238 | | { |
| | 5239 | | Density<T> measurement = new Density<T>(value |
| | 5240 | | , fromMassUnits1 |
| | 5241 | | , fromLengthUnits2 |
| | 5242 | | , fromLengthUnits3 |
| | 5243 | | , fromLengthUnits4 |
| | 5244 | | ); |
| | 5245 | | return measurement[ |
| | 5246 | | toMassUnits1 |
| | 5247 | | , toLengthUnits2 |
| | 5248 | | , toLengthUnits3 |
| | 5249 | | , toLengthUnits4 |
| | 5250 | | ]; |
| | 5251 | | } |
| | 5252 | |
|
| | 5253 | | /// <summary>Converts a Density measurement from units to another.</summary> |
| | 5254 | | /// <param name="value">The value to convert the units of.</param> |
| | 5255 | | /// <param name="from">The current units of the measurement.</param> |
| | 5256 | | /// <param name="to">The desired units of the measurement.</param> |
| | 5257 | | /// <returns>The Density measurement converted into the desired units.</returns> |
| | 5258 | | public static T Convert(T value, |
| | 5259 | | MeasurementUnitsSyntaxTypes.DensityBaseUnits from, |
| | 5260 | | MeasurementUnitsSyntaxTypes.DensityBaseUnits to) |
| | 5261 | | { |
| | 5262 | | return Convert(value |
| | 5263 | | , from._MassUnits1 |
| | 5264 | | , from._LengthUnits2 |
| | 5265 | | , from._LengthUnits3 |
| | 5266 | | , from._LengthUnits4 |
| | 5267 | | , to._MassUnits1 |
| | 5268 | | , to._LengthUnits2 |
| | 5269 | | , to._LengthUnits3 |
| | 5270 | | , to._LengthUnits4 |
| | 5271 | | ); |
| | 5272 | | } |
| | 5273 | |
|
| | 5274 | | /// <summary>Parses a Density measurement string.</summary> |
| | 5275 | | /// <param name="string">The string to be parsed.</param> |
| | 5276 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 5277 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 5278 | | public static (bool Success, Density<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value)> tryPa |
| | 5279 | |
|
| | 5280 | | #endregion |
| | 5281 | |
|
| | 5282 | | #region Constructors |
| | 5283 | |
|
| | 5284 | | /// <summary>Constructs an Density with the measurement value and units.</summary> |
| | 5285 | | /// <param name="measurement">The measurement value of the Density.</param> |
| | 5286 | | /// <param name="units">The units of the Density.</param> |
| | 5287 | | public Density(T measurement, MeasurementUnitsSyntaxTypes.DensityBaseUnits units) : this(measurement |
| | 5288 | | , units._MassUnits1 |
| | 5289 | | , units._LengthUnits2 |
| | 5290 | | , units._LengthUnits3 |
| | 5291 | | , units._LengthUnits4 |
| | 5292 | | ) { } |
| | 5293 | |
|
| | 5294 | |
|
| | 5295 | | /// <summary>Constructs an Density with the measurement value and units.</summary> |
| | 5296 | | /// <param name="measurement">The measurement value of the Density.</param> |
| | 5297 | | /// <param name="MassUnits1">The units of the Density.</param> |
| | 5298 | | /// <param name="LengthUnits2">The units of the Density.</param> |
| | 5299 | | /// <param name="LengthUnits3">The units of the Density.</param> |
| | 5300 | | /// <param name="LengthUnits4">The units of the Density.</param> |
| | 5301 | | public Density(T measurement |
| | 5302 | | , Mass.Units MassUnits1 |
| | 5303 | | , Length.Units LengthUnits2 |
| | 5304 | | , Length.Units LengthUnits3 |
| | 5305 | | , Length.Units LengthUnits4 |
| | 5306 | | ) |
| | 5307 | | { |
| | 5308 | | _measurement = measurement; |
| | 5309 | | _MassUnits1 = MassUnits1; |
| | 5310 | | _LengthUnits2 = LengthUnits2; |
| | 5311 | | _LengthUnits3 = LengthUnits3; |
| | 5312 | | _LengthUnits4 = LengthUnits4; |
| | 5313 | | } |
| | 5314 | |
|
| | 5315 | | #endregion |
| | 5316 | |
|
| | 5317 | | #region Properties |
| | 5318 | |
|
| | 5319 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 5320 | | public Mass.Units MassUnits1 |
| | 5321 | | { |
| | 5322 | | get { return _MassUnits1; } |
| | 5323 | | set |
| | 5324 | | { |
| | 5325 | | if (value != _MassUnits1) |
| | 5326 | | { |
| | 5327 | | _measurement = this[value, _LengthUnits2, _LengthUnits3, _LengthUnits4]; |
| | 5328 | | _MassUnits1 = value; |
| | 5329 | | } |
| | 5330 | | } |
| | 5331 | | } |
| | 5332 | |
|
| | 5333 | | /// <summary>The #2 component of this measurements units.</summary> |
| | 5334 | | public Length.Units LengthUnits2 |
| | 5335 | | { |
| | 5336 | | get { return _LengthUnits2; } |
| | 5337 | | set |
| | 5338 | | { |
| | 5339 | | if (value != _LengthUnits2) |
| | 5340 | | { |
| | 5341 | | _measurement = this[_MassUnits1, value, _LengthUnits3, _LengthUnits4]; |
| | 5342 | | _LengthUnits2 = value; |
| | 5343 | | } |
| | 5344 | | } |
| | 5345 | | } |
| | 5346 | |
|
| | 5347 | | /// <summary>The #3 component of this measurements units.</summary> |
| | 5348 | | public Length.Units LengthUnits3 |
| | 5349 | | { |
| | 5350 | | get { return _LengthUnits3; } |
| | 5351 | | set |
| | 5352 | | { |
| | 5353 | | if (value != _LengthUnits3) |
| | 5354 | | { |
| | 5355 | | _measurement = this[_MassUnits1, _LengthUnits2, value, _LengthUnits4]; |
| | 5356 | | _LengthUnits3 = value; |
| | 5357 | | } |
| | 5358 | | } |
| | 5359 | | } |
| | 5360 | |
|
| | 5361 | | /// <summary>The #4 component of this measurements units.</summary> |
| | 5362 | | public Length.Units LengthUnits4 |
| | 5363 | | { |
| | 5364 | | get { return _LengthUnits4; } |
| | 5365 | | set |
| | 5366 | | { |
| | 5367 | | if (value != _LengthUnits4) |
| | 5368 | | { |
| | 5369 | | _measurement = this[_MassUnits1, _LengthUnits2, _LengthUnits3, value]; |
| | 5370 | | _LengthUnits4 = value; |
| | 5371 | | } |
| | 5372 | | } |
| | 5373 | | } |
| | 5374 | |
|
| | 5375 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 5376 | | /// <param name="units">The units to get the measurement in.</param> |
| | 5377 | | /// <returns>The measurement value in the specified units.</returns> |
| | 5378 | | public T this[MeasurementUnitsSyntaxTypes.DensityBaseUnits units] |
| | 5379 | | { |
| | 5380 | | get { return this[units._MassUnits1, units._LengthUnits2, units._LengthUnits3, units._LengthUnits4]; } |
| | 5381 | | } |
| | 5382 | |
|
| | 5383 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 5384 | | /// <param name="MassUnits1">The #1 component of this measurements units.</param> |
| | 5385 | | /// <param name="LengthUnits2">The #2 component of this measurements units.</param> |
| | 5386 | | /// <param name="LengthUnits3">The #3 component of this measurements units.</param> |
| | 5387 | | /// <param name="LengthUnits4">The #4 component of this measurements units.</param> |
| | 5388 | | /// <returns>The measurement value in the specified units.</returns> |
| | 5389 | | public T this[Mass.Units MassUnits1, Length.Units LengthUnits2, Length.Units LengthUnits3, Length.Units LengthUnits4 |
| | 5390 | | { |
| | 5391 | | get |
| | 5392 | | { |
| | 5393 | | T measurement = _measurement; |
| | 5394 | | if (MassUnits1 != _MassUnits1) |
| | 5395 | | { |
| | 5396 | | measurement = Mass<T>.Table[(int)_MassUnits1][(int)MassUnits1](measurement); |
| | 5397 | | //if (MassUnits1 < _MassUnits1) |
| | 5398 | | //{ |
| | 5399 | | // measurement = Mass<T>.Table[(int)_MassUnits1][(int)MassUnits1](measurement); |
| | 5400 | | //} |
| | 5401 | | //else |
| | 5402 | | //{ |
| | 5403 | | // measurement = Mass<T>.Table[(int)MassUnits1][(int)_MassUnits1](measurement); |
| | 5404 | | //} |
| | 5405 | | } |
| | 5406 | | if (LengthUnits2 != _LengthUnits2) |
| | 5407 | | { |
| | 5408 | | measurement = Length<T>.Table[(int)LengthUnits2][(int)_LengthUnits2](measurement); |
| | 5409 | | //if (LengthUnits2 > _LengthUnits2) |
| | 5410 | | //{ |
| | 5411 | | // measurement = Length<T>.Table[(int)_LengthUnits2][(int)LengthUnits2](measurement); |
| | 5412 | | //} |
| | 5413 | | //else |
| | 5414 | | //{ |
| | 5415 | | // measurement = Length<T>.Table[(int)LengthUnits2][(int)_LengthUnits2](measurement); |
| | 5416 | | //} |
| | 5417 | | } |
| | 5418 | | if (LengthUnits3 != _LengthUnits3) |
| | 5419 | | { |
| | 5420 | | measurement = Length<T>.Table[(int)LengthUnits3][(int)_LengthUnits3](measurement); |
| | 5421 | | //if (LengthUnits3 > _LengthUnits3) |
| | 5422 | | //{ |
| | 5423 | | // measurement = Length<T>.Table[(int)_LengthUnits3][(int)LengthUnits3](measurement); |
| | 5424 | | //} |
| | 5425 | | //else |
| | 5426 | | //{ |
| | 5427 | | // measurement = Length<T>.Table[(int)LengthUnits3][(int)_LengthUnits3](measurement); |
| | 5428 | | //} |
| | 5429 | | } |
| | 5430 | | if (LengthUnits4 != _LengthUnits4) |
| | 5431 | | { |
| | 5432 | | measurement = Length<T>.Table[(int)LengthUnits4][(int)_LengthUnits4](measurement); |
| | 5433 | | //if (LengthUnits4 > _LengthUnits4) |
| | 5434 | | //{ |
| | 5435 | | // measurement = Length<T>.Table[(int)_LengthUnits4][(int)LengthUnits4](measurement); |
| | 5436 | | //} |
| | 5437 | | //else |
| | 5438 | | //{ |
| | 5439 | | // measurement = Length<T>.Table[(int)LengthUnits4][(int)_LengthUnits4](measurement); |
| | 5440 | | //} |
| | 5441 | | } |
| | 5442 | | return measurement; |
| | 5443 | | } |
| | 5444 | | } |
| | 5445 | |
|
| | 5446 | | #endregion |
| | 5447 | |
|
| | 5448 | | #region Casting Operators |
| | 5449 | |
|
| | 5450 | | /// <summary>Converts a ValueTuple to a Density measurement.</summary> |
| | 5451 | | /// <param name="valueTuple">The ValueTuple to converted into a Density measurement.</param> |
| | 5452 | | public static implicit operator Density<T>((T, MeasurementUnitsSyntaxTypes.DensityBaseUnits) valueTuple) |
| | 5453 | | { |
| | 5454 | | return new Density<T>(valueTuple.Item1, valueTuple.Item2); |
| | 5455 | | } |
| | 5456 | |
|
| | 5457 | | #endregion |
| | 5458 | |
|
| | 5459 | | #region Mathematics |
| | 5460 | |
|
| | 5461 | | #region Bases |
| | 5462 | |
|
| | 5463 | | internal static Density<T> MathBase(Density<T> a, T b, Func<T, T, T> func) |
| | 5464 | | { |
| | 5465 | | return new Density<T>(func(a._measurement, b) |
| | 5466 | | , a._MassUnits1 |
| | 5467 | | , a._LengthUnits2 |
| | 5468 | | , a._LengthUnits3 |
| | 5469 | | , a._LengthUnits4 |
| | 5470 | | ); |
| | 5471 | | } |
| | 5472 | |
|
| | 5473 | | internal static Density<T> MathBase(Density<T> a, Density<T> b, Func<T, T, T> func) |
| | 5474 | | { |
| | 5475 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 5476 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 5477 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits3 ? a._LengthUnits3 : b._LengthUnits3; |
| | 5478 | | Length.Units LengthUnits4 = a._LengthUnits4 <= b._LengthUnits4 ? a._LengthUnits4 : b._LengthUnits4; |
| | 5479 | | T A = a[MassUnits1, LengthUnits2, LengthUnits3, LengthUnits4]; |
| | 5480 | | T B = b[MassUnits1, LengthUnits2, LengthUnits3, LengthUnits4]; |
| | 5481 | | T C = func(A, B); |
| | 5482 | | return new Density<T>(C, MassUnits1, LengthUnits2, LengthUnits3, LengthUnits4); |
| | 5483 | | } |
| | 5484 | |
|
| | 5485 | | internal static bool LogicBase(Density<T> a, Density<T> b, Func<T, T, bool> func) |
| | 5486 | | { |
| | 5487 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 5488 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 5489 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits3 ? a._LengthUnits3 : b._LengthUnits3; |
| | 5490 | | Length.Units LengthUnits4 = a._LengthUnits4 <= b._LengthUnits4 ? a._LengthUnits4 : b._LengthUnits4; |
| | 5491 | | T A = a[MassUnits1, LengthUnits2, LengthUnits3, LengthUnits4]; |
| | 5492 | | T B = b[MassUnits1, LengthUnits2, LengthUnits3, LengthUnits4]; |
| | 5493 | | return func(A, B); |
| | 5494 | | } |
| | 5495 | |
|
| | 5496 | | #endregion |
| | 5497 | |
|
| | 5498 | | #region Add |
| | 5499 | |
|
| | 5500 | | /// <summary>Adds two Density measurements.</summary> |
| | 5501 | | /// <param name="a">The first operand of the addition.</param> |
| | 5502 | | /// <param name="b">The second operand of the addition.</param> |
| | 5503 | | /// <returns>The result of the addition operation.</returns> |
| | 5504 | | public static Density<T> Add(Density<T> a, Density<T> b) |
| | 5505 | | { |
| | 5506 | | return MathBase(a, b, Statics.Addition); |
| | 5507 | | } |
| | 5508 | |
|
| | 5509 | | /// <summary>Adds two Density measurements.</summary> |
| | 5510 | | /// <param name="a">The first operand of the addition.</param> |
| | 5511 | | /// <param name="b">The second operand of the addition.</param> |
| | 5512 | | /// <returns>The result of the addition operation.</returns> |
| | 5513 | | public static Density<T> operator +(Density<T> a, Density<T> b) |
| | 5514 | | { |
| | 5515 | | return Add(a, b); |
| | 5516 | | } |
| | 5517 | |
|
| | 5518 | | /// <summary>Adds two Density measurements.</summary> |
| | 5519 | | /// <param name="b">The second operand of the addition.</param> |
| | 5520 | | /// <returns>The result of the addition operation.</returns> |
| | 5521 | | public Density<T> Add(Density<T> b) |
| | 5522 | | { |
| | 5523 | | return this + b; |
| | 5524 | | } |
| | 5525 | |
|
| | 5526 | | #endregion |
| | 5527 | |
|
| | 5528 | | #region Subtract |
| | 5529 | |
|
| | 5530 | | /// <summary>Subtracts two Density measurements.</summary> |
| | 5531 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 5532 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 5533 | | /// <returns>The result of the subtraction.</returns> |
| | 5534 | | public static Density<T> Subtract(Density<T> a, Density<T> b) |
| | 5535 | | { |
| | 5536 | | return MathBase(a, b, Statics.Subtraction); |
| | 5537 | | } |
| | 5538 | |
|
| | 5539 | | /// <summary>Subtracts two Density measurements.</summary> |
| | 5540 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 5541 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 5542 | | /// <returns>The result of the subtraction.</returns> |
| | 5543 | | public static Density<T> operator -(Density<T> a, Density<T> b) |
| | 5544 | | { |
| | 5545 | | return Subtract(a, b); |
| | 5546 | | } |
| | 5547 | |
|
| | 5548 | | /// <summary>Subtracts two Density measurements.</summary> |
| | 5549 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 5550 | | /// <returns>The result of the subtraction.</returns> |
| | 5551 | | public Density<T> Subtract(Density<T> b) |
| | 5552 | | { |
| | 5553 | | return this - b; |
| | 5554 | | } |
| | 5555 | |
|
| | 5556 | | #endregion |
| | 5557 | |
|
| | 5558 | | #region Multiply |
| | 5559 | |
|
| | 5560 | | /// <summary>Multiplies an Density by a scalar numeric value.</summary> |
| | 5561 | | /// <param name="a">The Density measurement to multiply.</param> |
| | 5562 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 5563 | | /// <returns>The result of the multiplication.</returns> |
| | 5564 | | public static Density<T> Multiply(Density<T> a, T b) |
| | 5565 | | { |
| | 5566 | | return MathBase(a, b, Statics.Multiplication); |
| | 5567 | | } |
| | 5568 | |
|
| | 5569 | | /// <summary>Multiplies an Density by a scalar numeric value.</summary> |
| | 5570 | | /// <param name="a">The Density measurement to multiply.</param> |
| | 5571 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 5572 | | /// <returns>The result of the multiplication.</returns> |
| | 5573 | | public static Density<T> Multiply(T b, Density<T> a) |
| | 5574 | | { |
| | 5575 | | return Multiply(a, b); |
| | 5576 | | } |
| | 5577 | |
|
| | 5578 | | /// <summary>Multiplies an Density by a scalar numeric value.</summary> |
| | 5579 | | /// <param name="a">The Density measurement to multiply.</param> |
| | 5580 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 5581 | | /// <returns>The result of the multiplication.</returns> |
| | 5582 | | public static Density<T> operator *(Density<T> a, T b) |
| | 5583 | | { |
| | 5584 | | return Multiply(a, b); |
| | 5585 | | } |
| | 5586 | |
|
| | 5587 | | /// <summary>Multiplies an Density by a scalar numeric value.</summary> |
| | 5588 | | /// <param name="a">The Density measurement to multiply.</param> |
| | 5589 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 5590 | | /// <returns>The result of the multiplication.</returns> |
| | 5591 | | public static Density<T> operator *(T b, Density<T> a) |
| | 5592 | | { |
| | 5593 | | return Multiply(b, a); |
| | 5594 | | } |
| | 5595 | |
|
| | 5596 | | /// <summary>Multiplies an Density by a scalar numeric value.</summary> |
| | 5597 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 5598 | | /// <returns>The result of the multiplication.</returns> |
| | 5599 | | public Density<T> Add(T b) |
| | 5600 | | { |
| | 5601 | | return this * b; |
| | 5602 | | } |
| | 5603 | |
|
| | 5604 | | #region Density<T> * Area<T> = LinearDensity<T> |
| | 5605 | |
|
| | 5606 | | /// <summary>Mulitplies Density by Area resulting in LinearDensity.</summary> |
| | 5607 | | /// <param name="a">The Density to be multiplied.</param> |
| | 5608 | | /// <param name="b">The Area to multiply by.</param> |
| | 5609 | | /// <returns>The LinearDensity result of the multiplication.</returns> |
| | 5610 | | public static LinearDensity<T> Multiply(Density<T> a, Area<T> b) |
| | 5611 | | { |
| | 5612 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 5613 | | Length.Units LengthUnits2 = a._LengthUnits3 <= b._LengthUnits2 ? a._LengthUnits3 : b._LengthUnits2; |
| | 5614 | |
|
| | 5615 | | T A = a[a._MassUnits1, LengthUnits1, LengthUnits2, a._LengthUnits4]; |
| | 5616 | | T B = b[LengthUnits1, LengthUnits2]; |
| | 5617 | | T C = Statics.Multiplication(A, B); |
| | 5618 | |
|
| | 5619 | | return new LinearDensity<T>(C |
| | 5620 | | , a._MassUnits1 |
| | 5621 | | , a._LengthUnits4 |
| | 5622 | | ); |
| | 5623 | | } |
| | 5624 | |
|
| | 5625 | | /// <summary>Mulitplies Density by Area resulting in LinearDensity.</summary> |
| | 5626 | | /// <param name="a">The Density to be multiplied.</param> |
| | 5627 | | /// <param name="b">The Area to multiply by.</param> |
| | 5628 | | /// <returns>The LinearDensity result of the multiplication.</returns> |
| | 5629 | | public static LinearDensity<T> operator *(Density<T> a, Area<T> b) |
| | 5630 | | { |
| | 5631 | | return Multiply(a, b); |
| | 5632 | | } |
| | 5633 | |
|
| | 5634 | | /// <summary>Mulitplies Density by Area resulting in LinearDensity.</summary> |
| | 5635 | | /// <param name="b">The Area to multiply by.</param> |
| | 5636 | | /// <returns>The LinearDensity result of the multiplication.</returns> |
| | 5637 | | public LinearDensity<T> Multiply(Area<T> b) |
| | 5638 | | { |
| | 5639 | | return this * b; |
| | 5640 | | } |
| | 5641 | |
|
| | 5642 | | #endregion |
| | 5643 | |
|
| | 5644 | | #region Density<T> * Length<T> = AreaDensity<T> |
| | 5645 | |
|
| | 5646 | | /// <summary>Mulitplies Density by Length resulting in AreaDensity.</summary> |
| | 5647 | | /// <param name="a">The Density to be multiplied.</param> |
| | 5648 | | /// <param name="b">The Length to multiply by.</param> |
| | 5649 | | /// <returns>The AreaDensity result of the multiplication.</returns> |
| | 5650 | | public static AreaDensity<T> Multiply(Density<T> a, Length<T> b) |
| | 5651 | | { |
| | 5652 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 5653 | |
|
| | 5654 | | T A = a[a._MassUnits1, LengthUnits1, a._LengthUnits3, a._LengthUnits4]; |
| | 5655 | | T B = b[LengthUnits1]; |
| | 5656 | | T C = Statics.Multiplication(A, B); |
| | 5657 | |
|
| | 5658 | | return new AreaDensity<T>(C |
| | 5659 | | , a._MassUnits1 |
| | 5660 | | , a._LengthUnits3 |
| | 5661 | | , a._LengthUnits4 |
| | 5662 | | ); |
| | 5663 | | } |
| | 5664 | |
|
| | 5665 | | /// <summary>Mulitplies Density by Length resulting in AreaDensity.</summary> |
| | 5666 | | /// <param name="a">The Density to be multiplied.</param> |
| | 5667 | | /// <param name="b">The Length to multiply by.</param> |
| | 5668 | | /// <returns>The AreaDensity result of the multiplication.</returns> |
| | 5669 | | public static AreaDensity<T> operator *(Density<T> a, Length<T> b) |
| | 5670 | | { |
| | 5671 | | return Multiply(a, b); |
| | 5672 | | } |
| | 5673 | |
|
| | 5674 | | /// <summary>Mulitplies Density by Length resulting in AreaDensity.</summary> |
| | 5675 | | /// <param name="b">The Length to multiply by.</param> |
| | 5676 | | /// <returns>The AreaDensity result of the multiplication.</returns> |
| | 5677 | | public AreaDensity<T> Multiply(Length<T> b) |
| | 5678 | | { |
| | 5679 | | return this * b; |
| | 5680 | | } |
| | 5681 | |
|
| | 5682 | | #endregion |
| | 5683 | |
|
| | 5684 | | #region Density<T> * Volume<T> = Mass<T> |
| | 5685 | |
|
| | 5686 | | /// <summary>Mulitplies Density by Volume resulting in Mass.</summary> |
| | 5687 | | /// <param name="a">The Density to be multiplied.</param> |
| | 5688 | | /// <param name="b">The Volume to multiply by.</param> |
| | 5689 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 5690 | | public static Mass<T> Multiply(Density<T> a, Volume<T> b) |
| | 5691 | | { |
| | 5692 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 5693 | | Length.Units LengthUnits2 = a._LengthUnits3 <= b._LengthUnits2 ? a._LengthUnits3 : b._LengthUnits2; |
| | 5694 | | Length.Units LengthUnits3 = a._LengthUnits4 <= b._LengthUnits3 ? a._LengthUnits4 : b._LengthUnits3; |
| | 5695 | |
|
| | 5696 | | T A = a[a._MassUnits1, LengthUnits1, LengthUnits2, LengthUnits3]; |
| | 5697 | | T B = b[LengthUnits1, LengthUnits2, LengthUnits3]; |
| | 5698 | | T C = Statics.Multiplication(A, B); |
| | 5699 | |
|
| | 5700 | | return new Mass<T>(C |
| | 5701 | | , a._MassUnits1 |
| | 5702 | | ); |
| | 5703 | | } |
| | 5704 | |
|
| | 5705 | | /// <summary>Mulitplies Density by Volume resulting in Mass.</summary> |
| | 5706 | | /// <param name="a">The Density to be multiplied.</param> |
| | 5707 | | /// <param name="b">The Volume to multiply by.</param> |
| | 5708 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 5709 | | public static Mass<T> operator *(Density<T> a, Volume<T> b) |
| | 5710 | | { |
| | 5711 | | return Multiply(a, b); |
| | 5712 | | } |
| | 5713 | |
|
| | 5714 | | /// <summary>Mulitplies Density by Volume resulting in Mass.</summary> |
| | 5715 | | /// <param name="b">The Volume to multiply by.</param> |
| | 5716 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 5717 | | public Mass<T> Multiply(Volume<T> b) |
| | 5718 | | { |
| | 5719 | | return this * b; |
| | 5720 | | } |
| | 5721 | |
|
| | 5722 | | #endregion |
| | 5723 | |
|
| | 5724 | | #region Density<T> * VolumeRate<T> = MassRate<T> |
| | 5725 | |
|
| | 5726 | | /// <summary>Mulitplies Density by VolumeRate resulting in MassRate.</summary> |
| | 5727 | | /// <param name="a">The Density to be multiplied.</param> |
| | 5728 | | /// <param name="b">The VolumeRate to multiply by.</param> |
| | 5729 | | /// <returns>The MassRate result of the multiplication.</returns> |
| | 5730 | | public static MassRate<T> Multiply(Density<T> a, VolumeRate<T> b) |
| | 5731 | | { |
| | 5732 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 5733 | | Length.Units LengthUnits2 = a._LengthUnits3 <= b._LengthUnits2 ? a._LengthUnits3 : b._LengthUnits2; |
| | 5734 | | Length.Units LengthUnits3 = a._LengthUnits4 <= b._LengthUnits3 ? a._LengthUnits4 : b._LengthUnits3; |
| | 5735 | |
|
| | 5736 | | T A = a[a._MassUnits1, LengthUnits1, LengthUnits2, LengthUnits3]; |
| | 5737 | | T B = b[LengthUnits1, LengthUnits2, LengthUnits3, b._TimeUnits4]; |
| | 5738 | | T C = Statics.Multiplication(A, B); |
| | 5739 | |
|
| | 5740 | | return new MassRate<T>(C |
| | 5741 | | , a._MassUnits1 |
| | 5742 | | , b._TimeUnits4 |
| | 5743 | | ); |
| | 5744 | | } |
| | 5745 | |
|
| | 5746 | | /// <summary>Mulitplies Density by VolumeRate resulting in MassRate.</summary> |
| | 5747 | | /// <param name="a">The Density to be multiplied.</param> |
| | 5748 | | /// <param name="b">The VolumeRate to multiply by.</param> |
| | 5749 | | /// <returns>The MassRate result of the multiplication.</returns> |
| | 5750 | | public static MassRate<T> operator *(Density<T> a, VolumeRate<T> b) |
| | 5751 | | { |
| | 5752 | | return Multiply(a, b); |
| | 5753 | | } |
| | 5754 | |
|
| | 5755 | | /// <summary>Mulitplies Density by VolumeRate resulting in MassRate.</summary> |
| | 5756 | | /// <param name="b">The VolumeRate to multiply by.</param> |
| | 5757 | | /// <returns>The MassRate result of the multiplication.</returns> |
| | 5758 | | public MassRate<T> Multiply(VolumeRate<T> b) |
| | 5759 | | { |
| | 5760 | | return this * b; |
| | 5761 | | } |
| | 5762 | |
|
| | 5763 | | #endregion |
| | 5764 | |
|
| | 5765 | | #endregion |
| | 5766 | |
|
| | 5767 | | #region Divide |
| | 5768 | |
|
| | 5769 | | /// <summary>Divides an Density measurement by another Density measurement resulting in a scalar numeric value.</sum |
| | 5770 | | /// <param name="a">The first operand of the division operation.</param> |
| | 5771 | | /// <param name="b">The second operand of the division operation.</param> |
| | 5772 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 5773 | | public static T Divide(Density<T> a, Density<T> b) |
| | 5774 | | { |
| | 5775 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 5776 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 5777 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits3 ? a._LengthUnits3 : b._LengthUnits3; |
| | 5778 | | Length.Units LengthUnits4 = a._LengthUnits4 <= b._LengthUnits4 ? a._LengthUnits4 : b._LengthUnits4; |
| | 5779 | | T A = a[MassUnits1, LengthUnits2, LengthUnits3, LengthUnits4]; |
| | 5780 | | T B = b[MassUnits1, LengthUnits2, LengthUnits3, LengthUnits4]; |
| | 5781 | | return Statics.Division(A, B); |
| | 5782 | | } |
| | 5783 | |
|
| | 5784 | | /// <summary>Divides this Density measurement by a numaric scalar value.</summary> |
| | 5785 | | /// <param name="a">The Density measurement to divide.</param> |
| | 5786 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 5787 | | /// <returns>The result of the division.</returns> |
| | 5788 | | public static Density<T> Divide(Density<T> a, T b) |
| | 5789 | | { |
| | 5790 | | return MathBase(a, b, Statics.Division); |
| | 5791 | | } |
| | 5792 | |
|
| | 5793 | | /// <summary>Divides this Density measurement by a numaric scalar value.</summary> |
| | 5794 | | /// <param name="a">The Density measurement to divide.</param> |
| | 5795 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 5796 | | /// <returns>The result of the division.</returns> |
| | 5797 | | public static Density<T> operator /(Density<T> a, T b) |
| | 5798 | | { |
| | 5799 | | return Divide(a, b); |
| | 5800 | | } |
| | 5801 | |
|
| | 5802 | | /// <summary>Divides this Density measurement by a numaric scalar value.</summary> |
| | 5803 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 5804 | | /// <returns>The result of the division.</returns> |
| | 5805 | | public Density<T> Divide(T b) |
| | 5806 | | { |
| | 5807 | | return this / b; |
| | 5808 | | } |
| | 5809 | |
|
| | 5810 | | /// <summary>Divides an Density measurement by another Density measurement resulting in a scalar numeric value.</sum |
| | 5811 | | /// <param name="a">The first operand of the division operation.</param> |
| | 5812 | | /// <param name="b">The second operand of the division operation.</param> |
| | 5813 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 5814 | | public static T operator /(Density<T> a, Density<T> b) |
| | 5815 | | { |
| | 5816 | | return Divide(a, b); |
| | 5817 | | } |
| | 5818 | |
|
| | 5819 | | /// <summary>Divides an Density measurement by another Density measurement resulting in a scalar numeric value.</sum |
| | 5820 | | /// <param name="b">The second operand of the division operation.</param> |
| | 5821 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 5822 | | public T Divide(Density<T> b) |
| | 5823 | | { |
| | 5824 | | return this / b; |
| | 5825 | | } |
| | 5826 | |
|
| | 5827 | | #endregion |
| | 5828 | |
|
| | 5829 | | #region LessThan |
| | 5830 | |
|
| | 5831 | | /// <summary>Determines if an Density measurement is less than another Density measurement.</summary> |
| | 5832 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 5833 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 5834 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 5835 | | public static bool LessThan(Density<T> a, Density<T> b) |
| | 5836 | | { |
| | 5837 | | return LogicBase(a, b, Statics.LessThan); |
| | 5838 | | } |
| | 5839 | |
|
| | 5840 | | /// <summary>Determines if an Density measurement is less than another Density measurement.</summary> |
| | 5841 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 5842 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 5843 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 5844 | | public static bool operator <(Density<T> a, Density<T> b) |
| | 5845 | | { |
| | 5846 | | return LessThan(a, b); |
| | 5847 | | } |
| | 5848 | |
|
| | 5849 | | /// <summary>Determines if an Density measurement is less than another Density measurement.</summary> |
| | 5850 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 5851 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 5852 | | public bool LessThan(Density<T> b) |
| | 5853 | | { |
| | 5854 | | return this < b; |
| | 5855 | | } |
| | 5856 | |
|
| | 5857 | | #endregion |
| | 5858 | |
|
| | 5859 | | #region GreaterThan |
| | 5860 | |
|
| | 5861 | | /// <summary>Determines if an Density measurement is greater than another Density measurement.</summary> |
| | 5862 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 5863 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 5864 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 5865 | | public static bool GreaterThan(Density<T> a, Density<T> b) |
| | 5866 | | { |
| | 5867 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 5868 | | } |
| | 5869 | |
|
| | 5870 | | /// <summary>Determines if an Density measurement is greater than another Density measurement.</summary> |
| | 5871 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 5872 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 5873 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 5874 | | public static bool operator >(Density<T> a, Density<T> b) |
| | 5875 | | { |
| | 5876 | | return GreaterThan(a, b); |
| | 5877 | | } |
| | 5878 | |
|
| | 5879 | | /// <summary>Determines if an Density measurement is greater than another Density measurement.</summary> |
| | 5880 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 5881 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 5882 | | public bool GreaterThan(Density<T> b) |
| | 5883 | | { |
| | 5884 | | return this > b; |
| | 5885 | | } |
| | 5886 | |
|
| | 5887 | | #endregion |
| | 5888 | |
|
| | 5889 | | #region LessThanOrEqual |
| | 5890 | |
|
| | 5891 | | /// <summary>Determines if an Density measurement is less than or equal to another Density measurement.</summary> |
| | 5892 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 5893 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 5894 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 5895 | | public static bool LessThanOrEqual(Density<T> a, Density<T> b) |
| | 5896 | | { |
| | 5897 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 5898 | | } |
| | 5899 | |
|
| | 5900 | | /// <summary>Determines if an Density measurement is less than or equal to another Density measurement.</summary> |
| | 5901 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 5902 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 5903 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 5904 | | public static bool operator <=(Density<T> a, Density<T> b) |
| | 5905 | | { |
| | 5906 | | return LessThanOrEqual(a, b); |
| | 5907 | | } |
| | 5908 | |
|
| | 5909 | | /// <summary>Determines if an Density measurement is less than or equal to another Density measurement.</summary> |
| | 5910 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 5911 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 5912 | | public bool LessThanOrEqual(Density<T> b) |
| | 5913 | | { |
| | 5914 | | return this <= b; |
| | 5915 | | } |
| | 5916 | |
|
| | 5917 | | #endregion |
| | 5918 | |
|
| | 5919 | | #region GreaterThanOrEqual |
| | 5920 | |
|
| | 5921 | | /// <summary>Determines if an Density measurement is greater than or equal to another Density measurement.</summary> |
| | 5922 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 5923 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 5924 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 5925 | | public static bool GreaterThanOrEqual(Density<T> a, Density<T> b) |
| | 5926 | | { |
| | 5927 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 5928 | | } |
| | 5929 | |
|
| | 5930 | | /// <summary>Determines if an Density measurement is greater than or equal to another Density measurement.</summary> |
| | 5931 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 5932 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 5933 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 5934 | | public static bool operator >=(Density<T> a, Density<T> b) |
| | 5935 | | { |
| | 5936 | | return GreaterThanOrEqual(a, b); |
| | 5937 | | } |
| | 5938 | |
|
| | 5939 | | /// <summary>Determines if an Density measurement is greater than or equal to another Density measurement.</summary> |
| | 5940 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 5941 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 5942 | | public bool GreaterThanOrEqual(Density<T> b) |
| | 5943 | | { |
| | 5944 | | return this >= b; |
| | 5945 | | } |
| | 5946 | |
|
| | 5947 | | #endregion |
| | 5948 | |
|
| | 5949 | | #region Equal |
| | 5950 | |
|
| | 5951 | | /// <summary>Determines if an Density measurement is equal to another Density measurement.</summary> |
| | 5952 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 5953 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 5954 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 5955 | | public static bool Equal(Density<T> a, Density<T> b) |
| | 5956 | | { |
| | 5957 | | return LogicBase(a, b, Statics.Equate); |
| | 5958 | | } |
| | 5959 | |
|
| | 5960 | | /// <summary>Determines if an Density measurement is equal to another Density measurement.</summary> |
| | 5961 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 5962 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 5963 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 5964 | | public static bool operator ==(Density<T> a, Density<T> b) |
| | 5965 | | { |
| | 5966 | | return Equal(a, b); |
| | 5967 | | } |
| | 5968 | |
|
| | 5969 | | /// <summary>Determines if an Density measurement is equal to another Density measurement.</summary> |
| | 5970 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 5971 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 5972 | | public bool Equal(Density<T> b) |
| | 5973 | | { |
| | 5974 | | return this == b; |
| | 5975 | | } |
| | 5976 | |
|
| | 5977 | | #endregion |
| | 5978 | |
|
| | 5979 | | #region NotEqual |
| | 5980 | |
|
| | 5981 | | /// <summary>Determines if an Density measurement is not equal to another Density measurement.</summary> |
| | 5982 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 5983 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 5984 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 5985 | | public static bool NotEqual(Density<T> a, Density<T> b) |
| | 5986 | | { |
| | 5987 | | return LogicBase(a, b, Statics.Inequate); |
| | 5988 | | } |
| | 5989 | |
|
| | 5990 | | /// <summary>Determines if an Density measurement is not equal to another Density measurement.</summary> |
| | 5991 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 5992 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 5993 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 5994 | | public static bool operator !=(Density<T> a, Density<T> b) |
| | 5995 | | { |
| | 5996 | | return NotEqual(a, b); |
| | 5997 | | } |
| | 5998 | |
|
| | 5999 | | /// <summary>Determines if an Density measurement is not equal to another Density measurement.</summary> |
| | 6000 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 6001 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 6002 | | public bool NotEqual(Density<T> b) |
| | 6003 | | { |
| | 6004 | | return this != b; |
| | 6005 | | } |
| | 6006 | |
|
| | 6007 | | #endregion |
| | 6008 | |
|
| | 6009 | | #endregion |
| | 6010 | |
|
| | 6011 | | #region Overrides |
| | 6012 | |
|
| | 6013 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 6014 | | /// <param name="obj">The object to check for equality with.</param> |
| | 6015 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 6016 | | public override bool Equals(object obj) |
| | 6017 | | { |
| | 6018 | | if (obj is Density<T>) |
| | 6019 | | { |
| | 6020 | | return this == (Density<T>)obj; |
| | 6021 | | } |
| | 6022 | | return false; |
| | 6023 | | } |
| | 6024 | |
|
| | 6025 | | /// <summary>Converts the Density measurement to a string represenation.</summary> |
| | 6026 | | /// <returns>The string representation of the measurement.</returns> |
| | 6027 | | public override string ToString() |
| | 6028 | | { |
| | 6029 | | return _measurement + " " + |
| | 6030 | | _MassUnits1 |
| | 6031 | | + "/" + |
| | 6032 | | _LengthUnits2 + "/" + _LengthUnits3 + "/" + _LengthUnits4 |
| | 6033 | | ; |
| | 6034 | | } |
| | 6035 | |
|
| | 6036 | | /// <summary>Base hashing function for Density measurements.</summary> |
| | 6037 | | /// <returns>Computed hash code for this instance.</returns> |
| | 6038 | | public override int GetHashCode() => Hash(_measurement); |
| | 6039 | |
|
| | 6040 | | #endregion |
| | 6041 | | } |
| | 6042 | |
|
| | 6043 | | #endregion |
| | 6044 | |
|
| | 6045 | | #region ElectricCharge |
| | 6046 | |
|
| | 6047 | | internal static partial class ParsingFunctions |
| | 6048 | | { |
| | 6049 | | [Measurement.Parseable("ElectricCharge")] |
| | 6050 | | public static object ElectricCharge<T>(T value, object[] units) |
| | 6051 | | { |
| | 6052 | | if (units.Length != 1) |
| | 6053 | | { |
| | 6054 | | throw new Exception("Bug in Towel. Invalid parameters to ElectricCharge Factory."); |
| | 6055 | | } |
| | 6056 | | if (!(units[0] is ElectricCharge.Units)) |
| | 6057 | | { |
| | 6058 | | throw new Exception("Bug in Towel. Invalid parameters to ElectricCharge Factory."); |
| | 6059 | | } |
| | 6060 | | return new ElectricCharge<T>(value |
| | 6061 | | , (ElectricCharge.Units)units[0] |
| | 6062 | | ); |
| | 6063 | | } |
| | 6064 | | } |
| | 6065 | |
|
| | 6066 | | /// <summary>ElectricCharge measurement with a value and the units.</summary> |
| | 6067 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 6068 | | public struct ElectricCharge<T> |
| | 6069 | | { |
| | 6070 | | internal static Func<T, T>[][] Table = UnitConversionTable.Build<ElectricCharge.Units, T>(); |
| | 6071 | | internal T _measurement; |
| | 6072 | | internal ElectricCharge.Units _ElectricChargeUnits1; |
| | 6073 | |
|
| | 6074 | | #region Statics |
| | 6075 | |
|
| | 6076 | | /// <summary>Converts a ElectricCharge measurement from units to another.</summary> |
| | 6077 | | /// <param name="value">The value to convert the units of.</param> |
| | 6078 | | /// <param name="fromElectricChargeUnits1">The current units of the measurement.</param> |
| | 6079 | | /// <param name="toElectricChargeUnits1">The desired units of the measurement.</param> |
| | 6080 | | /// <returns>The ElectricCharge measurement converted into the desired units.</returns> |
| | 6081 | | public static T Convert(T value |
| | 6082 | | , ElectricCharge.Units fromElectricChargeUnits1 |
| | 6083 | | , ElectricCharge.Units toElectricChargeUnits1 |
| | 6084 | | ) |
| | 6085 | | { |
| | 6086 | | ElectricCharge<T> measurement = new ElectricCharge<T>(value |
| | 6087 | | , fromElectricChargeUnits1 |
| | 6088 | | ); |
| | 6089 | | return measurement[ |
| | 6090 | | toElectricChargeUnits1 |
| | 6091 | | ]; |
| | 6092 | | } |
| | 6093 | |
|
| | 6094 | | /// <summary>Converts a ElectricCharge measurement from units to another.</summary> |
| | 6095 | | /// <param name="value">The value to convert the units of.</param> |
| | 6096 | | /// <param name="from">The current units of the measurement.</param> |
| | 6097 | | /// <param name="to">The desired units of the measurement.</param> |
| | 6098 | | /// <returns>The ElectricCharge measurement converted into the desired units.</returns> |
| | 6099 | | public static T Convert(T value, |
| | 6100 | | MeasurementUnitsSyntaxTypes.ElectricChargeUnits from, |
| | 6101 | | MeasurementUnitsSyntaxTypes.ElectricChargeUnits to) |
| | 6102 | | { |
| | 6103 | | return Convert(value |
| | 6104 | | , from._ElectricChargeUnits1 |
| | 6105 | | , to._ElectricChargeUnits1 |
| | 6106 | | ); |
| | 6107 | | } |
| | 6108 | |
|
| | 6109 | | /// <summary>Parses a ElectricCharge measurement string.</summary> |
| | 6110 | | /// <param name="string">The string to be parsed.</param> |
| | 6111 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 6112 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 6113 | | public static (bool Success, ElectricCharge<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value) |
| | 6114 | |
|
| | 6115 | | #endregion |
| | 6116 | |
|
| | 6117 | | #region Constructors |
| | 6118 | |
|
| | 6119 | | /// <summary>Constructs an ElectricCharge with the measurement value and units.</summary> |
| | 6120 | | /// <param name="measurement">The measurement value of the ElectricCharge.</param> |
| | 6121 | | /// <param name="units">The units of the ElectricCharge.</param> |
| | 6122 | | public ElectricCharge(T measurement, MeasurementUnitsSyntaxTypes.ElectricChargeUnits units) : this(measurement |
| | 6123 | | , units._ElectricChargeUnits1 |
| | 6124 | | ) { } |
| | 6125 | |
|
| | 6126 | |
|
| | 6127 | | /// <summary>Constructs an ElectricCharge with the measurement value and units.</summary> |
| | 6128 | | /// <param name="measurement">The measurement value of the ElectricCharge.</param> |
| | 6129 | | /// <param name="ElectricChargeUnits1">The units of the ElectricCharge.</param> |
| | 6130 | | public ElectricCharge(T measurement |
| | 6131 | | , ElectricCharge.Units ElectricChargeUnits1 |
| | 6132 | | ) |
| | 6133 | | { |
| | 6134 | | _measurement = measurement; |
| | 6135 | | _ElectricChargeUnits1 = ElectricChargeUnits1; |
| | 6136 | | } |
| | 6137 | |
|
| | 6138 | | #endregion |
| | 6139 | |
|
| | 6140 | | #region Properties |
| | 6141 | |
|
| | 6142 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 6143 | | public ElectricCharge.Units ElectricChargeUnits1 |
| | 6144 | | { |
| | 6145 | | get { return _ElectricChargeUnits1; } |
| | 6146 | | set |
| | 6147 | | { |
| | 6148 | | if (value != _ElectricChargeUnits1) |
| | 6149 | | { |
| | 6150 | | _measurement = this[value]; |
| | 6151 | | _ElectricChargeUnits1 = value; |
| | 6152 | | } |
| | 6153 | | } |
| | 6154 | | } |
| | 6155 | |
|
| | 6156 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 6157 | | /// <param name="units">The units to get the measurement in.</param> |
| | 6158 | | /// <returns>The measurement value in the specified units.</returns> |
| | 6159 | | public T this[MeasurementUnitsSyntaxTypes.ElectricChargeUnits units] |
| | 6160 | | { |
| | 6161 | | get { return this[units._ElectricChargeUnits1]; } |
| | 6162 | | } |
| | 6163 | |
|
| | 6164 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 6165 | | /// <param name="ElectricChargeUnits1">The #1 component of this measurements units.</param> |
| | 6166 | | /// <returns>The measurement value in the specified units.</returns> |
| | 6167 | | public T this[ElectricCharge.Units ElectricChargeUnits1] |
| | 6168 | | { |
| | 6169 | | get |
| | 6170 | | { |
| | 6171 | | T measurement = _measurement; |
| | 6172 | | if (ElectricChargeUnits1 != _ElectricChargeUnits1) |
| | 6173 | | { |
| | 6174 | | measurement = ElectricCharge<T>.Table[(int)_ElectricChargeUnits1][(int)ElectricChargeUnits1](measurement); |
| | 6175 | | //if (ElectricChargeUnits1 < _ElectricChargeUnits1) |
| | 6176 | | //{ |
| | 6177 | | // measurement = ElectricCharge<T>.Table[(int)_ElectricChargeUnits1][(int)ElectricChargeUnits1](measurement); |
| | 6178 | | //} |
| | 6179 | | //else |
| | 6180 | | //{ |
| | 6181 | | // measurement = ElectricCharge<T>.Table[(int)ElectricChargeUnits1][(int)_ElectricChargeUnits1](measurement); |
| | 6182 | | //} |
| | 6183 | | } |
| | 6184 | | return measurement; |
| | 6185 | | } |
| | 6186 | | } |
| | 6187 | |
|
| | 6188 | | #endregion |
| | 6189 | |
|
| | 6190 | | #region Casting Operators |
| | 6191 | |
|
| | 6192 | | /// <summary>Converts a ValueTuple to a ElectricCharge measurement.</summary> |
| | 6193 | | /// <param name="valueTuple">The ValueTuple to converted into a ElectricCharge measurement.</param> |
| | 6194 | | public static implicit operator ElectricCharge<T>((T, MeasurementUnitsSyntaxTypes.ElectricChargeUnits) valueTuple) |
| | 6195 | | { |
| | 6196 | | return new ElectricCharge<T>(valueTuple.Item1, valueTuple.Item2); |
| | 6197 | | } |
| | 6198 | |
|
| | 6199 | | #endregion |
| | 6200 | |
|
| | 6201 | | #region Mathematics |
| | 6202 | |
|
| | 6203 | | #region Bases |
| | 6204 | |
|
| | 6205 | | internal static ElectricCharge<T> MathBase(ElectricCharge<T> a, T b, Func<T, T, T> func) |
| | 6206 | | { |
| | 6207 | | return new ElectricCharge<T>(func(a._measurement, b) |
| | 6208 | | , a._ElectricChargeUnits1 |
| | 6209 | | ); |
| | 6210 | | } |
| | 6211 | |
|
| | 6212 | | internal static ElectricCharge<T> MathBase(ElectricCharge<T> a, ElectricCharge<T> b, Func<T, T, T> func) |
| | 6213 | | { |
| | 6214 | | ElectricCharge.Units ElectricChargeUnits1 = a._ElectricChargeUnits1 <= b._ElectricChargeUnits1 ? a._ElectricCharge |
| | 6215 | | T A = a[ElectricChargeUnits1]; |
| | 6216 | | T B = b[ElectricChargeUnits1]; |
| | 6217 | | T C = func(A, B); |
| | 6218 | | return new ElectricCharge<T>(C, ElectricChargeUnits1); |
| | 6219 | | } |
| | 6220 | |
|
| | 6221 | | internal static bool LogicBase(ElectricCharge<T> a, ElectricCharge<T> b, Func<T, T, bool> func) |
| | 6222 | | { |
| | 6223 | | ElectricCharge.Units ElectricChargeUnits1 = a._ElectricChargeUnits1 <= b._ElectricChargeUnits1 ? a._ElectricCharge |
| | 6224 | | T A = a[ElectricChargeUnits1]; |
| | 6225 | | T B = b[ElectricChargeUnits1]; |
| | 6226 | | return func(A, B); |
| | 6227 | | } |
| | 6228 | |
|
| | 6229 | | #endregion |
| | 6230 | |
|
| | 6231 | | #region Add |
| | 6232 | |
|
| | 6233 | | /// <summary>Adds two ElectricCharge measurements.</summary> |
| | 6234 | | /// <param name="a">The first operand of the addition.</param> |
| | 6235 | | /// <param name="b">The second operand of the addition.</param> |
| | 6236 | | /// <returns>The result of the addition operation.</returns> |
| | 6237 | | public static ElectricCharge<T> Add(ElectricCharge<T> a, ElectricCharge<T> b) |
| | 6238 | | { |
| | 6239 | | return MathBase(a, b, Statics.Addition); |
| | 6240 | | } |
| | 6241 | |
|
| | 6242 | | /// <summary>Adds two ElectricCharge measurements.</summary> |
| | 6243 | | /// <param name="a">The first operand of the addition.</param> |
| | 6244 | | /// <param name="b">The second operand of the addition.</param> |
| | 6245 | | /// <returns>The result of the addition operation.</returns> |
| | 6246 | | public static ElectricCharge<T> operator +(ElectricCharge<T> a, ElectricCharge<T> b) |
| | 6247 | | { |
| | 6248 | | return Add(a, b); |
| | 6249 | | } |
| | 6250 | |
|
| | 6251 | | /// <summary>Adds two ElectricCharge measurements.</summary> |
| | 6252 | | /// <param name="b">The second operand of the addition.</param> |
| | 6253 | | /// <returns>The result of the addition operation.</returns> |
| | 6254 | | public ElectricCharge<T> Add(ElectricCharge<T> b) |
| | 6255 | | { |
| | 6256 | | return this + b; |
| | 6257 | | } |
| | 6258 | |
|
| | 6259 | | #endregion |
| | 6260 | |
|
| | 6261 | | #region Subtract |
| | 6262 | |
|
| | 6263 | | /// <summary>Subtracts two ElectricCharge measurements.</summary> |
| | 6264 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 6265 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 6266 | | /// <returns>The result of the subtraction.</returns> |
| | 6267 | | public static ElectricCharge<T> Subtract(ElectricCharge<T> a, ElectricCharge<T> b) |
| | 6268 | | { |
| | 6269 | | return MathBase(a, b, Statics.Subtraction); |
| | 6270 | | } |
| | 6271 | |
|
| | 6272 | | /// <summary>Subtracts two ElectricCharge measurements.</summary> |
| | 6273 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 6274 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 6275 | | /// <returns>The result of the subtraction.</returns> |
| | 6276 | | public static ElectricCharge<T> operator -(ElectricCharge<T> a, ElectricCharge<T> b) |
| | 6277 | | { |
| | 6278 | | return Subtract(a, b); |
| | 6279 | | } |
| | 6280 | |
|
| | 6281 | | /// <summary>Subtracts two ElectricCharge measurements.</summary> |
| | 6282 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 6283 | | /// <returns>The result of the subtraction.</returns> |
| | 6284 | | public ElectricCharge<T> Subtract(ElectricCharge<T> b) |
| | 6285 | | { |
| | 6286 | | return this - b; |
| | 6287 | | } |
| | 6288 | |
|
| | 6289 | | #endregion |
| | 6290 | |
|
| | 6291 | | #region Multiply |
| | 6292 | |
|
| | 6293 | | /// <summary>Multiplies an ElectricCharge by a scalar numeric value.</summary> |
| | 6294 | | /// <param name="a">The ElectricCharge measurement to multiply.</param> |
| | 6295 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 6296 | | /// <returns>The result of the multiplication.</returns> |
| | 6297 | | public static ElectricCharge<T> Multiply(ElectricCharge<T> a, T b) |
| | 6298 | | { |
| | 6299 | | return MathBase(a, b, Statics.Multiplication); |
| | 6300 | | } |
| | 6301 | |
|
| | 6302 | | /// <summary>Multiplies an ElectricCharge by a scalar numeric value.</summary> |
| | 6303 | | /// <param name="a">The ElectricCharge measurement to multiply.</param> |
| | 6304 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 6305 | | /// <returns>The result of the multiplication.</returns> |
| | 6306 | | public static ElectricCharge<T> Multiply(T b, ElectricCharge<T> a) |
| | 6307 | | { |
| | 6308 | | return Multiply(a, b); |
| | 6309 | | } |
| | 6310 | |
|
| | 6311 | | /// <summary>Multiplies an ElectricCharge by a scalar numeric value.</summary> |
| | 6312 | | /// <param name="a">The ElectricCharge measurement to multiply.</param> |
| | 6313 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 6314 | | /// <returns>The result of the multiplication.</returns> |
| | 6315 | | public static ElectricCharge<T> operator *(ElectricCharge<T> a, T b) |
| | 6316 | | { |
| | 6317 | | return Multiply(a, b); |
| | 6318 | | } |
| | 6319 | |
|
| | 6320 | | /// <summary>Multiplies an ElectricCharge by a scalar numeric value.</summary> |
| | 6321 | | /// <param name="a">The ElectricCharge measurement to multiply.</param> |
| | 6322 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 6323 | | /// <returns>The result of the multiplication.</returns> |
| | 6324 | | public static ElectricCharge<T> operator *(T b, ElectricCharge<T> a) |
| | 6325 | | { |
| | 6326 | | return Multiply(b, a); |
| | 6327 | | } |
| | 6328 | |
|
| | 6329 | | /// <summary>Multiplies an ElectricCharge by a scalar numeric value.</summary> |
| | 6330 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 6331 | | /// <returns>The result of the multiplication.</returns> |
| | 6332 | | public ElectricCharge<T> Add(T b) |
| | 6333 | | { |
| | 6334 | | return this * b; |
| | 6335 | | } |
| | 6336 | |
|
| | 6337 | | #endregion |
| | 6338 | |
|
| | 6339 | | #region Divide |
| | 6340 | |
|
| | 6341 | | /// <summary>Divides an ElectricCharge measurement by another ElectricCharge measurement resulting in a scalar numer |
| | 6342 | | /// <param name="a">The first operand of the division operation.</param> |
| | 6343 | | /// <param name="b">The second operand of the division operation.</param> |
| | 6344 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 6345 | | public static T Divide(ElectricCharge<T> a, ElectricCharge<T> b) |
| | 6346 | | { |
| | 6347 | | ElectricCharge.Units ElectricChargeUnits1 = a._ElectricChargeUnits1 <= b._ElectricChargeUnits1 ? a._ElectricCharge |
| | 6348 | | T A = a[ElectricChargeUnits1]; |
| | 6349 | | T B = b[ElectricChargeUnits1]; |
| | 6350 | | return Statics.Division(A, B); |
| | 6351 | | } |
| | 6352 | |
|
| | 6353 | | /// <summary>Divides this ElectricCharge measurement by a numaric scalar value.</summary> |
| | 6354 | | /// <param name="a">The ElectricCharge measurement to divide.</param> |
| | 6355 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 6356 | | /// <returns>The result of the division.</returns> |
| | 6357 | | public static ElectricCharge<T> Divide(ElectricCharge<T> a, T b) |
| | 6358 | | { |
| | 6359 | | return MathBase(a, b, Statics.Division); |
| | 6360 | | } |
| | 6361 | |
|
| | 6362 | | /// <summary>Divides this ElectricCharge measurement by a numaric scalar value.</summary> |
| | 6363 | | /// <param name="a">The ElectricCharge measurement to divide.</param> |
| | 6364 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 6365 | | /// <returns>The result of the division.</returns> |
| | 6366 | | public static ElectricCharge<T> operator /(ElectricCharge<T> a, T b) |
| | 6367 | | { |
| | 6368 | | return Divide(a, b); |
| | 6369 | | } |
| | 6370 | |
|
| | 6371 | | /// <summary>Divides this ElectricCharge measurement by a numaric scalar value.</summary> |
| | 6372 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 6373 | | /// <returns>The result of the division.</returns> |
| | 6374 | | public ElectricCharge<T> Divide(T b) |
| | 6375 | | { |
| | 6376 | | return this / b; |
| | 6377 | | } |
| | 6378 | |
|
| | 6379 | | /// <summary>Divides an ElectricCharge measurement by another ElectricCharge measurement resulting in a scalar numer |
| | 6380 | | /// <param name="a">The first operand of the division operation.</param> |
| | 6381 | | /// <param name="b">The second operand of the division operation.</param> |
| | 6382 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 6383 | | public static T operator /(ElectricCharge<T> a, ElectricCharge<T> b) |
| | 6384 | | { |
| | 6385 | | return Divide(a, b); |
| | 6386 | | } |
| | 6387 | |
|
| | 6388 | | /// <summary>Divides an ElectricCharge measurement by another ElectricCharge measurement resulting in a scalar numer |
| | 6389 | | /// <param name="b">The second operand of the division operation.</param> |
| | 6390 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 6391 | | public T Divide(ElectricCharge<T> b) |
| | 6392 | | { |
| | 6393 | | return this / b; |
| | 6394 | | } |
| | 6395 | |
|
| | 6396 | |
|
| | 6397 | | #region ElectricCharge<T> / ElectricCurrent<T> = Time<T> |
| | 6398 | |
|
| | 6399 | | /// <summary>Divides ElectricCharge by ElectricCurrent resulting in Time.</summary> |
| | 6400 | | /// <param name="a">The ElectricCharge to be divided.</param> |
| | 6401 | | /// <param name="b">The ElectricCurrent to divide by.</param> |
| | 6402 | | /// <returns>The Time result of the division.</returns> |
| | 6403 | | public static Time<T> Divide(ElectricCharge<T> a, ElectricCurrent<T> b) |
| | 6404 | | { |
| | 6405 | | ElectricCharge.Units ElectricChargeUnits1 = a._ElectricChargeUnits1 <= b._ElectricChargeUnits1 ? a._ElectricCharge |
| | 6406 | |
|
| | 6407 | | T A = a[ElectricChargeUnits1]; |
| | 6408 | | T B = b[ElectricChargeUnits1, b._TimeUnits2]; |
| | 6409 | | T C = Statics.Division(A, B); |
| | 6410 | |
|
| | 6411 | | return new Time<T>(C |
| | 6412 | | , b._TimeUnits2 |
| | 6413 | | ); |
| | 6414 | | } |
| | 6415 | |
|
| | 6416 | | /// <summary>Divides ElectricCharge by ElectricCurrent resulting in Time.</summary> |
| | 6417 | | /// <param name="a">The ElectricCharge to be divided.</param> |
| | 6418 | | /// <param name="b">The ElectricCurrent to divide by.</param> |
| | 6419 | | /// <returns>The Time result of the division.</returns> |
| | 6420 | | public static Time<T> operator /(ElectricCharge<T> a, ElectricCurrent<T> b) |
| | 6421 | | { |
| | 6422 | | return Divide(a, b); |
| | 6423 | | } |
| | 6424 | |
|
| | 6425 | | /// <summary>Divides ElectricCharge by ElectricCurrent resulting in Time.</summary> |
| | 6426 | | /// <param name="b">The ElectricCurrent to divide by.</param> |
| | 6427 | | /// <returns>The Time result of the division.</returns> |
| | 6428 | | public Time<T> Divide(ElectricCurrent<T> b) |
| | 6429 | | { |
| | 6430 | | return this / b; |
| | 6431 | | } |
| | 6432 | |
|
| | 6433 | | #endregion |
| | 6434 | |
|
| | 6435 | |
|
| | 6436 | | #region ElectricCharge<T> / Time<T> = ElectricCurrent<T> |
| | 6437 | |
|
| | 6438 | | /// <summary>Divides ElectricCharge by Time resulting in ElectricCurrent.</summary> |
| | 6439 | | /// <param name="a">The ElectricCharge to be divided.</param> |
| | 6440 | | /// <param name="b">The Time to divide by.</param> |
| | 6441 | | /// <returns>The ElectricCurrent result of the division.</returns> |
| | 6442 | | public static ElectricCurrent<T> Divide(ElectricCharge<T> a, Time<T> b) |
| | 6443 | | { |
| | 6444 | |
|
| | 6445 | | T A = a[a._ElectricChargeUnits1]; |
| | 6446 | | T B = b[b._TimeUnits1]; |
| | 6447 | | T C = Statics.Division(A, B); |
| | 6448 | |
|
| | 6449 | | return new ElectricCurrent<T>(C |
| | 6450 | | , a._ElectricChargeUnits1 |
| | 6451 | | , b._TimeUnits1 |
| | 6452 | | ); |
| | 6453 | | } |
| | 6454 | |
|
| | 6455 | | /// <summary>Divides ElectricCharge by Time resulting in ElectricCurrent.</summary> |
| | 6456 | | /// <param name="a">The ElectricCharge to be divided.</param> |
| | 6457 | | /// <param name="b">The Time to divide by.</param> |
| | 6458 | | /// <returns>The ElectricCurrent result of the division.</returns> |
| | 6459 | | public static ElectricCurrent<T> operator /(ElectricCharge<T> a, Time<T> b) |
| | 6460 | | { |
| | 6461 | | return Divide(a, b); |
| | 6462 | | } |
| | 6463 | |
|
| | 6464 | | /// <summary>Divides ElectricCharge by Time resulting in ElectricCurrent.</summary> |
| | 6465 | | /// <param name="b">The Time to divide by.</param> |
| | 6466 | | /// <returns>The ElectricCurrent result of the division.</returns> |
| | 6467 | | public ElectricCurrent<T> Divide(Time<T> b) |
| | 6468 | | { |
| | 6469 | | return this / b; |
| | 6470 | | } |
| | 6471 | |
|
| | 6472 | | #endregion |
| | 6473 | |
|
| | 6474 | | #endregion |
| | 6475 | |
|
| | 6476 | | #region LessThan |
| | 6477 | |
|
| | 6478 | | /// <summary>Determines if an ElectricCharge measurement is less than another ElectricCharge measurement.</summary> |
| | 6479 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 6480 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 6481 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 6482 | | public static bool LessThan(ElectricCharge<T> a, ElectricCharge<T> b) |
| | 6483 | | { |
| | 6484 | | return LogicBase(a, b, Statics.LessThan); |
| | 6485 | | } |
| | 6486 | |
|
| | 6487 | | /// <summary>Determines if an ElectricCharge measurement is less than another ElectricCharge measurement.</summary> |
| | 6488 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 6489 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 6490 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 6491 | | public static bool operator <(ElectricCharge<T> a, ElectricCharge<T> b) |
| | 6492 | | { |
| | 6493 | | return LessThan(a, b); |
| | 6494 | | } |
| | 6495 | |
|
| | 6496 | | /// <summary>Determines if an ElectricCharge measurement is less than another ElectricCharge measurement.</summary> |
| | 6497 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 6498 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 6499 | | public bool LessThan(ElectricCharge<T> b) |
| | 6500 | | { |
| | 6501 | | return this < b; |
| | 6502 | | } |
| | 6503 | |
|
| | 6504 | | #endregion |
| | 6505 | |
|
| | 6506 | | #region GreaterThan |
| | 6507 | |
|
| | 6508 | | /// <summary>Determines if an ElectricCharge measurement is greater than another ElectricCharge measurement.</summar |
| | 6509 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 6510 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 6511 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 6512 | | public static bool GreaterThan(ElectricCharge<T> a, ElectricCharge<T> b) |
| | 6513 | | { |
| | 6514 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 6515 | | } |
| | 6516 | |
|
| | 6517 | | /// <summary>Determines if an ElectricCharge measurement is greater than another ElectricCharge measurement.</summar |
| | 6518 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 6519 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 6520 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 6521 | | public static bool operator >(ElectricCharge<T> a, ElectricCharge<T> b) |
| | 6522 | | { |
| | 6523 | | return GreaterThan(a, b); |
| | 6524 | | } |
| | 6525 | |
|
| | 6526 | | /// <summary>Determines if an ElectricCharge measurement is greater than another ElectricCharge measurement.</summar |
| | 6527 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 6528 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 6529 | | public bool GreaterThan(ElectricCharge<T> b) |
| | 6530 | | { |
| | 6531 | | return this > b; |
| | 6532 | | } |
| | 6533 | |
|
| | 6534 | | #endregion |
| | 6535 | |
|
| | 6536 | | #region LessThanOrEqual |
| | 6537 | |
|
| | 6538 | | /// <summary>Determines if an ElectricCharge measurement is less than or equal to another ElectricCharge measurement |
| | 6539 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 6540 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 6541 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 6542 | | public static bool LessThanOrEqual(ElectricCharge<T> a, ElectricCharge<T> b) |
| | 6543 | | { |
| | 6544 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 6545 | | } |
| | 6546 | |
|
| | 6547 | | /// <summary>Determines if an ElectricCharge measurement is less than or equal to another ElectricCharge measurement |
| | 6548 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 6549 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 6550 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 6551 | | public static bool operator <=(ElectricCharge<T> a, ElectricCharge<T> b) |
| | 6552 | | { |
| | 6553 | | return LessThanOrEqual(a, b); |
| | 6554 | | } |
| | 6555 | |
|
| | 6556 | | /// <summary>Determines if an ElectricCharge measurement is less than or equal to another ElectricCharge measurement |
| | 6557 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 6558 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 6559 | | public bool LessThanOrEqual(ElectricCharge<T> b) |
| | 6560 | | { |
| | 6561 | | return this <= b; |
| | 6562 | | } |
| | 6563 | |
|
| | 6564 | | #endregion |
| | 6565 | |
|
| | 6566 | | #region GreaterThanOrEqual |
| | 6567 | |
|
| | 6568 | | /// <summary>Determines if an ElectricCharge measurement is greater than or equal to another ElectricCharge measurem |
| | 6569 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 6570 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 6571 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 6572 | | public static bool GreaterThanOrEqual(ElectricCharge<T> a, ElectricCharge<T> b) |
| | 6573 | | { |
| | 6574 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 6575 | | } |
| | 6576 | |
|
| | 6577 | | /// <summary>Determines if an ElectricCharge measurement is greater than or equal to another ElectricCharge measurem |
| | 6578 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 6579 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 6580 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 6581 | | public static bool operator >=(ElectricCharge<T> a, ElectricCharge<T> b) |
| | 6582 | | { |
| | 6583 | | return GreaterThanOrEqual(a, b); |
| | 6584 | | } |
| | 6585 | |
|
| | 6586 | | /// <summary>Determines if an ElectricCharge measurement is greater than or equal to another ElectricCharge measurem |
| | 6587 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 6588 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 6589 | | public bool GreaterThanOrEqual(ElectricCharge<T> b) |
| | 6590 | | { |
| | 6591 | | return this >= b; |
| | 6592 | | } |
| | 6593 | |
|
| | 6594 | | #endregion |
| | 6595 | |
|
| | 6596 | | #region Equal |
| | 6597 | |
|
| | 6598 | | /// <summary>Determines if an ElectricCharge measurement is equal to another ElectricCharge measurement.</summary> |
| | 6599 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 6600 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 6601 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 6602 | | public static bool Equal(ElectricCharge<T> a, ElectricCharge<T> b) |
| | 6603 | | { |
| | 6604 | | return LogicBase(a, b, Statics.Equate); |
| | 6605 | | } |
| | 6606 | |
|
| | 6607 | | /// <summary>Determines if an ElectricCharge measurement is equal to another ElectricCharge measurement.</summary> |
| | 6608 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 6609 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 6610 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 6611 | | public static bool operator ==(ElectricCharge<T> a, ElectricCharge<T> b) |
| | 6612 | | { |
| | 6613 | | return Equal(a, b); |
| | 6614 | | } |
| | 6615 | |
|
| | 6616 | | /// <summary>Determines if an ElectricCharge measurement is equal to another ElectricCharge measurement.</summary> |
| | 6617 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 6618 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 6619 | | public bool Equal(ElectricCharge<T> b) |
| | 6620 | | { |
| | 6621 | | return this == b; |
| | 6622 | | } |
| | 6623 | |
|
| | 6624 | | #endregion |
| | 6625 | |
|
| | 6626 | | #region NotEqual |
| | 6627 | |
|
| | 6628 | | /// <summary>Determines if an ElectricCharge measurement is not equal to another ElectricCharge measurement.</summar |
| | 6629 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 6630 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 6631 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 6632 | | public static bool NotEqual(ElectricCharge<T> a, ElectricCharge<T> b) |
| | 6633 | | { |
| | 6634 | | return LogicBase(a, b, Statics.Inequate); |
| | 6635 | | } |
| | 6636 | |
|
| | 6637 | | /// <summary>Determines if an ElectricCharge measurement is not equal to another ElectricCharge measurement.</summar |
| | 6638 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 6639 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 6640 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 6641 | | public static bool operator !=(ElectricCharge<T> a, ElectricCharge<T> b) |
| | 6642 | | { |
| | 6643 | | return NotEqual(a, b); |
| | 6644 | | } |
| | 6645 | |
|
| | 6646 | | /// <summary>Determines if an ElectricCharge measurement is not equal to another ElectricCharge measurement.</summar |
| | 6647 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 6648 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 6649 | | public bool NotEqual(ElectricCharge<T> b) |
| | 6650 | | { |
| | 6651 | | return this != b; |
| | 6652 | | } |
| | 6653 | |
|
| | 6654 | | #endregion |
| | 6655 | |
|
| | 6656 | | #endregion |
| | 6657 | |
|
| | 6658 | | #region Overrides |
| | 6659 | |
|
| | 6660 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 6661 | | /// <param name="obj">The object to check for equality with.</param> |
| | 6662 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 6663 | | public override bool Equals(object obj) |
| | 6664 | | { |
| | 6665 | | if (obj is ElectricCharge<T>) |
| | 6666 | | { |
| | 6667 | | return this == (ElectricCharge<T>)obj; |
| | 6668 | | } |
| | 6669 | | return false; |
| | 6670 | | } |
| | 6671 | |
|
| | 6672 | | /// <summary>Converts the ElectricCharge measurement to a string represenation.</summary> |
| | 6673 | | /// <returns>The string representation of the measurement.</returns> |
| | 6674 | | public override string ToString() |
| | 6675 | | { |
| | 6676 | | return _measurement + " " + |
| | 6677 | | _ElectricChargeUnits1 |
| | 6678 | |
|
| | 6679 | | ; |
| | 6680 | | } |
| | 6681 | |
|
| | 6682 | | /// <summary>Base hashing function for ElectricCharge measurements.</summary> |
| | 6683 | | /// <returns>Computed hash code for this instance.</returns> |
| | 6684 | | public override int GetHashCode() => Hash(_measurement); |
| | 6685 | |
|
| | 6686 | | #endregion |
| | 6687 | | } |
| | 6688 | |
|
| | 6689 | | #endregion |
| | 6690 | |
|
| | 6691 | | #region ElectricCurrent |
| | 6692 | |
|
| | 6693 | | internal static partial class ParsingFunctions |
| | 6694 | | { |
| | 6695 | | [Measurement.Parseable("ElectricCharge/Time")] |
| | 6696 | | public static object ElectricCurrent<T>(T value, object[] units) |
| | 6697 | | { |
| | 6698 | | if (units.Length != 2) |
| | 6699 | | { |
| | 6700 | | throw new Exception("Bug in Towel. Invalid parameters to ElectricCurrent Factory."); |
| | 6701 | | } |
| | 6702 | | if (!(units[0] is ElectricCharge.Units)) |
| | 6703 | | { |
| | 6704 | | throw new Exception("Bug in Towel. Invalid parameters to ElectricCurrent Factory."); |
| | 6705 | | } |
| | 6706 | | if (!(units[1] is Time.Units)) |
| | 6707 | | { |
| | 6708 | | throw new Exception("Bug in Towel. Invalid parameters to ElectricCurrent Factory."); |
| | 6709 | | } |
| | 6710 | | return new ElectricCurrent<T>(value |
| | 6711 | | , (ElectricCharge.Units)units[0] |
| | 6712 | | , (Time.Units)units[1] |
| | 6713 | | ); |
| | 6714 | | } |
| | 6715 | | } |
| | 6716 | |
|
| | 6717 | | /// <summary>ElectricCurrent measurement with a value and the units.</summary> |
| | 6718 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 6719 | | public struct ElectricCurrent<T> |
| | 6720 | | { |
| | 6721 | | internal T _measurement; |
| | 6722 | | internal ElectricCharge.Units _ElectricChargeUnits1; |
| | 6723 | | internal Time.Units _TimeUnits2; |
| | 6724 | |
|
| | 6725 | | #region Statics |
| | 6726 | |
|
| | 6727 | | /// <summary>Converts a ElectricCurrent measurement from units to another.</summary> |
| | 6728 | | /// <param name="value">The value to convert the units of.</param> |
| | 6729 | | /// <param name="fromElectricChargeUnits1">The current units of the measurement.</param> |
| | 6730 | | /// <param name="fromTimeUnits2">The current units of the measurement.</param> |
| | 6731 | | /// <param name="toElectricChargeUnits1">The desired units of the measurement.</param> |
| | 6732 | | /// <param name="toTimeUnits2">The desired units of the measurement.</param> |
| | 6733 | | /// <returns>The ElectricCurrent measurement converted into the desired units.</returns> |
| | 6734 | | public static T Convert(T value |
| | 6735 | | , ElectricCharge.Units fromElectricChargeUnits1 |
| | 6736 | | , Time.Units fromTimeUnits2 |
| | 6737 | | , ElectricCharge.Units toElectricChargeUnits1 |
| | 6738 | | , Time.Units toTimeUnits2 |
| | 6739 | | ) |
| | 6740 | | { |
| | 6741 | | ElectricCurrent<T> measurement = new ElectricCurrent<T>(value |
| | 6742 | | , fromElectricChargeUnits1 |
| | 6743 | | , fromTimeUnits2 |
| | 6744 | | ); |
| | 6745 | | return measurement[ |
| | 6746 | | toElectricChargeUnits1 |
| | 6747 | | , toTimeUnits2 |
| | 6748 | | ]; |
| | 6749 | | } |
| | 6750 | |
|
| | 6751 | | /// <summary>Converts a ElectricCurrent measurement from units to another.</summary> |
| | 6752 | | /// <param name="value">The value to convert the units of.</param> |
| | 6753 | | /// <param name="from">The current units of the measurement.</param> |
| | 6754 | | /// <param name="to">The desired units of the measurement.</param> |
| | 6755 | | /// <returns>The ElectricCurrent measurement converted into the desired units.</returns> |
| | 6756 | | public static T Convert(T value, |
| | 6757 | | MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits from, |
| | 6758 | | MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits to) |
| | 6759 | | { |
| | 6760 | | return Convert(value |
| | 6761 | | , from._ElectricChargeUnits1 |
| | 6762 | | , from._TimeUnits2 |
| | 6763 | | , to._ElectricChargeUnits1 |
| | 6764 | | , to._TimeUnits2 |
| | 6765 | | ); |
| | 6766 | | } |
| | 6767 | |
|
| | 6768 | | /// <summary>Parses a ElectricCurrent measurement string.</summary> |
| | 6769 | | /// <param name="string">The string to be parsed.</param> |
| | 6770 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 6771 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 6772 | | public static (bool Success, ElectricCurrent<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value |
| | 6773 | |
|
| | 6774 | | #endregion |
| | 6775 | |
|
| | 6776 | | #region Constructors |
| | 6777 | |
|
| | 6778 | | /// <summary>Constructs an ElectricCurrent with the measurement value and units.</summary> |
| | 6779 | | /// <param name="measurement">The measurement value of the ElectricCurrent.</param> |
| | 6780 | | /// <param name="units">The units of the ElectricCurrent.</param> |
| | 6781 | | public ElectricCurrent(T measurement, MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits units) : this(measurement |
| | 6782 | | , units._ElectricChargeUnits1 |
| | 6783 | | , units._TimeUnits2 |
| | 6784 | | ) { } |
| | 6785 | |
|
| | 6786 | |
|
| | 6787 | | /// <summary>Constructs an ElectricCurrent with the measurement value and units.</summary> |
| | 6788 | | /// <param name="measurement">The measurement value of the ElectricCurrent.</param> |
| | 6789 | | /// <param name="ElectricChargeUnits1">The units of the ElectricCurrent.</param> |
| | 6790 | | /// <param name="TimeUnits2">The units of the ElectricCurrent.</param> |
| | 6791 | | public ElectricCurrent(T measurement |
| | 6792 | | , ElectricCharge.Units ElectricChargeUnits1 |
| | 6793 | | , Time.Units TimeUnits2 |
| | 6794 | | ) |
| | 6795 | | { |
| | 6796 | | _measurement = measurement; |
| | 6797 | | _ElectricChargeUnits1 = ElectricChargeUnits1; |
| | 6798 | | _TimeUnits2 = TimeUnits2; |
| | 6799 | | } |
| | 6800 | |
|
| | 6801 | | #endregion |
| | 6802 | |
|
| | 6803 | | #region Properties |
| | 6804 | |
|
| | 6805 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 6806 | | public ElectricCharge.Units ElectricChargeUnits1 |
| | 6807 | | { |
| | 6808 | | get { return _ElectricChargeUnits1; } |
| | 6809 | | set |
| | 6810 | | { |
| | 6811 | | if (value != _ElectricChargeUnits1) |
| | 6812 | | { |
| | 6813 | | _measurement = this[value, _TimeUnits2]; |
| | 6814 | | _ElectricChargeUnits1 = value; |
| | 6815 | | } |
| | 6816 | | } |
| | 6817 | | } |
| | 6818 | |
|
| | 6819 | | /// <summary>The #2 component of this measurements units.</summary> |
| | 6820 | | public Time.Units TimeUnits2 |
| | 6821 | | { |
| | 6822 | | get { return _TimeUnits2; } |
| | 6823 | | set |
| | 6824 | | { |
| | 6825 | | if (value != _TimeUnits2) |
| | 6826 | | { |
| | 6827 | | _measurement = this[_ElectricChargeUnits1, value]; |
| | 6828 | | _TimeUnits2 = value; |
| | 6829 | | } |
| | 6830 | | } |
| | 6831 | | } |
| | 6832 | |
|
| | 6833 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 6834 | | /// <param name="units">The units to get the measurement in.</param> |
| | 6835 | | /// <returns>The measurement value in the specified units.</returns> |
| | 6836 | | public T this[MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits units] |
| | 6837 | | { |
| | 6838 | | get { return this[units._ElectricChargeUnits1, units._TimeUnits2]; } |
| | 6839 | | } |
| | 6840 | |
|
| | 6841 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 6842 | | /// <param name="ElectricChargeUnits1">The #1 component of this measurements units.</param> |
| | 6843 | | /// <param name="TimeUnits2">The #2 component of this measurements units.</param> |
| | 6844 | | /// <returns>The measurement value in the specified units.</returns> |
| | 6845 | | public T this[ElectricCharge.Units ElectricChargeUnits1, Time.Units TimeUnits2] |
| | 6846 | | { |
| | 6847 | | get |
| | 6848 | | { |
| | 6849 | | T measurement = _measurement; |
| | 6850 | | if (ElectricChargeUnits1 != _ElectricChargeUnits1) |
| | 6851 | | { |
| | 6852 | | measurement = ElectricCharge<T>.Table[(int)_ElectricChargeUnits1][(int)ElectricChargeUnits1](measurement); |
| | 6853 | | //if (ElectricChargeUnits1 < _ElectricChargeUnits1) |
| | 6854 | | //{ |
| | 6855 | | // measurement = ElectricCharge<T>.Table[(int)_ElectricChargeUnits1][(int)ElectricChargeUnits1](measurement); |
| | 6856 | | //} |
| | 6857 | | //else |
| | 6858 | | //{ |
| | 6859 | | // measurement = ElectricCharge<T>.Table[(int)ElectricChargeUnits1][(int)_ElectricChargeUnits1](measurement); |
| | 6860 | | //} |
| | 6861 | | } |
| | 6862 | | if (TimeUnits2 != _TimeUnits2) |
| | 6863 | | { |
| | 6864 | | measurement = Time<T>.Table[(int)TimeUnits2][(int)_TimeUnits2](measurement); |
| | 6865 | | //if (TimeUnits2 > _TimeUnits2) |
| | 6866 | | //{ |
| | 6867 | | // measurement = Time<T>.Table[(int)_TimeUnits2][(int)TimeUnits2](measurement); |
| | 6868 | | //} |
| | 6869 | | //else |
| | 6870 | | //{ |
| | 6871 | | // measurement = Time<T>.Table[(int)TimeUnits2][(int)_TimeUnits2](measurement); |
| | 6872 | | //} |
| | 6873 | | } |
| | 6874 | | return measurement; |
| | 6875 | | } |
| | 6876 | | } |
| | 6877 | |
|
| | 6878 | | #endregion |
| | 6879 | |
|
| | 6880 | | #region Casting Operators |
| | 6881 | |
|
| | 6882 | | /// <summary>Converts a ValueTuple to a ElectricCurrent measurement.</summary> |
| | 6883 | | /// <param name="valueTuple">The ValueTuple to converted into a ElectricCurrent measurement.</param> |
| | 6884 | | public static implicit operator ElectricCurrent<T>((T, MeasurementUnitsSyntaxTypes.ElectricCurrentBaseUnits) valueTu |
| | 6885 | | { |
| | 6886 | | return new ElectricCurrent<T>(valueTuple.Item1, valueTuple.Item2); |
| | 6887 | | } |
| | 6888 | |
|
| | 6889 | | #endregion |
| | 6890 | |
|
| | 6891 | | #region Mathematics |
| | 6892 | |
|
| | 6893 | | #region Bases |
| | 6894 | |
|
| | 6895 | | internal static ElectricCurrent<T> MathBase(ElectricCurrent<T> a, T b, Func<T, T, T> func) |
| | 6896 | | { |
| | 6897 | | return new ElectricCurrent<T>(func(a._measurement, b) |
| | 6898 | | , a._ElectricChargeUnits1 |
| | 6899 | | , a._TimeUnits2 |
| | 6900 | | ); |
| | 6901 | | } |
| | 6902 | |
|
| | 6903 | | internal static ElectricCurrent<T> MathBase(ElectricCurrent<T> a, ElectricCurrent<T> b, Func<T, T, T> func) |
| | 6904 | | { |
| | 6905 | | ElectricCharge.Units ElectricChargeUnits1 = a._ElectricChargeUnits1 <= b._ElectricChargeUnits1 ? a._ElectricCharge |
| | 6906 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 6907 | | T A = a[ElectricChargeUnits1, TimeUnits2]; |
| | 6908 | | T B = b[ElectricChargeUnits1, TimeUnits2]; |
| | 6909 | | T C = func(A, B); |
| | 6910 | | return new ElectricCurrent<T>(C, ElectricChargeUnits1, TimeUnits2); |
| | 6911 | | } |
| | 6912 | |
|
| | 6913 | | internal static bool LogicBase(ElectricCurrent<T> a, ElectricCurrent<T> b, Func<T, T, bool> func) |
| | 6914 | | { |
| | 6915 | | ElectricCharge.Units ElectricChargeUnits1 = a._ElectricChargeUnits1 <= b._ElectricChargeUnits1 ? a._ElectricCharge |
| | 6916 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 6917 | | T A = a[ElectricChargeUnits1, TimeUnits2]; |
| | 6918 | | T B = b[ElectricChargeUnits1, TimeUnits2]; |
| | 6919 | | return func(A, B); |
| | 6920 | | } |
| | 6921 | |
|
| | 6922 | | #endregion |
| | 6923 | |
|
| | 6924 | | #region Add |
| | 6925 | |
|
| | 6926 | | /// <summary>Adds two ElectricCurrent measurements.</summary> |
| | 6927 | | /// <param name="a">The first operand of the addition.</param> |
| | 6928 | | /// <param name="b">The second operand of the addition.</param> |
| | 6929 | | /// <returns>The result of the addition operation.</returns> |
| | 6930 | | public static ElectricCurrent<T> Add(ElectricCurrent<T> a, ElectricCurrent<T> b) |
| | 6931 | | { |
| | 6932 | | return MathBase(a, b, Statics.Addition); |
| | 6933 | | } |
| | 6934 | |
|
| | 6935 | | /// <summary>Adds two ElectricCurrent measurements.</summary> |
| | 6936 | | /// <param name="a">The first operand of the addition.</param> |
| | 6937 | | /// <param name="b">The second operand of the addition.</param> |
| | 6938 | | /// <returns>The result of the addition operation.</returns> |
| | 6939 | | public static ElectricCurrent<T> operator +(ElectricCurrent<T> a, ElectricCurrent<T> b) |
| | 6940 | | { |
| | 6941 | | return Add(a, b); |
| | 6942 | | } |
| | 6943 | |
|
| | 6944 | | /// <summary>Adds two ElectricCurrent measurements.</summary> |
| | 6945 | | /// <param name="b">The second operand of the addition.</param> |
| | 6946 | | /// <returns>The result of the addition operation.</returns> |
| | 6947 | | public ElectricCurrent<T> Add(ElectricCurrent<T> b) |
| | 6948 | | { |
| | 6949 | | return this + b; |
| | 6950 | | } |
| | 6951 | |
|
| | 6952 | | #endregion |
| | 6953 | |
|
| | 6954 | | #region Subtract |
| | 6955 | |
|
| | 6956 | | /// <summary>Subtracts two ElectricCurrent measurements.</summary> |
| | 6957 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 6958 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 6959 | | /// <returns>The result of the subtraction.</returns> |
| | 6960 | | public static ElectricCurrent<T> Subtract(ElectricCurrent<T> a, ElectricCurrent<T> b) |
| | 6961 | | { |
| | 6962 | | return MathBase(a, b, Statics.Subtraction); |
| | 6963 | | } |
| | 6964 | |
|
| | 6965 | | /// <summary>Subtracts two ElectricCurrent measurements.</summary> |
| | 6966 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 6967 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 6968 | | /// <returns>The result of the subtraction.</returns> |
| | 6969 | | public static ElectricCurrent<T> operator -(ElectricCurrent<T> a, ElectricCurrent<T> b) |
| | 6970 | | { |
| | 6971 | | return Subtract(a, b); |
| | 6972 | | } |
| | 6973 | |
|
| | 6974 | | /// <summary>Subtracts two ElectricCurrent measurements.</summary> |
| | 6975 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 6976 | | /// <returns>The result of the subtraction.</returns> |
| | 6977 | | public ElectricCurrent<T> Subtract(ElectricCurrent<T> b) |
| | 6978 | | { |
| | 6979 | | return this - b; |
| | 6980 | | } |
| | 6981 | |
|
| | 6982 | | #endregion |
| | 6983 | |
|
| | 6984 | | #region Multiply |
| | 6985 | |
|
| | 6986 | | /// <summary>Multiplies an ElectricCurrent by a scalar numeric value.</summary> |
| | 6987 | | /// <param name="a">The ElectricCurrent measurement to multiply.</param> |
| | 6988 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 6989 | | /// <returns>The result of the multiplication.</returns> |
| | 6990 | | public static ElectricCurrent<T> Multiply(ElectricCurrent<T> a, T b) |
| | 6991 | | { |
| | 6992 | | return MathBase(a, b, Statics.Multiplication); |
| | 6993 | | } |
| | 6994 | |
|
| | 6995 | | /// <summary>Multiplies an ElectricCurrent by a scalar numeric value.</summary> |
| | 6996 | | /// <param name="a">The ElectricCurrent measurement to multiply.</param> |
| | 6997 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 6998 | | /// <returns>The result of the multiplication.</returns> |
| | 6999 | | public static ElectricCurrent<T> Multiply(T b, ElectricCurrent<T> a) |
| | 7000 | | { |
| | 7001 | | return Multiply(a, b); |
| | 7002 | | } |
| | 7003 | |
|
| | 7004 | | /// <summary>Multiplies an ElectricCurrent by a scalar numeric value.</summary> |
| | 7005 | | /// <param name="a">The ElectricCurrent measurement to multiply.</param> |
| | 7006 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 7007 | | /// <returns>The result of the multiplication.</returns> |
| | 7008 | | public static ElectricCurrent<T> operator *(ElectricCurrent<T> a, T b) |
| | 7009 | | { |
| | 7010 | | return Multiply(a, b); |
| | 7011 | | } |
| | 7012 | |
|
| | 7013 | | /// <summary>Multiplies an ElectricCurrent by a scalar numeric value.</summary> |
| | 7014 | | /// <param name="a">The ElectricCurrent measurement to multiply.</param> |
| | 7015 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 7016 | | /// <returns>The result of the multiplication.</returns> |
| | 7017 | | public static ElectricCurrent<T> operator *(T b, ElectricCurrent<T> a) |
| | 7018 | | { |
| | 7019 | | return Multiply(b, a); |
| | 7020 | | } |
| | 7021 | |
|
| | 7022 | | /// <summary>Multiplies an ElectricCurrent by a scalar numeric value.</summary> |
| | 7023 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 7024 | | /// <returns>The result of the multiplication.</returns> |
| | 7025 | | public ElectricCurrent<T> Add(T b) |
| | 7026 | | { |
| | 7027 | | return this * b; |
| | 7028 | | } |
| | 7029 | |
|
| | 7030 | | #region ElectricCurrent<T> * Time<T> = ElectricCharge<T> |
| | 7031 | |
|
| | 7032 | | /// <summary>Mulitplies ElectricCurrent by Time resulting in ElectricCharge.</summary> |
| | 7033 | | /// <param name="a">The ElectricCurrent to be multiplied.</param> |
| | 7034 | | /// <param name="b">The Time to multiply by.</param> |
| | 7035 | | /// <returns>The ElectricCharge result of the multiplication.</returns> |
| | 7036 | | public static ElectricCharge<T> Multiply(ElectricCurrent<T> a, Time<T> b) |
| | 7037 | | { |
| | 7038 | | Time.Units TimeUnits1 = a._TimeUnits2 <= b._TimeUnits1 ? a._TimeUnits2 : b._TimeUnits1; |
| | 7039 | |
|
| | 7040 | | T A = a[a._ElectricChargeUnits1, TimeUnits1]; |
| | 7041 | | T B = b[TimeUnits1]; |
| | 7042 | | T C = Statics.Multiplication(A, B); |
| | 7043 | |
|
| | 7044 | | return new ElectricCharge<T>(C |
| | 7045 | | , a._ElectricChargeUnits1 |
| | 7046 | | ); |
| | 7047 | | } |
| | 7048 | |
|
| | 7049 | | /// <summary>Mulitplies ElectricCurrent by Time resulting in ElectricCharge.</summary> |
| | 7050 | | /// <param name="a">The ElectricCurrent to be multiplied.</param> |
| | 7051 | | /// <param name="b">The Time to multiply by.</param> |
| | 7052 | | /// <returns>The ElectricCharge result of the multiplication.</returns> |
| | 7053 | | public static ElectricCharge<T> operator *(ElectricCurrent<T> a, Time<T> b) |
| | 7054 | | { |
| | 7055 | | return Multiply(a, b); |
| | 7056 | | } |
| | 7057 | |
|
| | 7058 | | /// <summary>Mulitplies ElectricCurrent by Time resulting in ElectricCharge.</summary> |
| | 7059 | | /// <param name="b">The Time to multiply by.</param> |
| | 7060 | | /// <returns>The ElectricCharge result of the multiplication.</returns> |
| | 7061 | | public ElectricCharge<T> Multiply(Time<T> b) |
| | 7062 | | { |
| | 7063 | | return this * b; |
| | 7064 | | } |
| | 7065 | |
|
| | 7066 | | #endregion |
| | 7067 | |
|
| | 7068 | | #endregion |
| | 7069 | |
|
| | 7070 | | #region Divide |
| | 7071 | |
|
| | 7072 | | /// <summary>Divides an ElectricCurrent measurement by another ElectricCurrent measurement resulting in a scalar num |
| | 7073 | | /// <param name="a">The first operand of the division operation.</param> |
| | 7074 | | /// <param name="b">The second operand of the division operation.</param> |
| | 7075 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 7076 | | public static T Divide(ElectricCurrent<T> a, ElectricCurrent<T> b) |
| | 7077 | | { |
| | 7078 | | ElectricCharge.Units ElectricChargeUnits1 = a._ElectricChargeUnits1 <= b._ElectricChargeUnits1 ? a._ElectricCharge |
| | 7079 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 7080 | | T A = a[ElectricChargeUnits1, TimeUnits2]; |
| | 7081 | | T B = b[ElectricChargeUnits1, TimeUnits2]; |
| | 7082 | | return Statics.Division(A, B); |
| | 7083 | | } |
| | 7084 | |
|
| | 7085 | | /// <summary>Divides this ElectricCurrent measurement by a numaric scalar value.</summary> |
| | 7086 | | /// <param name="a">The ElectricCurrent measurement to divide.</param> |
| | 7087 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 7088 | | /// <returns>The result of the division.</returns> |
| | 7089 | | public static ElectricCurrent<T> Divide(ElectricCurrent<T> a, T b) |
| | 7090 | | { |
| | 7091 | | return MathBase(a, b, Statics.Division); |
| | 7092 | | } |
| | 7093 | |
|
| | 7094 | | /// <summary>Divides this ElectricCurrent measurement by a numaric scalar value.</summary> |
| | 7095 | | /// <param name="a">The ElectricCurrent measurement to divide.</param> |
| | 7096 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 7097 | | /// <returns>The result of the division.</returns> |
| | 7098 | | public static ElectricCurrent<T> operator /(ElectricCurrent<T> a, T b) |
| | 7099 | | { |
| | 7100 | | return Divide(a, b); |
| | 7101 | | } |
| | 7102 | |
|
| | 7103 | | /// <summary>Divides this ElectricCurrent measurement by a numaric scalar value.</summary> |
| | 7104 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 7105 | | /// <returns>The result of the division.</returns> |
| | 7106 | | public ElectricCurrent<T> Divide(T b) |
| | 7107 | | { |
| | 7108 | | return this / b; |
| | 7109 | | } |
| | 7110 | |
|
| | 7111 | | /// <summary>Divides an ElectricCurrent measurement by another ElectricCurrent measurement resulting in a scalar num |
| | 7112 | | /// <param name="a">The first operand of the division operation.</param> |
| | 7113 | | /// <param name="b">The second operand of the division operation.</param> |
| | 7114 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 7115 | | public static T operator /(ElectricCurrent<T> a, ElectricCurrent<T> b) |
| | 7116 | | { |
| | 7117 | | return Divide(a, b); |
| | 7118 | | } |
| | 7119 | |
|
| | 7120 | | /// <summary>Divides an ElectricCurrent measurement by another ElectricCurrent measurement resulting in a scalar num |
| | 7121 | | /// <param name="b">The second operand of the division operation.</param> |
| | 7122 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 7123 | | public T Divide(ElectricCurrent<T> b) |
| | 7124 | | { |
| | 7125 | | return this / b; |
| | 7126 | | } |
| | 7127 | |
|
| | 7128 | | #endregion |
| | 7129 | |
|
| | 7130 | | #region LessThan |
| | 7131 | |
|
| | 7132 | | /// <summary>Determines if an ElectricCurrent measurement is less than another ElectricCurrent measurement.</summary |
| | 7133 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 7134 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 7135 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 7136 | | public static bool LessThan(ElectricCurrent<T> a, ElectricCurrent<T> b) |
| | 7137 | | { |
| | 7138 | | return LogicBase(a, b, Statics.LessThan); |
| | 7139 | | } |
| | 7140 | |
|
| | 7141 | | /// <summary>Determines if an ElectricCurrent measurement is less than another ElectricCurrent measurement.</summary |
| | 7142 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 7143 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 7144 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 7145 | | public static bool operator <(ElectricCurrent<T> a, ElectricCurrent<T> b) |
| | 7146 | | { |
| | 7147 | | return LessThan(a, b); |
| | 7148 | | } |
| | 7149 | |
|
| | 7150 | | /// <summary>Determines if an ElectricCurrent measurement is less than another ElectricCurrent measurement.</summary |
| | 7151 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 7152 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 7153 | | public bool LessThan(ElectricCurrent<T> b) |
| | 7154 | | { |
| | 7155 | | return this < b; |
| | 7156 | | } |
| | 7157 | |
|
| | 7158 | | #endregion |
| | 7159 | |
|
| | 7160 | | #region GreaterThan |
| | 7161 | |
|
| | 7162 | | /// <summary>Determines if an ElectricCurrent measurement is greater than another ElectricCurrent measurement.</summ |
| | 7163 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 7164 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 7165 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 7166 | | public static bool GreaterThan(ElectricCurrent<T> a, ElectricCurrent<T> b) |
| | 7167 | | { |
| | 7168 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 7169 | | } |
| | 7170 | |
|
| | 7171 | | /// <summary>Determines if an ElectricCurrent measurement is greater than another ElectricCurrent measurement.</summ |
| | 7172 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 7173 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 7174 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 7175 | | public static bool operator >(ElectricCurrent<T> a, ElectricCurrent<T> b) |
| | 7176 | | { |
| | 7177 | | return GreaterThan(a, b); |
| | 7178 | | } |
| | 7179 | |
|
| | 7180 | | /// <summary>Determines if an ElectricCurrent measurement is greater than another ElectricCurrent measurement.</summ |
| | 7181 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 7182 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 7183 | | public bool GreaterThan(ElectricCurrent<T> b) |
| | 7184 | | { |
| | 7185 | | return this > b; |
| | 7186 | | } |
| | 7187 | |
|
| | 7188 | | #endregion |
| | 7189 | |
|
| | 7190 | | #region LessThanOrEqual |
| | 7191 | |
|
| | 7192 | | /// <summary>Determines if an ElectricCurrent measurement is less than or equal to another ElectricCurrent measureme |
| | 7193 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 7194 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 7195 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 7196 | | public static bool LessThanOrEqual(ElectricCurrent<T> a, ElectricCurrent<T> b) |
| | 7197 | | { |
| | 7198 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 7199 | | } |
| | 7200 | |
|
| | 7201 | | /// <summary>Determines if an ElectricCurrent measurement is less than or equal to another ElectricCurrent measureme |
| | 7202 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 7203 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 7204 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 7205 | | public static bool operator <=(ElectricCurrent<T> a, ElectricCurrent<T> b) |
| | 7206 | | { |
| | 7207 | | return LessThanOrEqual(a, b); |
| | 7208 | | } |
| | 7209 | |
|
| | 7210 | | /// <summary>Determines if an ElectricCurrent measurement is less than or equal to another ElectricCurrent measureme |
| | 7211 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 7212 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 7213 | | public bool LessThanOrEqual(ElectricCurrent<T> b) |
| | 7214 | | { |
| | 7215 | | return this <= b; |
| | 7216 | | } |
| | 7217 | |
|
| | 7218 | | #endregion |
| | 7219 | |
|
| | 7220 | | #region GreaterThanOrEqual |
| | 7221 | |
|
| | 7222 | | /// <summary>Determines if an ElectricCurrent measurement is greater than or equal to another ElectricCurrent measur |
| | 7223 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 7224 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 7225 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 7226 | | public static bool GreaterThanOrEqual(ElectricCurrent<T> a, ElectricCurrent<T> b) |
| | 7227 | | { |
| | 7228 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 7229 | | } |
| | 7230 | |
|
| | 7231 | | /// <summary>Determines if an ElectricCurrent measurement is greater than or equal to another ElectricCurrent measur |
| | 7232 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 7233 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 7234 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 7235 | | public static bool operator >=(ElectricCurrent<T> a, ElectricCurrent<T> b) |
| | 7236 | | { |
| | 7237 | | return GreaterThanOrEqual(a, b); |
| | 7238 | | } |
| | 7239 | |
|
| | 7240 | | /// <summary>Determines if an ElectricCurrent measurement is greater than or equal to another ElectricCurrent measur |
| | 7241 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 7242 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 7243 | | public bool GreaterThanOrEqual(ElectricCurrent<T> b) |
| | 7244 | | { |
| | 7245 | | return this >= b; |
| | 7246 | | } |
| | 7247 | |
|
| | 7248 | | #endregion |
| | 7249 | |
|
| | 7250 | | #region Equal |
| | 7251 | |
|
| | 7252 | | /// <summary>Determines if an ElectricCurrent measurement is equal to another ElectricCurrent measurement.</summary> |
| | 7253 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 7254 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 7255 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 7256 | | public static bool Equal(ElectricCurrent<T> a, ElectricCurrent<T> b) |
| | 7257 | | { |
| | 7258 | | return LogicBase(a, b, Statics.Equate); |
| | 7259 | | } |
| | 7260 | |
|
| | 7261 | | /// <summary>Determines if an ElectricCurrent measurement is equal to another ElectricCurrent measurement.</summary> |
| | 7262 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 7263 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 7264 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 7265 | | public static bool operator ==(ElectricCurrent<T> a, ElectricCurrent<T> b) |
| | 7266 | | { |
| | 7267 | | return Equal(a, b); |
| | 7268 | | } |
| | 7269 | |
|
| | 7270 | | /// <summary>Determines if an ElectricCurrent measurement is equal to another ElectricCurrent measurement.</summary> |
| | 7271 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 7272 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 7273 | | public bool Equal(ElectricCurrent<T> b) |
| | 7274 | | { |
| | 7275 | | return this == b; |
| | 7276 | | } |
| | 7277 | |
|
| | 7278 | | #endregion |
| | 7279 | |
|
| | 7280 | | #region NotEqual |
| | 7281 | |
|
| | 7282 | | /// <summary>Determines if an ElectricCurrent measurement is not equal to another ElectricCurrent measurement.</summ |
| | 7283 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 7284 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 7285 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 7286 | | public static bool NotEqual(ElectricCurrent<T> a, ElectricCurrent<T> b) |
| | 7287 | | { |
| | 7288 | | return LogicBase(a, b, Statics.Inequate); |
| | 7289 | | } |
| | 7290 | |
|
| | 7291 | | /// <summary>Determines if an ElectricCurrent measurement is not equal to another ElectricCurrent measurement.</summ |
| | 7292 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 7293 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 7294 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 7295 | | public static bool operator !=(ElectricCurrent<T> a, ElectricCurrent<T> b) |
| | 7296 | | { |
| | 7297 | | return NotEqual(a, b); |
| | 7298 | | } |
| | 7299 | |
|
| | 7300 | | /// <summary>Determines if an ElectricCurrent measurement is not equal to another ElectricCurrent measurement.</summ |
| | 7301 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 7302 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 7303 | | public bool NotEqual(ElectricCurrent<T> b) |
| | 7304 | | { |
| | 7305 | | return this != b; |
| | 7306 | | } |
| | 7307 | |
|
| | 7308 | | #endregion |
| | 7309 | |
|
| | 7310 | | #endregion |
| | 7311 | |
|
| | 7312 | | #region Overrides |
| | 7313 | |
|
| | 7314 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 7315 | | /// <param name="obj">The object to check for equality with.</param> |
| | 7316 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 7317 | | public override bool Equals(object obj) |
| | 7318 | | { |
| | 7319 | | if (obj is ElectricCurrent<T>) |
| | 7320 | | { |
| | 7321 | | return this == (ElectricCurrent<T>)obj; |
| | 7322 | | } |
| | 7323 | | return false; |
| | 7324 | | } |
| | 7325 | |
|
| | 7326 | | /// <summary>Converts the ElectricCurrent measurement to a string represenation.</summary> |
| | 7327 | | /// <returns>The string representation of the measurement.</returns> |
| | 7328 | | public override string ToString() |
| | 7329 | | { |
| | 7330 | | return _measurement + " " + |
| | 7331 | | _ElectricChargeUnits1 |
| | 7332 | | + "/" + |
| | 7333 | | _TimeUnits2 |
| | 7334 | | ; |
| | 7335 | | } |
| | 7336 | |
|
| | 7337 | | /// <summary>Base hashing function for ElectricCurrent measurements.</summary> |
| | 7338 | | /// <returns>Computed hash code for this instance.</returns> |
| | 7339 | | public override int GetHashCode() => Hash(_measurement); |
| | 7340 | |
|
| | 7341 | | #endregion |
| | 7342 | | } |
| | 7343 | |
|
| | 7344 | | #endregion |
| | 7345 | |
|
| | 7346 | | #region Energy |
| | 7347 | |
|
| | 7348 | | internal static partial class ParsingFunctions |
| | 7349 | | { |
| | 7350 | | [Measurement.Parseable("Mass*Length*Length/Time/Time")] |
| | 7351 | | public static object Energy<T>(T value, object[] units) |
| | 7352 | | { |
| | 7353 | | if (units.Length != 5) |
| | 7354 | | { |
| | 7355 | | throw new Exception("Bug in Towel. Invalid parameters to Energy Factory."); |
| | 7356 | | } |
| | 7357 | | if (!(units[0] is Mass.Units)) |
| | 7358 | | { |
| | 7359 | | throw new Exception("Bug in Towel. Invalid parameters to Energy Factory."); |
| | 7360 | | } |
| | 7361 | | if (!(units[1] is Length.Units)) |
| | 7362 | | { |
| | 7363 | | throw new Exception("Bug in Towel. Invalid parameters to Energy Factory."); |
| | 7364 | | } |
| | 7365 | | if (!(units[2] is Length.Units)) |
| | 7366 | | { |
| | 7367 | | throw new Exception("Bug in Towel. Invalid parameters to Energy Factory."); |
| | 7368 | | } |
| | 7369 | | if (!(units[3] is Time.Units)) |
| | 7370 | | { |
| | 7371 | | throw new Exception("Bug in Towel. Invalid parameters to Energy Factory."); |
| | 7372 | | } |
| | 7373 | | if (!(units[4] is Time.Units)) |
| | 7374 | | { |
| | 7375 | | throw new Exception("Bug in Towel. Invalid parameters to Energy Factory."); |
| | 7376 | | } |
| | 7377 | | return new Energy<T>(value |
| | 7378 | | , (Mass.Units)units[0] |
| | 7379 | | , (Length.Units)units[1] |
| | 7380 | | , (Length.Units)units[2] |
| | 7381 | | , (Time.Units)units[3] |
| | 7382 | | , (Time.Units)units[4] |
| | 7383 | | ); |
| | 7384 | | } |
| | 7385 | | } |
| | 7386 | |
|
| | 7387 | | /// <summary>Energy measurement with a value and the units.</summary> |
| | 7388 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 7389 | | public struct Energy<T> |
| | 7390 | | { |
| | 7391 | | internal T _measurement; |
| | 7392 | | internal Mass.Units _MassUnits1; |
| | 7393 | | internal Length.Units _LengthUnits2; |
| | 7394 | | internal Length.Units _LengthUnits3; |
| | 7395 | | internal Time.Units _TimeUnits4; |
| | 7396 | | internal Time.Units _TimeUnits5; |
| | 7397 | |
|
| | 7398 | | #region Statics |
| | 7399 | |
|
| | 7400 | | /// <summary>Converts a Energy measurement from units to another.</summary> |
| | 7401 | | /// <param name="value">The value to convert the units of.</param> |
| | 7402 | | /// <param name="fromMassUnits1">The current units of the measurement.</param> |
| | 7403 | | /// <param name="fromLengthUnits2">The current units of the measurement.</param> |
| | 7404 | | /// <param name="fromLengthUnits3">The current units of the measurement.</param> |
| | 7405 | | /// <param name="fromTimeUnits4">The current units of the measurement.</param> |
| | 7406 | | /// <param name="fromTimeUnits5">The current units of the measurement.</param> |
| | 7407 | | /// <param name="toMassUnits1">The desired units of the measurement.</param> |
| | 7408 | | /// <param name="toLengthUnits2">The desired units of the measurement.</param> |
| | 7409 | | /// <param name="toLengthUnits3">The desired units of the measurement.</param> |
| | 7410 | | /// <param name="toTimeUnits4">The desired units of the measurement.</param> |
| | 7411 | | /// <param name="toTimeUnits5">The desired units of the measurement.</param> |
| | 7412 | | /// <returns>The Energy measurement converted into the desired units.</returns> |
| | 7413 | | public static T Convert(T value |
| | 7414 | | , Mass.Units fromMassUnits1 |
| | 7415 | | , Length.Units fromLengthUnits2 |
| | 7416 | | , Length.Units fromLengthUnits3 |
| | 7417 | | , Time.Units fromTimeUnits4 |
| | 7418 | | , Time.Units fromTimeUnits5 |
| | 7419 | | , Mass.Units toMassUnits1 |
| | 7420 | | , Length.Units toLengthUnits2 |
| | 7421 | | , Length.Units toLengthUnits3 |
| | 7422 | | , Time.Units toTimeUnits4 |
| | 7423 | | , Time.Units toTimeUnits5 |
| | 7424 | | ) |
| | 7425 | | { |
| | 7426 | | Energy<T> measurement = new Energy<T>(value |
| | 7427 | | , fromMassUnits1 |
| | 7428 | | , fromLengthUnits2 |
| | 7429 | | , fromLengthUnits3 |
| | 7430 | | , fromTimeUnits4 |
| | 7431 | | , fromTimeUnits5 |
| | 7432 | | ); |
| | 7433 | | return measurement[ |
| | 7434 | | toMassUnits1 |
| | 7435 | | , toLengthUnits2 |
| | 7436 | | , toLengthUnits3 |
| | 7437 | | , toTimeUnits4 |
| | 7438 | | , toTimeUnits5 |
| | 7439 | | ]; |
| | 7440 | | } |
| | 7441 | |
|
| | 7442 | | /// <summary>Converts a Energy measurement from units to another.</summary> |
| | 7443 | | /// <param name="value">The value to convert the units of.</param> |
| | 7444 | | /// <param name="from">The current units of the measurement.</param> |
| | 7445 | | /// <param name="to">The desired units of the measurement.</param> |
| | 7446 | | /// <returns>The Energy measurement converted into the desired units.</returns> |
| | 7447 | | public static T Convert(T value, |
| | 7448 | | MeasurementUnitsSyntaxTypes.EnergyBaseUnits from, |
| | 7449 | | MeasurementUnitsSyntaxTypes.EnergyBaseUnits to) |
| | 7450 | | { |
| | 7451 | | return Convert(value |
| | 7452 | | , from._MassUnits1 |
| | 7453 | | , from._LengthUnits2 |
| | 7454 | | , from._LengthUnits3 |
| | 7455 | | , from._TimeUnits4 |
| | 7456 | | , from._TimeUnits5 |
| | 7457 | | , to._MassUnits1 |
| | 7458 | | , to._LengthUnits2 |
| | 7459 | | , to._LengthUnits3 |
| | 7460 | | , to._TimeUnits4 |
| | 7461 | | , to._TimeUnits5 |
| | 7462 | | ); |
| | 7463 | | } |
| | 7464 | |
|
| | 7465 | | /// <summary>Parses a Energy measurement string.</summary> |
| | 7466 | | /// <param name="string">The string to be parsed.</param> |
| | 7467 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 7468 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 7469 | | public static (bool Success, Energy<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value)> tryPar |
| | 7470 | |
|
| | 7471 | | #endregion |
| | 7472 | |
|
| | 7473 | | #region Constructors |
| | 7474 | |
|
| | 7475 | | /// <summary>Constructs an Energy with the measurement value and units.</summary> |
| | 7476 | | /// <param name="measurement">The measurement value of the Energy.</param> |
| | 7477 | | /// <param name="units">The units of the Energy.</param> |
| | 7478 | | public Energy(T measurement, MeasurementUnitsSyntaxTypes.EnergyBaseUnits units) : this(measurement |
| | 7479 | | , units._MassUnits1 |
| | 7480 | | , units._LengthUnits2 |
| | 7481 | | , units._LengthUnits3 |
| | 7482 | | , units._TimeUnits4 |
| | 7483 | | , units._TimeUnits5 |
| | 7484 | | ) { } |
| | 7485 | |
|
| | 7486 | |
|
| | 7487 | | /// <summary>Constructs an Energy with the measurement value and units.</summary> |
| | 7488 | | /// <param name="measurement">The measurement value of the Energy.</param> |
| | 7489 | | /// <param name="MassUnits1">The units of the Energy.</param> |
| | 7490 | | /// <param name="LengthUnits2">The units of the Energy.</param> |
| | 7491 | | /// <param name="LengthUnits3">The units of the Energy.</param> |
| | 7492 | | /// <param name="TimeUnits4">The units of the Energy.</param> |
| | 7493 | | /// <param name="TimeUnits5">The units of the Energy.</param> |
| | 7494 | | public Energy(T measurement |
| | 7495 | | , Mass.Units MassUnits1 |
| | 7496 | | , Length.Units LengthUnits2 |
| | 7497 | | , Length.Units LengthUnits3 |
| | 7498 | | , Time.Units TimeUnits4 |
| | 7499 | | , Time.Units TimeUnits5 |
| | 7500 | | ) |
| | 7501 | | { |
| | 7502 | | _measurement = measurement; |
| | 7503 | | _MassUnits1 = MassUnits1; |
| | 7504 | | _LengthUnits2 = LengthUnits2; |
| | 7505 | | _LengthUnits3 = LengthUnits3; |
| | 7506 | | _TimeUnits4 = TimeUnits4; |
| | 7507 | | _TimeUnits5 = TimeUnits5; |
| | 7508 | | } |
| | 7509 | |
|
| | 7510 | | #endregion |
| | 7511 | |
|
| | 7512 | | #region Properties |
| | 7513 | |
|
| | 7514 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 7515 | | public Mass.Units MassUnits1 |
| | 7516 | | { |
| | 7517 | | get { return _MassUnits1; } |
| | 7518 | | set |
| | 7519 | | { |
| | 7520 | | if (value != _MassUnits1) |
| | 7521 | | { |
| | 7522 | | _measurement = this[value, _LengthUnits2, _LengthUnits3, _TimeUnits4, _TimeUnits5]; |
| | 7523 | | _MassUnits1 = value; |
| | 7524 | | } |
| | 7525 | | } |
| | 7526 | | } |
| | 7527 | |
|
| | 7528 | | /// <summary>The #2 component of this measurements units.</summary> |
| | 7529 | | public Length.Units LengthUnits2 |
| | 7530 | | { |
| | 7531 | | get { return _LengthUnits2; } |
| | 7532 | | set |
| | 7533 | | { |
| | 7534 | | if (value != _LengthUnits2) |
| | 7535 | | { |
| | 7536 | | _measurement = this[_MassUnits1, value, _LengthUnits3, _TimeUnits4, _TimeUnits5]; |
| | 7537 | | _LengthUnits2 = value; |
| | 7538 | | } |
| | 7539 | | } |
| | 7540 | | } |
| | 7541 | |
|
| | 7542 | | /// <summary>The #3 component of this measurements units.</summary> |
| | 7543 | | public Length.Units LengthUnits3 |
| | 7544 | | { |
| | 7545 | | get { return _LengthUnits3; } |
| | 7546 | | set |
| | 7547 | | { |
| | 7548 | | if (value != _LengthUnits3) |
| | 7549 | | { |
| | 7550 | | _measurement = this[_MassUnits1, _LengthUnits2, value, _TimeUnits4, _TimeUnits5]; |
| | 7551 | | _LengthUnits3 = value; |
| | 7552 | | } |
| | 7553 | | } |
| | 7554 | | } |
| | 7555 | |
|
| | 7556 | | /// <summary>The #4 component of this measurements units.</summary> |
| | 7557 | | public Time.Units TimeUnits4 |
| | 7558 | | { |
| | 7559 | | get { return _TimeUnits4; } |
| | 7560 | | set |
| | 7561 | | { |
| | 7562 | | if (value != _TimeUnits4) |
| | 7563 | | { |
| | 7564 | | _measurement = this[_MassUnits1, _LengthUnits2, _LengthUnits3, value, _TimeUnits5]; |
| | 7565 | | _TimeUnits4 = value; |
| | 7566 | | } |
| | 7567 | | } |
| | 7568 | | } |
| | 7569 | |
|
| | 7570 | | /// <summary>The #5 component of this measurements units.</summary> |
| | 7571 | | public Time.Units TimeUnits5 |
| | 7572 | | { |
| | 7573 | | get { return _TimeUnits5; } |
| | 7574 | | set |
| | 7575 | | { |
| | 7576 | | if (value != _TimeUnits5) |
| | 7577 | | { |
| | 7578 | | _measurement = this[_MassUnits1, _LengthUnits2, _LengthUnits3, _TimeUnits4, value]; |
| | 7579 | | _TimeUnits5 = value; |
| | 7580 | | } |
| | 7581 | | } |
| | 7582 | | } |
| | 7583 | |
|
| | 7584 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 7585 | | /// <param name="units">The units to get the measurement in.</param> |
| | 7586 | | /// <returns>The measurement value in the specified units.</returns> |
| | 7587 | | public T this[MeasurementUnitsSyntaxTypes.EnergyBaseUnits units] |
| | 7588 | | { |
| | 7589 | | get { return this[units._MassUnits1, units._LengthUnits2, units._LengthUnits3, units._TimeUnits4, units._TimeUnits |
| | 7590 | | } |
| | 7591 | |
|
| | 7592 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 7593 | | /// <param name="MassUnits1">The #1 component of this measurements units.</param> |
| | 7594 | | /// <param name="LengthUnits2">The #2 component of this measurements units.</param> |
| | 7595 | | /// <param name="LengthUnits3">The #3 component of this measurements units.</param> |
| | 7596 | | /// <param name="TimeUnits4">The #4 component of this measurements units.</param> |
| | 7597 | | /// <param name="TimeUnits5">The #5 component of this measurements units.</param> |
| | 7598 | | /// <returns>The measurement value in the specified units.</returns> |
| | 7599 | | public T this[Mass.Units MassUnits1, Length.Units LengthUnits2, Length.Units LengthUnits3, Time.Units TimeUnits4, Ti |
| | 7600 | | { |
| | 7601 | | get |
| | 7602 | | { |
| | 7603 | | T measurement = _measurement; |
| | 7604 | | if (MassUnits1 != _MassUnits1) |
| | 7605 | | { |
| | 7606 | | measurement = Mass<T>.Table[(int)_MassUnits1][(int)MassUnits1](measurement); |
| | 7607 | | //if (MassUnits1 < _MassUnits1) |
| | 7608 | | //{ |
| | 7609 | | // measurement = Mass<T>.Table[(int)_MassUnits1][(int)MassUnits1](measurement); |
| | 7610 | | //} |
| | 7611 | | //else |
| | 7612 | | //{ |
| | 7613 | | // measurement = Mass<T>.Table[(int)MassUnits1][(int)_MassUnits1](measurement); |
| | 7614 | | //} |
| | 7615 | | } |
| | 7616 | | if (LengthUnits2 != _LengthUnits2) |
| | 7617 | | { |
| | 7618 | | measurement = Length<T>.Table[(int)_LengthUnits2][(int)LengthUnits2](measurement); |
| | 7619 | | //if (LengthUnits2 < _LengthUnits2) |
| | 7620 | | //{ |
| | 7621 | | // measurement = Length<T>.Table[(int)_LengthUnits2][(int)LengthUnits2](measurement); |
| | 7622 | | //} |
| | 7623 | | //else |
| | 7624 | | //{ |
| | 7625 | | // measurement = Length<T>.Table[(int)LengthUnits2][(int)_LengthUnits2](measurement); |
| | 7626 | | //} |
| | 7627 | | } |
| | 7628 | | if (LengthUnits3 != _LengthUnits3) |
| | 7629 | | { |
| | 7630 | | measurement = Length<T>.Table[(int)_LengthUnits3][(int)LengthUnits3](measurement); |
| | 7631 | | //if (LengthUnits3 < _LengthUnits3) |
| | 7632 | | //{ |
| | 7633 | | // measurement = Length<T>.Table[(int)_LengthUnits3][(int)LengthUnits3](measurement); |
| | 7634 | | //} |
| | 7635 | | //else |
| | 7636 | | //{ |
| | 7637 | | // measurement = Length<T>.Table[(int)LengthUnits3][(int)_LengthUnits3](measurement); |
| | 7638 | | //} |
| | 7639 | | } |
| | 7640 | | if (TimeUnits4 != _TimeUnits4) |
| | 7641 | | { |
| | 7642 | | measurement = Time<T>.Table[(int)TimeUnits4][(int)_TimeUnits4](measurement); |
| | 7643 | | //if (TimeUnits4 > _TimeUnits4) |
| | 7644 | | //{ |
| | 7645 | | // measurement = Time<T>.Table[(int)_TimeUnits4][(int)TimeUnits4](measurement); |
| | 7646 | | //} |
| | 7647 | | //else |
| | 7648 | | //{ |
| | 7649 | | // measurement = Time<T>.Table[(int)TimeUnits4][(int)_TimeUnits4](measurement); |
| | 7650 | | //} |
| | 7651 | | } |
| | 7652 | | if (TimeUnits5 != _TimeUnits5) |
| | 7653 | | { |
| | 7654 | | measurement = Time<T>.Table[(int)TimeUnits5][(int)_TimeUnits5](measurement); |
| | 7655 | | //if (TimeUnits5 > _TimeUnits5) |
| | 7656 | | //{ |
| | 7657 | | // measurement = Time<T>.Table[(int)_TimeUnits5][(int)TimeUnits5](measurement); |
| | 7658 | | //} |
| | 7659 | | //else |
| | 7660 | | //{ |
| | 7661 | | // measurement = Time<T>.Table[(int)TimeUnits5][(int)_TimeUnits5](measurement); |
| | 7662 | | //} |
| | 7663 | | } |
| | 7664 | | return measurement; |
| | 7665 | | } |
| | 7666 | | } |
| | 7667 | |
|
| | 7668 | | #endregion |
| | 7669 | |
|
| | 7670 | | #region Casting Operators |
| | 7671 | |
|
| | 7672 | | /// <summary>Converts a ValueTuple to a Energy measurement.</summary> |
| | 7673 | | /// <param name="valueTuple">The ValueTuple to converted into a Energy measurement.</param> |
| | 7674 | | public static implicit operator Energy<T>((T, MeasurementUnitsSyntaxTypes.EnergyBaseUnits) valueTuple) |
| | 7675 | | { |
| | 7676 | | return new Energy<T>(valueTuple.Item1, valueTuple.Item2); |
| | 7677 | | } |
| | 7678 | |
|
| | 7679 | | #endregion |
| | 7680 | |
|
| | 7681 | | #region Mathematics |
| | 7682 | |
|
| | 7683 | | #region Bases |
| | 7684 | |
|
| | 7685 | | internal static Energy<T> MathBase(Energy<T> a, T b, Func<T, T, T> func) |
| | 7686 | | { |
| | 7687 | | return new Energy<T>(func(a._measurement, b) |
| | 7688 | | , a._MassUnits1 |
| | 7689 | | , a._LengthUnits2 |
| | 7690 | | , a._LengthUnits3 |
| | 7691 | | , a._TimeUnits4 |
| | 7692 | | , a._TimeUnits5 |
| | 7693 | | ); |
| | 7694 | | } |
| | 7695 | |
|
| | 7696 | | internal static Energy<T> MathBase(Energy<T> a, Energy<T> b, Func<T, T, T> func) |
| | 7697 | | { |
| | 7698 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 7699 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 7700 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits3 ? a._LengthUnits3 : b._LengthUnits3; |
| | 7701 | | Time.Units TimeUnits4 = a._TimeUnits4 <= b._TimeUnits4 ? a._TimeUnits4 : b._TimeUnits4; |
| | 7702 | | Time.Units TimeUnits5 = a._TimeUnits5 <= b._TimeUnits5 ? a._TimeUnits5 : b._TimeUnits5; |
| | 7703 | | T A = a[MassUnits1, LengthUnits2, LengthUnits3, TimeUnits4, TimeUnits5]; |
| | 7704 | | T B = b[MassUnits1, LengthUnits2, LengthUnits3, TimeUnits4, TimeUnits5]; |
| | 7705 | | T C = func(A, B); |
| | 7706 | | return new Energy<T>(C, MassUnits1, LengthUnits2, LengthUnits3, TimeUnits4, TimeUnits5); |
| | 7707 | | } |
| | 7708 | |
|
| | 7709 | | internal static bool LogicBase(Energy<T> a, Energy<T> b, Func<T, T, bool> func) |
| | 7710 | | { |
| | 7711 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 7712 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 7713 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits3 ? a._LengthUnits3 : b._LengthUnits3; |
| | 7714 | | Time.Units TimeUnits4 = a._TimeUnits4 <= b._TimeUnits4 ? a._TimeUnits4 : b._TimeUnits4; |
| | 7715 | | Time.Units TimeUnits5 = a._TimeUnits5 <= b._TimeUnits5 ? a._TimeUnits5 : b._TimeUnits5; |
| | 7716 | | T A = a[MassUnits1, LengthUnits2, LengthUnits3, TimeUnits4, TimeUnits5]; |
| | 7717 | | T B = b[MassUnits1, LengthUnits2, LengthUnits3, TimeUnits4, TimeUnits5]; |
| | 7718 | | return func(A, B); |
| | 7719 | | } |
| | 7720 | |
|
| | 7721 | | #endregion |
| | 7722 | |
|
| | 7723 | | #region Add |
| | 7724 | |
|
| | 7725 | | /// <summary>Adds two Energy measurements.</summary> |
| | 7726 | | /// <param name="a">The first operand of the addition.</param> |
| | 7727 | | /// <param name="b">The second operand of the addition.</param> |
| | 7728 | | /// <returns>The result of the addition operation.</returns> |
| | 7729 | | public static Energy<T> Add(Energy<T> a, Energy<T> b) |
| | 7730 | | { |
| | 7731 | | return MathBase(a, b, Statics.Addition); |
| | 7732 | | } |
| | 7733 | |
|
| | 7734 | | /// <summary>Adds two Energy measurements.</summary> |
| | 7735 | | /// <param name="a">The first operand of the addition.</param> |
| | 7736 | | /// <param name="b">The second operand of the addition.</param> |
| | 7737 | | /// <returns>The result of the addition operation.</returns> |
| | 7738 | | public static Energy<T> operator +(Energy<T> a, Energy<T> b) |
| | 7739 | | { |
| | 7740 | | return Add(a, b); |
| | 7741 | | } |
| | 7742 | |
|
| | 7743 | | /// <summary>Adds two Energy measurements.</summary> |
| | 7744 | | /// <param name="b">The second operand of the addition.</param> |
| | 7745 | | /// <returns>The result of the addition operation.</returns> |
| | 7746 | | public Energy<T> Add(Energy<T> b) |
| | 7747 | | { |
| | 7748 | | return this + b; |
| | 7749 | | } |
| | 7750 | |
|
| | 7751 | | #endregion |
| | 7752 | |
|
| | 7753 | | #region Subtract |
| | 7754 | |
|
| | 7755 | | /// <summary>Subtracts two Energy measurements.</summary> |
| | 7756 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 7757 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 7758 | | /// <returns>The result of the subtraction.</returns> |
| | 7759 | | public static Energy<T> Subtract(Energy<T> a, Energy<T> b) |
| | 7760 | | { |
| | 7761 | | return MathBase(a, b, Statics.Subtraction); |
| | 7762 | | } |
| | 7763 | |
|
| | 7764 | | /// <summary>Subtracts two Energy measurements.</summary> |
| | 7765 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 7766 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 7767 | | /// <returns>The result of the subtraction.</returns> |
| | 7768 | | public static Energy<T> operator -(Energy<T> a, Energy<T> b) |
| | 7769 | | { |
| | 7770 | | return Subtract(a, b); |
| | 7771 | | } |
| | 7772 | |
|
| | 7773 | | /// <summary>Subtracts two Energy measurements.</summary> |
| | 7774 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 7775 | | /// <returns>The result of the subtraction.</returns> |
| | 7776 | | public Energy<T> Subtract(Energy<T> b) |
| | 7777 | | { |
| | 7778 | | return this - b; |
| | 7779 | | } |
| | 7780 | |
|
| | 7781 | | #endregion |
| | 7782 | |
|
| | 7783 | | #region Multiply |
| | 7784 | |
|
| | 7785 | | /// <summary>Multiplies an Energy by a scalar numeric value.</summary> |
| | 7786 | | /// <param name="a">The Energy measurement to multiply.</param> |
| | 7787 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 7788 | | /// <returns>The result of the multiplication.</returns> |
| | 7789 | | public static Energy<T> Multiply(Energy<T> a, T b) |
| | 7790 | | { |
| | 7791 | | return MathBase(a, b, Statics.Multiplication); |
| | 7792 | | } |
| | 7793 | |
|
| | 7794 | | /// <summary>Multiplies an Energy by a scalar numeric value.</summary> |
| | 7795 | | /// <param name="a">The Energy measurement to multiply.</param> |
| | 7796 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 7797 | | /// <returns>The result of the multiplication.</returns> |
| | 7798 | | public static Energy<T> Multiply(T b, Energy<T> a) |
| | 7799 | | { |
| | 7800 | | return Multiply(a, b); |
| | 7801 | | } |
| | 7802 | |
|
| | 7803 | | /// <summary>Multiplies an Energy by a scalar numeric value.</summary> |
| | 7804 | | /// <param name="a">The Energy measurement to multiply.</param> |
| | 7805 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 7806 | | /// <returns>The result of the multiplication.</returns> |
| | 7807 | | public static Energy<T> operator *(Energy<T> a, T b) |
| | 7808 | | { |
| | 7809 | | return Multiply(a, b); |
| | 7810 | | } |
| | 7811 | |
|
| | 7812 | | /// <summary>Multiplies an Energy by a scalar numeric value.</summary> |
| | 7813 | | /// <param name="a">The Energy measurement to multiply.</param> |
| | 7814 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 7815 | | /// <returns>The result of the multiplication.</returns> |
| | 7816 | | public static Energy<T> operator *(T b, Energy<T> a) |
| | 7817 | | { |
| | 7818 | | return Multiply(b, a); |
| | 7819 | | } |
| | 7820 | |
|
| | 7821 | | /// <summary>Multiplies an Energy by a scalar numeric value.</summary> |
| | 7822 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 7823 | | /// <returns>The result of the multiplication.</returns> |
| | 7824 | | public Energy<T> Add(T b) |
| | 7825 | | { |
| | 7826 | | return this * b; |
| | 7827 | | } |
| | 7828 | |
|
| | 7829 | | #endregion |
| | 7830 | |
|
| | 7831 | | #region Divide |
| | 7832 | |
|
| | 7833 | | /// <summary>Divides an Energy measurement by another Energy measurement resulting in a scalar numeric value.</summa |
| | 7834 | | /// <param name="a">The first operand of the division operation.</param> |
| | 7835 | | /// <param name="b">The second operand of the division operation.</param> |
| | 7836 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 7837 | | public static T Divide(Energy<T> a, Energy<T> b) |
| | 7838 | | { |
| | 7839 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 7840 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 7841 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits3 ? a._LengthUnits3 : b._LengthUnits3; |
| | 7842 | | Time.Units TimeUnits4 = a._TimeUnits4 <= b._TimeUnits4 ? a._TimeUnits4 : b._TimeUnits4; |
| | 7843 | | Time.Units TimeUnits5 = a._TimeUnits5 <= b._TimeUnits5 ? a._TimeUnits5 : b._TimeUnits5; |
| | 7844 | | T A = a[MassUnits1, LengthUnits2, LengthUnits3, TimeUnits4, TimeUnits5]; |
| | 7845 | | T B = b[MassUnits1, LengthUnits2, LengthUnits3, TimeUnits4, TimeUnits5]; |
| | 7846 | | return Statics.Division(A, B); |
| | 7847 | | } |
| | 7848 | |
|
| | 7849 | | /// <summary>Divides this Energy measurement by a numaric scalar value.</summary> |
| | 7850 | | /// <param name="a">The Energy measurement to divide.</param> |
| | 7851 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 7852 | | /// <returns>The result of the division.</returns> |
| | 7853 | | public static Energy<T> Divide(Energy<T> a, T b) |
| | 7854 | | { |
| | 7855 | | return MathBase(a, b, Statics.Division); |
| | 7856 | | } |
| | 7857 | |
|
| | 7858 | | /// <summary>Divides this Energy measurement by a numaric scalar value.</summary> |
| | 7859 | | /// <param name="a">The Energy measurement to divide.</param> |
| | 7860 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 7861 | | /// <returns>The result of the division.</returns> |
| | 7862 | | public static Energy<T> operator /(Energy<T> a, T b) |
| | 7863 | | { |
| | 7864 | | return Divide(a, b); |
| | 7865 | | } |
| | 7866 | |
|
| | 7867 | | /// <summary>Divides this Energy measurement by a numaric scalar value.</summary> |
| | 7868 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 7869 | | /// <returns>The result of the division.</returns> |
| | 7870 | | public Energy<T> Divide(T b) |
| | 7871 | | { |
| | 7872 | | return this / b; |
| | 7873 | | } |
| | 7874 | |
|
| | 7875 | | /// <summary>Divides an Energy measurement by another Energy measurement resulting in a scalar numeric value.</summa |
| | 7876 | | /// <param name="a">The first operand of the division operation.</param> |
| | 7877 | | /// <param name="b">The second operand of the division operation.</param> |
| | 7878 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 7879 | | public static T operator /(Energy<T> a, Energy<T> b) |
| | 7880 | | { |
| | 7881 | | return Divide(a, b); |
| | 7882 | | } |
| | 7883 | |
|
| | 7884 | | /// <summary>Divides an Energy measurement by another Energy measurement resulting in a scalar numeric value.</summa |
| | 7885 | | /// <param name="b">The second operand of the division operation.</param> |
| | 7886 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 7887 | | public T Divide(Energy<T> b) |
| | 7888 | | { |
| | 7889 | | return this / b; |
| | 7890 | | } |
| | 7891 | |
|
| | 7892 | |
|
| | 7893 | | #region Energy<T> / Acceleration<T> = LinearMass<T> |
| | 7894 | |
|
| | 7895 | | /// <summary>Divides Energy by Acceleration resulting in LinearMass.</summary> |
| | 7896 | | /// <param name="a">The Energy to be divided.</param> |
| | 7897 | | /// <param name="b">The Acceleration to divide by.</param> |
| | 7898 | | /// <returns>The LinearMass result of the division.</returns> |
| | 7899 | | public static LinearMass<T> Divide(Energy<T> a, Acceleration<T> b) |
| | 7900 | | { |
| | 7901 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 7902 | | Time.Units TimeUnits2 = a._TimeUnits4 <= b._TimeUnits2 ? a._TimeUnits4 : b._TimeUnits2; |
| | 7903 | | Time.Units TimeUnits3 = a._TimeUnits5 <= b._TimeUnits3 ? a._TimeUnits5 : b._TimeUnits3; |
| | 7904 | |
|
| | 7905 | | T A = a[a._MassUnits1, LengthUnits1, a._LengthUnits3, TimeUnits2, TimeUnits3]; |
| | 7906 | | T B = b[LengthUnits1, TimeUnits2, TimeUnits3]; |
| | 7907 | | T C = Statics.Division(A, B); |
| | 7908 | |
|
| | 7909 | | return new LinearMass<T>(C |
| | 7910 | | , a._MassUnits1 |
| | 7911 | | , a._LengthUnits3 |
| | 7912 | | ); |
| | 7913 | | } |
| | 7914 | |
|
| | 7915 | | /// <summary>Divides Energy by Acceleration resulting in LinearMass.</summary> |
| | 7916 | | /// <param name="a">The Energy to be divided.</param> |
| | 7917 | | /// <param name="b">The Acceleration to divide by.</param> |
| | 7918 | | /// <returns>The LinearMass result of the division.</returns> |
| | 7919 | | public static LinearMass<T> operator /(Energy<T> a, Acceleration<T> b) |
| | 7920 | | { |
| | 7921 | | return Divide(a, b); |
| | 7922 | | } |
| | 7923 | |
|
| | 7924 | | /// <summary>Divides Energy by Acceleration resulting in LinearMass.</summary> |
| | 7925 | | /// <param name="b">The Acceleration to divide by.</param> |
| | 7926 | | /// <returns>The LinearMass result of the division.</returns> |
| | 7927 | | public LinearMass<T> Divide(Acceleration<T> b) |
| | 7928 | | { |
| | 7929 | | return this / b; |
| | 7930 | | } |
| | 7931 | |
|
| | 7932 | | #endregion |
| | 7933 | |
|
| | 7934 | |
|
| | 7935 | | #region Energy<T> / Force<T> = Length<T> |
| | 7936 | |
|
| | 7937 | | /// <summary>Divides Energy by Force resulting in Length.</summary> |
| | 7938 | | /// <param name="a">The Energy to be divided.</param> |
| | 7939 | | /// <param name="b">The Force to divide by.</param> |
| | 7940 | | /// <returns>The Length result of the division.</returns> |
| | 7941 | | public static Length<T> Divide(Energy<T> a, Force<T> b) |
| | 7942 | | { |
| | 7943 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 7944 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 7945 | | Time.Units TimeUnits3 = a._TimeUnits4 <= b._TimeUnits3 ? a._TimeUnits4 : b._TimeUnits3; |
| | 7946 | | Time.Units TimeUnits4 = a._TimeUnits5 <= b._TimeUnits4 ? a._TimeUnits5 : b._TimeUnits4; |
| | 7947 | |
|
| | 7948 | | T A = a[MassUnits1, LengthUnits2, a._LengthUnits3, TimeUnits3, TimeUnits4]; |
| | 7949 | | T B = b[MassUnits1, LengthUnits2, TimeUnits3, TimeUnits4]; |
| | 7950 | | T C = Statics.Division(A, B); |
| | 7951 | |
|
| | 7952 | | return new Length<T>(C |
| | 7953 | | , a._LengthUnits3 |
| | 7954 | | ); |
| | 7955 | | } |
| | 7956 | |
|
| | 7957 | | /// <summary>Divides Energy by Force resulting in Length.</summary> |
| | 7958 | | /// <param name="a">The Energy to be divided.</param> |
| | 7959 | | /// <param name="b">The Force to divide by.</param> |
| | 7960 | | /// <returns>The Length result of the division.</returns> |
| | 7961 | | public static Length<T> operator /(Energy<T> a, Force<T> b) |
| | 7962 | | { |
| | 7963 | | return Divide(a, b); |
| | 7964 | | } |
| | 7965 | |
|
| | 7966 | | /// <summary>Divides Energy by Force resulting in Length.</summary> |
| | 7967 | | /// <param name="b">The Force to divide by.</param> |
| | 7968 | | /// <returns>The Length result of the division.</returns> |
| | 7969 | | public Length<T> Divide(Force<T> b) |
| | 7970 | | { |
| | 7971 | | return this / b; |
| | 7972 | | } |
| | 7973 | |
|
| | 7974 | | #endregion |
| | 7975 | |
|
| | 7976 | |
|
| | 7977 | | #region Energy<T> / Length<T> = Force<T> |
| | 7978 | |
|
| | 7979 | | /// <summary>Divides Energy by Length resulting in Force.</summary> |
| | 7980 | | /// <param name="a">The Energy to be divided.</param> |
| | 7981 | | /// <param name="b">The Length to divide by.</param> |
| | 7982 | | /// <returns>The Force result of the division.</returns> |
| | 7983 | | public static Force<T> Divide(Energy<T> a, Length<T> b) |
| | 7984 | | { |
| | 7985 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 7986 | |
|
| | 7987 | | T A = a[a._MassUnits1, LengthUnits1, a._LengthUnits3, a._TimeUnits4, a._TimeUnits5]; |
| | 7988 | | T B = b[LengthUnits1]; |
| | 7989 | | T C = Statics.Division(A, B); |
| | 7990 | |
|
| | 7991 | | return new Force<T>(C |
| | 7992 | | , a._MassUnits1 |
| | 7993 | | , a._LengthUnits3 |
| | 7994 | | , a._TimeUnits4 |
| | 7995 | | , a._TimeUnits5 |
| | 7996 | | ); |
| | 7997 | | } |
| | 7998 | |
|
| | 7999 | | /// <summary>Divides Energy by Length resulting in Force.</summary> |
| | 8000 | | /// <param name="a">The Energy to be divided.</param> |
| | 8001 | | /// <param name="b">The Length to divide by.</param> |
| | 8002 | | /// <returns>The Force result of the division.</returns> |
| | 8003 | | public static Force<T> operator /(Energy<T> a, Length<T> b) |
| | 8004 | | { |
| | 8005 | | return Divide(a, b); |
| | 8006 | | } |
| | 8007 | |
|
| | 8008 | | /// <summary>Divides Energy by Length resulting in Force.</summary> |
| | 8009 | | /// <param name="b">The Length to divide by.</param> |
| | 8010 | | /// <returns>The Force result of the division.</returns> |
| | 8011 | | public Force<T> Divide(Length<T> b) |
| | 8012 | | { |
| | 8013 | | return this / b; |
| | 8014 | | } |
| | 8015 | |
|
| | 8016 | | #endregion |
| | 8017 | |
|
| | 8018 | |
|
| | 8019 | | #region Energy<T> / LinearMass<T> = Acceleration<T> |
| | 8020 | |
|
| | 8021 | | /// <summary>Divides Energy by LinearMass resulting in Acceleration.</summary> |
| | 8022 | | /// <param name="a">The Energy to be divided.</param> |
| | 8023 | | /// <param name="b">The LinearMass to divide by.</param> |
| | 8024 | | /// <returns>The Acceleration result of the division.</returns> |
| | 8025 | | public static Acceleration<T> Divide(Energy<T> a, LinearMass<T> b) |
| | 8026 | | { |
| | 8027 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 8028 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 8029 | |
|
| | 8030 | | T A = a[MassUnits1, LengthUnits2, a._LengthUnits3, a._TimeUnits4, a._TimeUnits5]; |
| | 8031 | | T B = b[MassUnits1, LengthUnits2]; |
| | 8032 | | T C = Statics.Division(A, B); |
| | 8033 | |
|
| | 8034 | | return new Acceleration<T>(C |
| | 8035 | | , a._LengthUnits3 |
| | 8036 | | , a._TimeUnits4 |
| | 8037 | | , a._TimeUnits5 |
| | 8038 | | ); |
| | 8039 | | } |
| | 8040 | |
|
| | 8041 | | /// <summary>Divides Energy by LinearMass resulting in Acceleration.</summary> |
| | 8042 | | /// <param name="a">The Energy to be divided.</param> |
| | 8043 | | /// <param name="b">The LinearMass to divide by.</param> |
| | 8044 | | /// <returns>The Acceleration result of the division.</returns> |
| | 8045 | | public static Acceleration<T> operator /(Energy<T> a, LinearMass<T> b) |
| | 8046 | | { |
| | 8047 | | return Divide(a, b); |
| | 8048 | | } |
| | 8049 | |
|
| | 8050 | | /// <summary>Divides Energy by LinearMass resulting in Acceleration.</summary> |
| | 8051 | | /// <param name="b">The LinearMass to divide by.</param> |
| | 8052 | | /// <returns>The Acceleration result of the division.</returns> |
| | 8053 | | public Acceleration<T> Divide(LinearMass<T> b) |
| | 8054 | | { |
| | 8055 | | return this / b; |
| | 8056 | | } |
| | 8057 | |
|
| | 8058 | | #endregion |
| | 8059 | |
|
| | 8060 | |
|
| | 8061 | | #region Energy<T> / LinearMassFlow<T> = Speed<T> |
| | 8062 | |
|
| | 8063 | | /// <summary>Divides Energy by LinearMassFlow resulting in Speed.</summary> |
| | 8064 | | /// <param name="a">The Energy to be divided.</param> |
| | 8065 | | /// <param name="b">The LinearMassFlow to divide by.</param> |
| | 8066 | | /// <returns>The Speed result of the division.</returns> |
| | 8067 | | public static Speed<T> Divide(Energy<T> a, LinearMassFlow<T> b) |
| | 8068 | | { |
| | 8069 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 8070 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 8071 | | Time.Units TimeUnits3 = a._TimeUnits4 <= b._TimeUnits3 ? a._TimeUnits4 : b._TimeUnits3; |
| | 8072 | |
|
| | 8073 | | T A = a[MassUnits1, LengthUnits2, a._LengthUnits3, TimeUnits3, a._TimeUnits5]; |
| | 8074 | | T B = b[MassUnits1, LengthUnits2, TimeUnits3]; |
| | 8075 | | T C = Statics.Division(A, B); |
| | 8076 | |
|
| | 8077 | | return new Speed<T>(C |
| | 8078 | | , a._LengthUnits3 |
| | 8079 | | , a._TimeUnits5 |
| | 8080 | | ); |
| | 8081 | | } |
| | 8082 | |
|
| | 8083 | | /// <summary>Divides Energy by LinearMassFlow resulting in Speed.</summary> |
| | 8084 | | /// <param name="a">The Energy to be divided.</param> |
| | 8085 | | /// <param name="b">The LinearMassFlow to divide by.</param> |
| | 8086 | | /// <returns>The Speed result of the division.</returns> |
| | 8087 | | public static Speed<T> operator /(Energy<T> a, LinearMassFlow<T> b) |
| | 8088 | | { |
| | 8089 | | return Divide(a, b); |
| | 8090 | | } |
| | 8091 | |
|
| | 8092 | | /// <summary>Divides Energy by LinearMassFlow resulting in Speed.</summary> |
| | 8093 | | /// <param name="b">The LinearMassFlow to divide by.</param> |
| | 8094 | | /// <returns>The Speed result of the division.</returns> |
| | 8095 | | public Speed<T> Divide(LinearMassFlow<T> b) |
| | 8096 | | { |
| | 8097 | | return this / b; |
| | 8098 | | } |
| | 8099 | |
|
| | 8100 | | #endregion |
| | 8101 | |
|
| | 8102 | |
|
| | 8103 | | #region Energy<T> / Power<T> = Time<T> |
| | 8104 | |
|
| | 8105 | | /// <summary>Divides Energy by Power resulting in Time.</summary> |
| | 8106 | | /// <param name="a">The Energy to be divided.</param> |
| | 8107 | | /// <param name="b">The Power to divide by.</param> |
| | 8108 | | /// <returns>The Time result of the division.</returns> |
| | 8109 | | public static Time<T> Divide(Energy<T> a, Power<T> b) |
| | 8110 | | { |
| | 8111 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 8112 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 8113 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits3 ? a._LengthUnits3 : b._LengthUnits3; |
| | 8114 | | Time.Units TimeUnits4 = a._TimeUnits4 <= b._TimeUnits4 ? a._TimeUnits4 : b._TimeUnits4; |
| | 8115 | | Time.Units TimeUnits5 = a._TimeUnits5 <= b._TimeUnits5 ? a._TimeUnits5 : b._TimeUnits5; |
| | 8116 | |
|
| | 8117 | | T A = a[MassUnits1, LengthUnits2, LengthUnits3, TimeUnits4, TimeUnits5]; |
| | 8118 | | T B = b[MassUnits1, LengthUnits2, LengthUnits3, TimeUnits4, TimeUnits5, b._TimeUnits6]; |
| | 8119 | | T C = Statics.Division(A, B); |
| | 8120 | |
|
| | 8121 | | return new Time<T>(C |
| | 8122 | | , b._TimeUnits6 |
| | 8123 | | ); |
| | 8124 | | } |
| | 8125 | |
|
| | 8126 | | /// <summary>Divides Energy by Power resulting in Time.</summary> |
| | 8127 | | /// <param name="a">The Energy to be divided.</param> |
| | 8128 | | /// <param name="b">The Power to divide by.</param> |
| | 8129 | | /// <returns>The Time result of the division.</returns> |
| | 8130 | | public static Time<T> operator /(Energy<T> a, Power<T> b) |
| | 8131 | | { |
| | 8132 | | return Divide(a, b); |
| | 8133 | | } |
| | 8134 | |
|
| | 8135 | | /// <summary>Divides Energy by Power resulting in Time.</summary> |
| | 8136 | | /// <param name="b">The Power to divide by.</param> |
| | 8137 | | /// <returns>The Time result of the division.</returns> |
| | 8138 | | public Time<T> Divide(Power<T> b) |
| | 8139 | | { |
| | 8140 | | return this / b; |
| | 8141 | | } |
| | 8142 | |
|
| | 8143 | | #endregion |
| | 8144 | |
|
| | 8145 | |
|
| | 8146 | | #region Energy<T> / Pressure<T> = Volume<T> |
| | 8147 | |
|
| | 8148 | | /// <summary>Divides Energy by Pressure resulting in Volume.</summary> |
| | 8149 | | /// <param name="a">The Energy to be divided.</param> |
| | 8150 | | /// <param name="b">The Pressure to divide by.</param> |
| | 8151 | | /// <returns>The Volume result of the division.</returns> |
| | 8152 | | public static Volume<T> Divide(Energy<T> a, Pressure<T> b) |
| | 8153 | | { |
| | 8154 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 8155 | | Time.Units TimeUnits2 = a._TimeUnits4 <= b._TimeUnits3 ? a._TimeUnits4 : b._TimeUnits3; |
| | 8156 | | Time.Units TimeUnits3 = a._TimeUnits5 <= b._TimeUnits4 ? a._TimeUnits5 : b._TimeUnits4; |
| | 8157 | |
|
| | 8158 | | T A = a[MassUnits1, a._LengthUnits2, a._LengthUnits3, TimeUnits2, TimeUnits3]; |
| | 8159 | | T B = b[MassUnits1, b._LengthUnits2, TimeUnits2, TimeUnits3]; |
| | 8160 | | T C = Statics.Division(A, B); |
| | 8161 | |
|
| | 8162 | | return new Volume<T>(C |
| | 8163 | | , a._LengthUnits2 |
| | 8164 | | , a._LengthUnits3 |
| | 8165 | | , b._LengthUnits2 |
| | 8166 | | ); |
| | 8167 | | } |
| | 8168 | |
|
| | 8169 | | /// <summary>Divides Energy by Pressure resulting in Volume.</summary> |
| | 8170 | | /// <param name="a">The Energy to be divided.</param> |
| | 8171 | | /// <param name="b">The Pressure to divide by.</param> |
| | 8172 | | /// <returns>The Volume result of the division.</returns> |
| | 8173 | | public static Volume<T> operator /(Energy<T> a, Pressure<T> b) |
| | 8174 | | { |
| | 8175 | | return Divide(a, b); |
| | 8176 | | } |
| | 8177 | |
|
| | 8178 | | /// <summary>Divides Energy by Pressure resulting in Volume.</summary> |
| | 8179 | | /// <param name="b">The Pressure to divide by.</param> |
| | 8180 | | /// <returns>The Volume result of the division.</returns> |
| | 8181 | | public Volume<T> Divide(Pressure<T> b) |
| | 8182 | | { |
| | 8183 | | return this / b; |
| | 8184 | | } |
| | 8185 | |
|
| | 8186 | | #endregion |
| | 8187 | |
|
| | 8188 | |
|
| | 8189 | | #region Energy<T> / Speed<T> = LinearMassFlow<T> |
| | 8190 | |
|
| | 8191 | | /// <summary>Divides Energy by Speed resulting in LinearMassFlow.</summary> |
| | 8192 | | /// <param name="a">The Energy to be divided.</param> |
| | 8193 | | /// <param name="b">The Speed to divide by.</param> |
| | 8194 | | /// <returns>The LinearMassFlow result of the division.</returns> |
| | 8195 | | public static LinearMassFlow<T> Divide(Energy<T> a, Speed<T> b) |
| | 8196 | | { |
| | 8197 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 8198 | | Time.Units TimeUnits2 = a._TimeUnits4 <= b._TimeUnits2 ? a._TimeUnits4 : b._TimeUnits2; |
| | 8199 | |
|
| | 8200 | | T A = a[a._MassUnits1, LengthUnits1, a._LengthUnits3, TimeUnits2, a._TimeUnits5]; |
| | 8201 | | T B = b[LengthUnits1, TimeUnits2]; |
| | 8202 | | T C = Statics.Division(A, B); |
| | 8203 | |
|
| | 8204 | | return new LinearMassFlow<T>(C |
| | 8205 | | , a._MassUnits1 |
| | 8206 | | , a._LengthUnits3 |
| | 8207 | | , a._TimeUnits5 |
| | 8208 | | ); |
| | 8209 | | } |
| | 8210 | |
|
| | 8211 | | /// <summary>Divides Energy by Speed resulting in LinearMassFlow.</summary> |
| | 8212 | | /// <param name="a">The Energy to be divided.</param> |
| | 8213 | | /// <param name="b">The Speed to divide by.</param> |
| | 8214 | | /// <returns>The LinearMassFlow result of the division.</returns> |
| | 8215 | | public static LinearMassFlow<T> operator /(Energy<T> a, Speed<T> b) |
| | 8216 | | { |
| | 8217 | | return Divide(a, b); |
| | 8218 | | } |
| | 8219 | |
|
| | 8220 | | /// <summary>Divides Energy by Speed resulting in LinearMassFlow.</summary> |
| | 8221 | | /// <param name="b">The Speed to divide by.</param> |
| | 8222 | | /// <returns>The LinearMassFlow result of the division.</returns> |
| | 8223 | | public LinearMassFlow<T> Divide(Speed<T> b) |
| | 8224 | | { |
| | 8225 | | return this / b; |
| | 8226 | | } |
| | 8227 | |
|
| | 8228 | | #endregion |
| | 8229 | |
|
| | 8230 | |
|
| | 8231 | | #region Energy<T> / Time<T> = Power<T> |
| | 8232 | |
|
| | 8233 | | /// <summary>Divides Energy by Time resulting in Power.</summary> |
| | 8234 | | /// <param name="a">The Energy to be divided.</param> |
| | 8235 | | /// <param name="b">The Time to divide by.</param> |
| | 8236 | | /// <returns>The Power result of the division.</returns> |
| | 8237 | | public static Power<T> Divide(Energy<T> a, Time<T> b) |
| | 8238 | | { |
| | 8239 | |
|
| | 8240 | | T A = a[a._MassUnits1, a._LengthUnits2, a._LengthUnits3, a._TimeUnits4, a._TimeUnits5]; |
| | 8241 | | T B = b[b._TimeUnits1]; |
| | 8242 | | T C = Statics.Division(A, B); |
| | 8243 | |
|
| | 8244 | | return new Power<T>(C |
| | 8245 | | , a._MassUnits1 |
| | 8246 | | , a._LengthUnits2 |
| | 8247 | | , a._LengthUnits3 |
| | 8248 | | , a._TimeUnits4 |
| | 8249 | | , a._TimeUnits5 |
| | 8250 | | , b._TimeUnits1 |
| | 8251 | | ); |
| | 8252 | | } |
| | 8253 | |
|
| | 8254 | | /// <summary>Divides Energy by Time resulting in Power.</summary> |
| | 8255 | | /// <param name="a">The Energy to be divided.</param> |
| | 8256 | | /// <param name="b">The Time to divide by.</param> |
| | 8257 | | /// <returns>The Power result of the division.</returns> |
| | 8258 | | public static Power<T> operator /(Energy<T> a, Time<T> b) |
| | 8259 | | { |
| | 8260 | | return Divide(a, b); |
| | 8261 | | } |
| | 8262 | |
|
| | 8263 | | /// <summary>Divides Energy by Time resulting in Power.</summary> |
| | 8264 | | /// <param name="b">The Time to divide by.</param> |
| | 8265 | | /// <returns>The Power result of the division.</returns> |
| | 8266 | | public Power<T> Divide(Time<T> b) |
| | 8267 | | { |
| | 8268 | | return this / b; |
| | 8269 | | } |
| | 8270 | |
|
| | 8271 | | #endregion |
| | 8272 | |
|
| | 8273 | |
|
| | 8274 | | #region Energy<T> / Volume<T> = Pressure<T> |
| | 8275 | |
|
| | 8276 | | /// <summary>Divides Energy by Volume resulting in Pressure.</summary> |
| | 8277 | | /// <param name="a">The Energy to be divided.</param> |
| | 8278 | | /// <param name="b">The Volume to divide by.</param> |
| | 8279 | | /// <returns>The Pressure result of the division.</returns> |
| | 8280 | | public static Pressure<T> Divide(Energy<T> a, Volume<T> b) |
| | 8281 | | { |
| | 8282 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 8283 | | Length.Units LengthUnits2 = a._LengthUnits3 <= b._LengthUnits2 ? a._LengthUnits3 : b._LengthUnits2; |
| | 8284 | |
|
| | 8285 | | T A = a[a._MassUnits1, LengthUnits1, LengthUnits2, a._TimeUnits4, a._TimeUnits5]; |
| | 8286 | | T B = b[LengthUnits1, LengthUnits2, b._LengthUnits3]; |
| | 8287 | | T C = Statics.Division(A, B); |
| | 8288 | |
|
| | 8289 | | return new Pressure<T>(C |
| | 8290 | | , a._MassUnits1 |
| | 8291 | | , b._LengthUnits3 |
| | 8292 | | , a._TimeUnits4 |
| | 8293 | | , a._TimeUnits5 |
| | 8294 | | ); |
| | 8295 | | } |
| | 8296 | |
|
| | 8297 | | /// <summary>Divides Energy by Volume resulting in Pressure.</summary> |
| | 8298 | | /// <param name="a">The Energy to be divided.</param> |
| | 8299 | | /// <param name="b">The Volume to divide by.</param> |
| | 8300 | | /// <returns>The Pressure result of the division.</returns> |
| | 8301 | | public static Pressure<T> operator /(Energy<T> a, Volume<T> b) |
| | 8302 | | { |
| | 8303 | | return Divide(a, b); |
| | 8304 | | } |
| | 8305 | |
|
| | 8306 | | /// <summary>Divides Energy by Volume resulting in Pressure.</summary> |
| | 8307 | | /// <param name="b">The Volume to divide by.</param> |
| | 8308 | | /// <returns>The Pressure result of the division.</returns> |
| | 8309 | | public Pressure<T> Divide(Volume<T> b) |
| | 8310 | | { |
| | 8311 | | return this / b; |
| | 8312 | | } |
| | 8313 | |
|
| | 8314 | | #endregion |
| | 8315 | |
|
| | 8316 | | #endregion |
| | 8317 | |
|
| | 8318 | | #region LessThan |
| | 8319 | |
|
| | 8320 | | /// <summary>Determines if an Energy measurement is less than another Energy measurement.</summary> |
| | 8321 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 8322 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 8323 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 8324 | | public static bool LessThan(Energy<T> a, Energy<T> b) |
| | 8325 | | { |
| | 8326 | | return LogicBase(a, b, Statics.LessThan); |
| | 8327 | | } |
| | 8328 | |
|
| | 8329 | | /// <summary>Determines if an Energy measurement is less than another Energy measurement.</summary> |
| | 8330 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 8331 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 8332 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 8333 | | public static bool operator <(Energy<T> a, Energy<T> b) |
| | 8334 | | { |
| | 8335 | | return LessThan(a, b); |
| | 8336 | | } |
| | 8337 | |
|
| | 8338 | | /// <summary>Determines if an Energy measurement is less than another Energy measurement.</summary> |
| | 8339 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 8340 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 8341 | | public bool LessThan(Energy<T> b) |
| | 8342 | | { |
| | 8343 | | return this < b; |
| | 8344 | | } |
| | 8345 | |
|
| | 8346 | | #endregion |
| | 8347 | |
|
| | 8348 | | #region GreaterThan |
| | 8349 | |
|
| | 8350 | | /// <summary>Determines if an Energy measurement is greater than another Energy measurement.</summary> |
| | 8351 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 8352 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 8353 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 8354 | | public static bool GreaterThan(Energy<T> a, Energy<T> b) |
| | 8355 | | { |
| | 8356 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 8357 | | } |
| | 8358 | |
|
| | 8359 | | /// <summary>Determines if an Energy measurement is greater than another Energy measurement.</summary> |
| | 8360 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 8361 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 8362 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 8363 | | public static bool operator >(Energy<T> a, Energy<T> b) |
| | 8364 | | { |
| | 8365 | | return GreaterThan(a, b); |
| | 8366 | | } |
| | 8367 | |
|
| | 8368 | | /// <summary>Determines if an Energy measurement is greater than another Energy measurement.</summary> |
| | 8369 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 8370 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 8371 | | public bool GreaterThan(Energy<T> b) |
| | 8372 | | { |
| | 8373 | | return this > b; |
| | 8374 | | } |
| | 8375 | |
|
| | 8376 | | #endregion |
| | 8377 | |
|
| | 8378 | | #region LessThanOrEqual |
| | 8379 | |
|
| | 8380 | | /// <summary>Determines if an Energy measurement is less than or equal to another Energy measurement.</summary> |
| | 8381 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 8382 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 8383 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 8384 | | public static bool LessThanOrEqual(Energy<T> a, Energy<T> b) |
| | 8385 | | { |
| | 8386 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 8387 | | } |
| | 8388 | |
|
| | 8389 | | /// <summary>Determines if an Energy measurement is less than or equal to another Energy measurement.</summary> |
| | 8390 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 8391 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 8392 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 8393 | | public static bool operator <=(Energy<T> a, Energy<T> b) |
| | 8394 | | { |
| | 8395 | | return LessThanOrEqual(a, b); |
| | 8396 | | } |
| | 8397 | |
|
| | 8398 | | /// <summary>Determines if an Energy measurement is less than or equal to another Energy measurement.</summary> |
| | 8399 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 8400 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 8401 | | public bool LessThanOrEqual(Energy<T> b) |
| | 8402 | | { |
| | 8403 | | return this <= b; |
| | 8404 | | } |
| | 8405 | |
|
| | 8406 | | #endregion |
| | 8407 | |
|
| | 8408 | | #region GreaterThanOrEqual |
| | 8409 | |
|
| | 8410 | | /// <summary>Determines if an Energy measurement is greater than or equal to another Energy measurement.</summary> |
| | 8411 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 8412 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 8413 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 8414 | | public static bool GreaterThanOrEqual(Energy<T> a, Energy<T> b) |
| | 8415 | | { |
| | 8416 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 8417 | | } |
| | 8418 | |
|
| | 8419 | | /// <summary>Determines if an Energy measurement is greater than or equal to another Energy measurement.</summary> |
| | 8420 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 8421 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 8422 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 8423 | | public static bool operator >=(Energy<T> a, Energy<T> b) |
| | 8424 | | { |
| | 8425 | | return GreaterThanOrEqual(a, b); |
| | 8426 | | } |
| | 8427 | |
|
| | 8428 | | /// <summary>Determines if an Energy measurement is greater than or equal to another Energy measurement.</summary> |
| | 8429 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 8430 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 8431 | | public bool GreaterThanOrEqual(Energy<T> b) |
| | 8432 | | { |
| | 8433 | | return this >= b; |
| | 8434 | | } |
| | 8435 | |
|
| | 8436 | | #endregion |
| | 8437 | |
|
| | 8438 | | #region Equal |
| | 8439 | |
|
| | 8440 | | /// <summary>Determines if an Energy measurement is equal to another Energy measurement.</summary> |
| | 8441 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 8442 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 8443 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 8444 | | public static bool Equal(Energy<T> a, Energy<T> b) |
| | 8445 | | { |
| | 8446 | | return LogicBase(a, b, Statics.Equate); |
| | 8447 | | } |
| | 8448 | |
|
| | 8449 | | /// <summary>Determines if an Energy measurement is equal to another Energy measurement.</summary> |
| | 8450 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 8451 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 8452 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 8453 | | public static bool operator ==(Energy<T> a, Energy<T> b) |
| | 8454 | | { |
| | 8455 | | return Equal(a, b); |
| | 8456 | | } |
| | 8457 | |
|
| | 8458 | | /// <summary>Determines if an Energy measurement is equal to another Energy measurement.</summary> |
| | 8459 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 8460 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 8461 | | public bool Equal(Energy<T> b) |
| | 8462 | | { |
| | 8463 | | return this == b; |
| | 8464 | | } |
| | 8465 | |
|
| | 8466 | | #endregion |
| | 8467 | |
|
| | 8468 | | #region NotEqual |
| | 8469 | |
|
| | 8470 | | /// <summary>Determines if an Energy measurement is not equal to another Energy measurement.</summary> |
| | 8471 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 8472 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 8473 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 8474 | | public static bool NotEqual(Energy<T> a, Energy<T> b) |
| | 8475 | | { |
| | 8476 | | return LogicBase(a, b, Statics.Inequate); |
| | 8477 | | } |
| | 8478 | |
|
| | 8479 | | /// <summary>Determines if an Energy measurement is not equal to another Energy measurement.</summary> |
| | 8480 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 8481 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 8482 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 8483 | | public static bool operator !=(Energy<T> a, Energy<T> b) |
| | 8484 | | { |
| | 8485 | | return NotEqual(a, b); |
| | 8486 | | } |
| | 8487 | |
|
| | 8488 | | /// <summary>Determines if an Energy measurement is not equal to another Energy measurement.</summary> |
| | 8489 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 8490 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 8491 | | public bool NotEqual(Energy<T> b) |
| | 8492 | | { |
| | 8493 | | return this != b; |
| | 8494 | | } |
| | 8495 | |
|
| | 8496 | | #endregion |
| | 8497 | |
|
| | 8498 | | #endregion |
| | 8499 | |
|
| | 8500 | | #region Overrides |
| | 8501 | |
|
| | 8502 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 8503 | | /// <param name="obj">The object to check for equality with.</param> |
| | 8504 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 8505 | | public override bool Equals(object obj) |
| | 8506 | | { |
| | 8507 | | if (obj is Energy<T>) |
| | 8508 | | { |
| | 8509 | | return this == (Energy<T>)obj; |
| | 8510 | | } |
| | 8511 | | return false; |
| | 8512 | | } |
| | 8513 | |
|
| | 8514 | | /// <summary>Converts the Energy measurement to a string represenation.</summary> |
| | 8515 | | /// <returns>The string representation of the measurement.</returns> |
| | 8516 | | public override string ToString() |
| | 8517 | | { |
| | 8518 | | return _measurement + " " + |
| | 8519 | | _MassUnits1 + "*" + _LengthUnits2 + "*" + _LengthUnits3 |
| | 8520 | | + "/" + |
| | 8521 | | _TimeUnits4 + "/" + _TimeUnits5 |
| | 8522 | | ; |
| | 8523 | | } |
| | 8524 | |
|
| | 8525 | | /// <summary>Base hashing function for Energy measurements.</summary> |
| | 8526 | | /// <returns>Computed hash code for this instance.</returns> |
| | 8527 | | public override int GetHashCode() => Hash(_measurement); |
| | 8528 | |
|
| | 8529 | | #endregion |
| | 8530 | | } |
| | 8531 | |
|
| | 8532 | | #endregion |
| | 8533 | |
|
| | 8534 | | #region Force |
| | 8535 | |
|
| | 8536 | | internal static partial class ParsingFunctions |
| | 8537 | | { |
| | 8538 | | [Measurement.Parseable("Mass*Length/Time/Time")] |
| | 8539 | | public static object Force<T>(T value, object[] units) |
| | 8540 | | { |
| | 8541 | | if (units.Length != 4) |
| | 8542 | | { |
| | 8543 | | throw new Exception("Bug in Towel. Invalid parameters to Force Factory."); |
| | 8544 | | } |
| | 8545 | | if (!(units[0] is Mass.Units)) |
| | 8546 | | { |
| | 8547 | | throw new Exception("Bug in Towel. Invalid parameters to Force Factory."); |
| | 8548 | | } |
| | 8549 | | if (!(units[1] is Length.Units)) |
| | 8550 | | { |
| | 8551 | | throw new Exception("Bug in Towel. Invalid parameters to Force Factory."); |
| | 8552 | | } |
| | 8553 | | if (!(units[2] is Time.Units)) |
| | 8554 | | { |
| | 8555 | | throw new Exception("Bug in Towel. Invalid parameters to Force Factory."); |
| | 8556 | | } |
| | 8557 | | if (!(units[3] is Time.Units)) |
| | 8558 | | { |
| | 8559 | | throw new Exception("Bug in Towel. Invalid parameters to Force Factory."); |
| | 8560 | | } |
| | 8561 | | return new Force<T>(value |
| | 8562 | | , (Mass.Units)units[0] |
| | 8563 | | , (Length.Units)units[1] |
| | 8564 | | , (Time.Units)units[2] |
| | 8565 | | , (Time.Units)units[3] |
| | 8566 | | ); |
| | 8567 | | } |
| | 8568 | | } |
| | 8569 | |
|
| | 8570 | | /// <summary>Force measurement with a value and the units.</summary> |
| | 8571 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 8572 | | public struct Force<T> |
| | 8573 | | { |
| | 8574 | | internal T _measurement; |
| | 8575 | | internal Mass.Units _MassUnits1; |
| | 8576 | | internal Length.Units _LengthUnits2; |
| | 8577 | | internal Time.Units _TimeUnits3; |
| | 8578 | | internal Time.Units _TimeUnits4; |
| | 8579 | |
|
| | 8580 | | #region Statics |
| | 8581 | |
|
| | 8582 | | /// <summary>Converts a Force measurement from units to another.</summary> |
| | 8583 | | /// <param name="value">The value to convert the units of.</param> |
| | 8584 | | /// <param name="fromMassUnits1">The current units of the measurement.</param> |
| | 8585 | | /// <param name="fromLengthUnits2">The current units of the measurement.</param> |
| | 8586 | | /// <param name="fromTimeUnits3">The current units of the measurement.</param> |
| | 8587 | | /// <param name="fromTimeUnits4">The current units of the measurement.</param> |
| | 8588 | | /// <param name="toMassUnits1">The desired units of the measurement.</param> |
| | 8589 | | /// <param name="toLengthUnits2">The desired units of the measurement.</param> |
| | 8590 | | /// <param name="toTimeUnits3">The desired units of the measurement.</param> |
| | 8591 | | /// <param name="toTimeUnits4">The desired units of the measurement.</param> |
| | 8592 | | /// <returns>The Force measurement converted into the desired units.</returns> |
| | 8593 | | public static T Convert(T value |
| | 8594 | | , Mass.Units fromMassUnits1 |
| | 8595 | | , Length.Units fromLengthUnits2 |
| | 8596 | | , Time.Units fromTimeUnits3 |
| | 8597 | | , Time.Units fromTimeUnits4 |
| | 8598 | | , Mass.Units toMassUnits1 |
| | 8599 | | , Length.Units toLengthUnits2 |
| | 8600 | | , Time.Units toTimeUnits3 |
| | 8601 | | , Time.Units toTimeUnits4 |
| | 8602 | | ) |
| 0 | 8603 | | { |
| 0 | 8604 | | Force<T> measurement = new Force<T>(value |
| 0 | 8605 | | , fromMassUnits1 |
| 0 | 8606 | | , fromLengthUnits2 |
| 0 | 8607 | | , fromTimeUnits3 |
| 0 | 8608 | | , fromTimeUnits4 |
| 0 | 8609 | | ); |
| 0 | 8610 | | return measurement[ |
| 0 | 8611 | | toMassUnits1 |
| 0 | 8612 | | , toLengthUnits2 |
| 0 | 8613 | | , toTimeUnits3 |
| 0 | 8614 | | , toTimeUnits4 |
| 0 | 8615 | | ]; |
| 0 | 8616 | | } |
| | 8617 | |
|
| | 8618 | | /// <summary>Converts a Force measurement from units to another.</summary> |
| | 8619 | | /// <param name="value">The value to convert the units of.</param> |
| | 8620 | | /// <param name="from">The current units of the measurement.</param> |
| | 8621 | | /// <param name="to">The desired units of the measurement.</param> |
| | 8622 | | /// <returns>The Force measurement converted into the desired units.</returns> |
| | 8623 | | public static T Convert(T value, |
| | 8624 | | MeasurementUnitsSyntaxTypes.ForceBaseUnits from, |
| | 8625 | | MeasurementUnitsSyntaxTypes.ForceBaseUnits to) |
| 0 | 8626 | | { |
| 0 | 8627 | | return Convert(value |
| 0 | 8628 | | , from._MassUnits1 |
| 0 | 8629 | | , from._LengthUnits2 |
| 0 | 8630 | | , from._TimeUnits3 |
| 0 | 8631 | | , from._TimeUnits4 |
| 0 | 8632 | | , to._MassUnits1 |
| 0 | 8633 | | , to._LengthUnits2 |
| 0 | 8634 | | , to._TimeUnits3 |
| 0 | 8635 | | , to._TimeUnits4 |
| 0 | 8636 | | ); |
| 0 | 8637 | | } |
| | 8638 | |
|
| | 8639 | | /// <summary>Parses a Force measurement string.</summary> |
| | 8640 | | /// <param name="string">The string to be parsed.</param> |
| | 8641 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 8642 | | /// <returns>True if the parse was successful or false if not.</returns> |
| 0 | 8643 | | public static (bool Success, Force<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value)> tryPars |
| | 8644 | |
|
| | 8645 | | #endregion |
| | 8646 | |
|
| | 8647 | | #region Constructors |
| | 8648 | |
|
| | 8649 | | /// <summary>Constructs an Force with the measurement value and units.</summary> |
| | 8650 | | /// <param name="measurement">The measurement value of the Force.</param> |
| | 8651 | | /// <param name="units">The units of the Force.</param> |
| 0 | 8652 | | public Force(T measurement, MeasurementUnitsSyntaxTypes.ForceBaseUnits units) : this(measurement |
| 0 | 8653 | | , units._MassUnits1 |
| 0 | 8654 | | , units._LengthUnits2 |
| 0 | 8655 | | , units._TimeUnits3 |
| 0 | 8656 | | , units._TimeUnits4 |
| 0 | 8657 | | ) { } |
| | 8658 | |
|
| | 8659 | |
|
| | 8660 | | /// <summary>Constructs an Force with the measurement value and units.</summary> |
| | 8661 | | /// <param name="measurement">The measurement value of the Force.</param> |
| | 8662 | | /// <param name="MassUnits1">The units of the Force.</param> |
| | 8663 | | /// <param name="LengthUnits2">The units of the Force.</param> |
| | 8664 | | /// <param name="TimeUnits3">The units of the Force.</param> |
| | 8665 | | /// <param name="TimeUnits4">The units of the Force.</param> |
| | 8666 | | public Force(T measurement |
| | 8667 | | , Mass.Units MassUnits1 |
| | 8668 | | , Length.Units LengthUnits2 |
| | 8669 | | , Time.Units TimeUnits3 |
| | 8670 | | , Time.Units TimeUnits4 |
| | 8671 | | ) |
| 0 | 8672 | | { |
| 0 | 8673 | | _measurement = measurement; |
| 0 | 8674 | | _MassUnits1 = MassUnits1; |
| 0 | 8675 | | _LengthUnits2 = LengthUnits2; |
| 0 | 8676 | | _TimeUnits3 = TimeUnits3; |
| 0 | 8677 | | _TimeUnits4 = TimeUnits4; |
| 0 | 8678 | | } |
| | 8679 | |
|
| | 8680 | | #endregion |
| | 8681 | |
|
| | 8682 | | #region Properties |
| | 8683 | |
|
| | 8684 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 8685 | | public Mass.Units MassUnits1 |
| | 8686 | | { |
| 0 | 8687 | | get { return _MassUnits1; } |
| | 8688 | | set |
| 0 | 8689 | | { |
| 0 | 8690 | | if (value != _MassUnits1) |
| 0 | 8691 | | { |
| 0 | 8692 | | _measurement = this[value, _LengthUnits2, _TimeUnits3, _TimeUnits4]; |
| 0 | 8693 | | _MassUnits1 = value; |
| 0 | 8694 | | } |
| 0 | 8695 | | } |
| | 8696 | | } |
| | 8697 | |
|
| | 8698 | | /// <summary>The #2 component of this measurements units.</summary> |
| | 8699 | | public Length.Units LengthUnits2 |
| | 8700 | | { |
| 0 | 8701 | | get { return _LengthUnits2; } |
| | 8702 | | set |
| 0 | 8703 | | { |
| 0 | 8704 | | if (value != _LengthUnits2) |
| 0 | 8705 | | { |
| 0 | 8706 | | _measurement = this[_MassUnits1, value, _TimeUnits3, _TimeUnits4]; |
| 0 | 8707 | | _LengthUnits2 = value; |
| 0 | 8708 | | } |
| 0 | 8709 | | } |
| | 8710 | | } |
| | 8711 | |
|
| | 8712 | | /// <summary>The #3 component of this measurements units.</summary> |
| | 8713 | | public Time.Units TimeUnits3 |
| | 8714 | | { |
| 0 | 8715 | | get { return _TimeUnits3; } |
| | 8716 | | set |
| 0 | 8717 | | { |
| 0 | 8718 | | if (value != _TimeUnits3) |
| 0 | 8719 | | { |
| 0 | 8720 | | _measurement = this[_MassUnits1, _LengthUnits2, value, _TimeUnits4]; |
| 0 | 8721 | | _TimeUnits3 = value; |
| 0 | 8722 | | } |
| 0 | 8723 | | } |
| | 8724 | | } |
| | 8725 | |
|
| | 8726 | | /// <summary>The #4 component of this measurements units.</summary> |
| | 8727 | | public Time.Units TimeUnits4 |
| | 8728 | | { |
| 0 | 8729 | | get { return _TimeUnits4; } |
| | 8730 | | set |
| 0 | 8731 | | { |
| 0 | 8732 | | if (value != _TimeUnits4) |
| 0 | 8733 | | { |
| 0 | 8734 | | _measurement = this[_MassUnits1, _LengthUnits2, _TimeUnits3, value]; |
| 0 | 8735 | | _TimeUnits4 = value; |
| 0 | 8736 | | } |
| 0 | 8737 | | } |
| | 8738 | | } |
| | 8739 | |
|
| | 8740 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 8741 | | /// <param name="units">The units to get the measurement in.</param> |
| | 8742 | | /// <returns>The measurement value in the specified units.</returns> |
| | 8743 | | public T this[MeasurementUnitsSyntaxTypes.ForceBaseUnits units] |
| | 8744 | | { |
| 0 | 8745 | | get { return this[units._MassUnits1, units._LengthUnits2, units._TimeUnits3, units._TimeUnits4]; } |
| | 8746 | | } |
| | 8747 | |
|
| | 8748 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 8749 | | /// <param name="MassUnits1">The #1 component of this measurements units.</param> |
| | 8750 | | /// <param name="LengthUnits2">The #2 component of this measurements units.</param> |
| | 8751 | | /// <param name="TimeUnits3">The #3 component of this measurements units.</param> |
| | 8752 | | /// <param name="TimeUnits4">The #4 component of this measurements units.</param> |
| | 8753 | | /// <returns>The measurement value in the specified units.</returns> |
| | 8754 | | public T this[Mass.Units MassUnits1, Length.Units LengthUnits2, Time.Units TimeUnits3, Time.Units TimeUnits4] |
| | 8755 | | { |
| | 8756 | | get |
| 0 | 8757 | | { |
| 0 | 8758 | | T measurement = _measurement; |
| 0 | 8759 | | if (MassUnits1 != _MassUnits1) |
| 0 | 8760 | | { |
| 0 | 8761 | | measurement = Mass<T>.Table[(int)_MassUnits1][(int)MassUnits1](measurement); |
| | 8762 | | //if (MassUnits1 < _MassUnits1) |
| | 8763 | | //{ |
| | 8764 | | // measurement = Mass<T>.Table[(int)_MassUnits1][(int)MassUnits1](measurement); |
| | 8765 | | //} |
| | 8766 | | //else |
| | 8767 | | //{ |
| | 8768 | | // measurement = Mass<T>.Table[(int)MassUnits1][(int)_MassUnits1](measurement); |
| | 8769 | | //} |
| 0 | 8770 | | } |
| 0 | 8771 | | if (LengthUnits2 != _LengthUnits2) |
| 0 | 8772 | | { |
| 0 | 8773 | | measurement = Length<T>.Table[(int)_LengthUnits2][(int)LengthUnits2](measurement); |
| | 8774 | | //if (LengthUnits2 < _LengthUnits2) |
| | 8775 | | //{ |
| | 8776 | | // measurement = Length<T>.Table[(int)_LengthUnits2][(int)LengthUnits2](measurement); |
| | 8777 | | //} |
| | 8778 | | //else |
| | 8779 | | //{ |
| | 8780 | | // measurement = Length<T>.Table[(int)LengthUnits2][(int)_LengthUnits2](measurement); |
| | 8781 | | //} |
| 0 | 8782 | | } |
| 0 | 8783 | | if (TimeUnits3 != _TimeUnits3) |
| 0 | 8784 | | { |
| 0 | 8785 | | measurement = Time<T>.Table[(int)TimeUnits3][(int)_TimeUnits3](measurement); |
| | 8786 | | //if (TimeUnits3 > _TimeUnits3) |
| | 8787 | | //{ |
| | 8788 | | // measurement = Time<T>.Table[(int)_TimeUnits3][(int)TimeUnits3](measurement); |
| | 8789 | | //} |
| | 8790 | | //else |
| | 8791 | | //{ |
| | 8792 | | // measurement = Time<T>.Table[(int)TimeUnits3][(int)_TimeUnits3](measurement); |
| | 8793 | | //} |
| 0 | 8794 | | } |
| 0 | 8795 | | if (TimeUnits4 != _TimeUnits4) |
| 0 | 8796 | | { |
| 0 | 8797 | | measurement = Time<T>.Table[(int)TimeUnits4][(int)_TimeUnits4](measurement); |
| | 8798 | | //if (TimeUnits4 > _TimeUnits4) |
| | 8799 | | //{ |
| | 8800 | | // measurement = Time<T>.Table[(int)_TimeUnits4][(int)TimeUnits4](measurement); |
| | 8801 | | //} |
| | 8802 | | //else |
| | 8803 | | //{ |
| | 8804 | | // measurement = Time<T>.Table[(int)TimeUnits4][(int)_TimeUnits4](measurement); |
| | 8805 | | //} |
| 0 | 8806 | | } |
| 0 | 8807 | | return measurement; |
| 0 | 8808 | | } |
| | 8809 | | } |
| | 8810 | |
|
| | 8811 | | #endregion |
| | 8812 | |
|
| | 8813 | | #region Casting Operators |
| | 8814 | |
|
| | 8815 | | /// <summary>Converts a ValueTuple to a Force measurement.</summary> |
| | 8816 | | /// <param name="valueTuple">The ValueTuple to converted into a Force measurement.</param> |
| | 8817 | | public static implicit operator Force<T>((T, MeasurementUnitsSyntaxTypes.ForceBaseUnits) valueTuple) |
| 0 | 8818 | | { |
| 0 | 8819 | | return new Force<T>(valueTuple.Item1, valueTuple.Item2); |
| 0 | 8820 | | } |
| | 8821 | |
|
| | 8822 | | #endregion |
| | 8823 | |
|
| | 8824 | | #region Mathematics |
| | 8825 | |
|
| | 8826 | | #region Bases |
| | 8827 | |
|
| | 8828 | | internal static Force<T> MathBase(Force<T> a, T b, Func<T, T, T> func) |
| 0 | 8829 | | { |
| 0 | 8830 | | return new Force<T>(func(a._measurement, b) |
| 0 | 8831 | | , a._MassUnits1 |
| 0 | 8832 | | , a._LengthUnits2 |
| 0 | 8833 | | , a._TimeUnits3 |
| 0 | 8834 | | , a._TimeUnits4 |
| 0 | 8835 | | ); |
| 0 | 8836 | | } |
| | 8837 | |
|
| | 8838 | | internal static Force<T> MathBase(Force<T> a, Force<T> b, Func<T, T, T> func) |
| 0 | 8839 | | { |
| 0 | 8840 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| 0 | 8841 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| 0 | 8842 | | Time.Units TimeUnits3 = a._TimeUnits3 <= b._TimeUnits3 ? a._TimeUnits3 : b._TimeUnits3; |
| 0 | 8843 | | Time.Units TimeUnits4 = a._TimeUnits4 <= b._TimeUnits4 ? a._TimeUnits4 : b._TimeUnits4; |
| 0 | 8844 | | T A = a[MassUnits1, LengthUnits2, TimeUnits3, TimeUnits4]; |
| 0 | 8845 | | T B = b[MassUnits1, LengthUnits2, TimeUnits3, TimeUnits4]; |
| 0 | 8846 | | T C = func(A, B); |
| 0 | 8847 | | return new Force<T>(C, MassUnits1, LengthUnits2, TimeUnits3, TimeUnits4); |
| 0 | 8848 | | } |
| | 8849 | |
|
| | 8850 | | internal static bool LogicBase(Force<T> a, Force<T> b, Func<T, T, bool> func) |
| 0 | 8851 | | { |
| 0 | 8852 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| 0 | 8853 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| 0 | 8854 | | Time.Units TimeUnits3 = a._TimeUnits3 <= b._TimeUnits3 ? a._TimeUnits3 : b._TimeUnits3; |
| 0 | 8855 | | Time.Units TimeUnits4 = a._TimeUnits4 <= b._TimeUnits4 ? a._TimeUnits4 : b._TimeUnits4; |
| 0 | 8856 | | T A = a[MassUnits1, LengthUnits2, TimeUnits3, TimeUnits4]; |
| 0 | 8857 | | T B = b[MassUnits1, LengthUnits2, TimeUnits3, TimeUnits4]; |
| 0 | 8858 | | return func(A, B); |
| 0 | 8859 | | } |
| | 8860 | |
|
| | 8861 | | #endregion |
| | 8862 | |
|
| | 8863 | | #region Add |
| | 8864 | |
|
| | 8865 | | /// <summary>Adds two Force measurements.</summary> |
| | 8866 | | /// <param name="a">The first operand of the addition.</param> |
| | 8867 | | /// <param name="b">The second operand of the addition.</param> |
| | 8868 | | /// <returns>The result of the addition operation.</returns> |
| | 8869 | | public static Force<T> Add(Force<T> a, Force<T> b) |
| 0 | 8870 | | { |
| 0 | 8871 | | return MathBase(a, b, Statics.Addition); |
| 0 | 8872 | | } |
| | 8873 | |
|
| | 8874 | | /// <summary>Adds two Force measurements.</summary> |
| | 8875 | | /// <param name="a">The first operand of the addition.</param> |
| | 8876 | | /// <param name="b">The second operand of the addition.</param> |
| | 8877 | | /// <returns>The result of the addition operation.</returns> |
| | 8878 | | public static Force<T> operator +(Force<T> a, Force<T> b) |
| 0 | 8879 | | { |
| 0 | 8880 | | return Add(a, b); |
| 0 | 8881 | | } |
| | 8882 | |
|
| | 8883 | | /// <summary>Adds two Force measurements.</summary> |
| | 8884 | | /// <param name="b">The second operand of the addition.</param> |
| | 8885 | | /// <returns>The result of the addition operation.</returns> |
| | 8886 | | public Force<T> Add(Force<T> b) |
| 0 | 8887 | | { |
| 0 | 8888 | | return this + b; |
| 0 | 8889 | | } |
| | 8890 | |
|
| | 8891 | | #endregion |
| | 8892 | |
|
| | 8893 | | #region Subtract |
| | 8894 | |
|
| | 8895 | | /// <summary>Subtracts two Force measurements.</summary> |
| | 8896 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 8897 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 8898 | | /// <returns>The result of the subtraction.</returns> |
| | 8899 | | public static Force<T> Subtract(Force<T> a, Force<T> b) |
| 0 | 8900 | | { |
| 0 | 8901 | | return MathBase(a, b, Statics.Subtraction); |
| 0 | 8902 | | } |
| | 8903 | |
|
| | 8904 | | /// <summary>Subtracts two Force measurements.</summary> |
| | 8905 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 8906 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 8907 | | /// <returns>The result of the subtraction.</returns> |
| | 8908 | | public static Force<T> operator -(Force<T> a, Force<T> b) |
| 0 | 8909 | | { |
| 0 | 8910 | | return Subtract(a, b); |
| 0 | 8911 | | } |
| | 8912 | |
|
| | 8913 | | /// <summary>Subtracts two Force measurements.</summary> |
| | 8914 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 8915 | | /// <returns>The result of the subtraction.</returns> |
| | 8916 | | public Force<T> Subtract(Force<T> b) |
| 0 | 8917 | | { |
| 0 | 8918 | | return this - b; |
| 0 | 8919 | | } |
| | 8920 | |
|
| | 8921 | | #endregion |
| | 8922 | |
|
| | 8923 | | #region Multiply |
| | 8924 | |
|
| | 8925 | | /// <summary>Multiplies an Force by a scalar numeric value.</summary> |
| | 8926 | | /// <param name="a">The Force measurement to multiply.</param> |
| | 8927 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 8928 | | /// <returns>The result of the multiplication.</returns> |
| | 8929 | | public static Force<T> Multiply(Force<T> a, T b) |
| 0 | 8930 | | { |
| 0 | 8931 | | return MathBase(a, b, Statics.Multiplication); |
| 0 | 8932 | | } |
| | 8933 | |
|
| | 8934 | | /// <summary>Multiplies an Force by a scalar numeric value.</summary> |
| | 8935 | | /// <param name="a">The Force measurement to multiply.</param> |
| | 8936 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 8937 | | /// <returns>The result of the multiplication.</returns> |
| | 8938 | | public static Force<T> Multiply(T b, Force<T> a) |
| 0 | 8939 | | { |
| 0 | 8940 | | return Multiply(a, b); |
| 0 | 8941 | | } |
| | 8942 | |
|
| | 8943 | | /// <summary>Multiplies an Force by a scalar numeric value.</summary> |
| | 8944 | | /// <param name="a">The Force measurement to multiply.</param> |
| | 8945 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 8946 | | /// <returns>The result of the multiplication.</returns> |
| | 8947 | | public static Force<T> operator *(Force<T> a, T b) |
| 0 | 8948 | | { |
| 0 | 8949 | | return Multiply(a, b); |
| 0 | 8950 | | } |
| | 8951 | |
|
| | 8952 | | /// <summary>Multiplies an Force by a scalar numeric value.</summary> |
| | 8953 | | /// <param name="a">The Force measurement to multiply.</param> |
| | 8954 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 8955 | | /// <returns>The result of the multiplication.</returns> |
| | 8956 | | public static Force<T> operator *(T b, Force<T> a) |
| 0 | 8957 | | { |
| 0 | 8958 | | return Multiply(b, a); |
| 0 | 8959 | | } |
| | 8960 | |
|
| | 8961 | | /// <summary>Multiplies an Force by a scalar numeric value.</summary> |
| | 8962 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 8963 | | /// <returns>The result of the multiplication.</returns> |
| | 8964 | | public Force<T> Add(T b) |
| 0 | 8965 | | { |
| 0 | 8966 | | return this * b; |
| 0 | 8967 | | } |
| | 8968 | |
|
| | 8969 | | #region Force<T> * Length<T> = Energy<T> |
| | 8970 | |
|
| | 8971 | | /// <summary>Mulitplies Force by Length resulting in Energy.</summary> |
| | 8972 | | /// <param name="a">The Force to be multiplied.</param> |
| | 8973 | | /// <param name="b">The Length to multiply by.</param> |
| | 8974 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 8975 | | public static Energy<T> Multiply(Force<T> a, Length<T> b) |
| 0 | 8976 | | { |
| | 8977 | |
|
| 0 | 8978 | | T A = a[a._MassUnits1, a._LengthUnits2, a._TimeUnits3, a._TimeUnits4]; |
| 0 | 8979 | | T B = b[b._LengthUnits1]; |
| 0 | 8980 | | T C = Statics.Multiplication(A, B); |
| | 8981 | |
|
| 0 | 8982 | | return new Energy<T>(C |
| 0 | 8983 | | , a._MassUnits1 |
| 0 | 8984 | | , a._LengthUnits2 |
| 0 | 8985 | | , b._LengthUnits1 |
| 0 | 8986 | | , a._TimeUnits3 |
| 0 | 8987 | | , a._TimeUnits4 |
| 0 | 8988 | | ); |
| 0 | 8989 | | } |
| | 8990 | |
|
| | 8991 | | /// <summary>Mulitplies Force by Length resulting in Energy.</summary> |
| | 8992 | | /// <param name="a">The Force to be multiplied.</param> |
| | 8993 | | /// <param name="b">The Length to multiply by.</param> |
| | 8994 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 8995 | | public static Energy<T> operator *(Force<T> a, Length<T> b) |
| 0 | 8996 | | { |
| 0 | 8997 | | return Multiply(a, b); |
| 0 | 8998 | | } |
| | 8999 | |
|
| | 9000 | | /// <summary>Mulitplies Force by Length resulting in Energy.</summary> |
| | 9001 | | /// <param name="b">The Length to multiply by.</param> |
| | 9002 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 9003 | | public Energy<T> Multiply(Length<T> b) |
| 0 | 9004 | | { |
| 0 | 9005 | | return this * b; |
| 0 | 9006 | | } |
| | 9007 | |
|
| | 9008 | | #endregion |
| | 9009 | |
|
| | 9010 | | #region Force<T> * Speed<T> = Power<T> |
| | 9011 | |
|
| | 9012 | | /// <summary>Mulitplies Force by Speed resulting in Power.</summary> |
| | 9013 | | /// <param name="a">The Force to be multiplied.</param> |
| | 9014 | | /// <param name="b">The Speed to multiply by.</param> |
| | 9015 | | /// <returns>The Power result of the multiplication.</returns> |
| | 9016 | | public static Power<T> Multiply(Force<T> a, Speed<T> b) |
| 0 | 9017 | | { |
| | 9018 | |
|
| 0 | 9019 | | T A = a[a._MassUnits1, a._LengthUnits2, a._TimeUnits3, a._TimeUnits4]; |
| 0 | 9020 | | T B = b[b._LengthUnits1, b._TimeUnits2]; |
| 0 | 9021 | | T C = Statics.Multiplication(A, B); |
| | 9022 | |
|
| 0 | 9023 | | return new Power<T>(C |
| 0 | 9024 | | , a._MassUnits1 |
| 0 | 9025 | | , a._LengthUnits2 |
| 0 | 9026 | | , b._LengthUnits1 |
| 0 | 9027 | | , a._TimeUnits3 |
| 0 | 9028 | | , a._TimeUnits4 |
| 0 | 9029 | | , b._TimeUnits2 |
| 0 | 9030 | | ); |
| 0 | 9031 | | } |
| | 9032 | |
|
| | 9033 | | /// <summary>Mulitplies Force by Speed resulting in Power.</summary> |
| | 9034 | | /// <param name="a">The Force to be multiplied.</param> |
| | 9035 | | /// <param name="b">The Speed to multiply by.</param> |
| | 9036 | | /// <returns>The Power result of the multiplication.</returns> |
| | 9037 | | public static Power<T> operator *(Force<T> a, Speed<T> b) |
| 0 | 9038 | | { |
| 0 | 9039 | | return Multiply(a, b); |
| 0 | 9040 | | } |
| | 9041 | |
|
| | 9042 | | /// <summary>Mulitplies Force by Speed resulting in Power.</summary> |
| | 9043 | | /// <param name="b">The Speed to multiply by.</param> |
| | 9044 | | /// <returns>The Power result of the multiplication.</returns> |
| | 9045 | | public Power<T> Multiply(Speed<T> b) |
| 0 | 9046 | | { |
| 0 | 9047 | | return this * b; |
| 0 | 9048 | | } |
| | 9049 | |
|
| | 9050 | | #endregion |
| | 9051 | |
|
| | 9052 | | #region Force<T> * Time<T> = LinearMassFlow<T> |
| | 9053 | |
|
| | 9054 | | /// <summary>Mulitplies Force by Time resulting in LinearMassFlow.</summary> |
| | 9055 | | /// <param name="a">The Force to be multiplied.</param> |
| | 9056 | | /// <param name="b">The Time to multiply by.</param> |
| | 9057 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 9058 | | public static LinearMassFlow<T> Multiply(Force<T> a, Time<T> b) |
| 0 | 9059 | | { |
| 0 | 9060 | | Time.Units TimeUnits1 = a._TimeUnits3 <= b._TimeUnits1 ? a._TimeUnits3 : b._TimeUnits1; |
| | 9061 | |
|
| 0 | 9062 | | T A = a[a._MassUnits1, a._LengthUnits2, TimeUnits1, a._TimeUnits4]; |
| 0 | 9063 | | T B = b[TimeUnits1]; |
| 0 | 9064 | | T C = Statics.Multiplication(A, B); |
| | 9065 | |
|
| 0 | 9066 | | return new LinearMassFlow<T>(C |
| 0 | 9067 | | , a._MassUnits1 |
| 0 | 9068 | | , a._LengthUnits2 |
| 0 | 9069 | | , a._TimeUnits4 |
| 0 | 9070 | | ); |
| 0 | 9071 | | } |
| | 9072 | |
|
| | 9073 | | /// <summary>Mulitplies Force by Time resulting in LinearMassFlow.</summary> |
| | 9074 | | /// <param name="a">The Force to be multiplied.</param> |
| | 9075 | | /// <param name="b">The Time to multiply by.</param> |
| | 9076 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 9077 | | public static LinearMassFlow<T> operator *(Force<T> a, Time<T> b) |
| 0 | 9078 | | { |
| 0 | 9079 | | return Multiply(a, b); |
| 0 | 9080 | | } |
| | 9081 | |
|
| | 9082 | | /// <summary>Mulitplies Force by Time resulting in LinearMassFlow.</summary> |
| | 9083 | | /// <param name="b">The Time to multiply by.</param> |
| | 9084 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 9085 | | public LinearMassFlow<T> Multiply(Time<T> b) |
| 0 | 9086 | | { |
| 0 | 9087 | | return this * b; |
| 0 | 9088 | | } |
| | 9089 | |
|
| | 9090 | | #endregion |
| | 9091 | |
|
| | 9092 | | #region Force<T> * TimeArea<T> = LinearMass<T> |
| | 9093 | |
|
| | 9094 | | /// <summary>Mulitplies Force by TimeArea resulting in LinearMass.</summary> |
| | 9095 | | /// <param name="a">The Force to be multiplied.</param> |
| | 9096 | | /// <param name="b">The TimeArea to multiply by.</param> |
| | 9097 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 9098 | | public static LinearMass<T> Multiply(Force<T> a, TimeArea<T> b) |
| 0 | 9099 | | { |
| 0 | 9100 | | Time.Units TimeUnits1 = a._TimeUnits3 <= b._TimeUnits1 ? a._TimeUnits3 : b._TimeUnits1; |
| 0 | 9101 | | Time.Units TimeUnits2 = a._TimeUnits4 <= b._TimeUnits2 ? a._TimeUnits4 : b._TimeUnits2; |
| | 9102 | |
|
| 0 | 9103 | | T A = a[a._MassUnits1, a._LengthUnits2, TimeUnits1, TimeUnits2]; |
| 0 | 9104 | | T B = b[TimeUnits1, TimeUnits2]; |
| 0 | 9105 | | T C = Statics.Multiplication(A, B); |
| | 9106 | |
|
| 0 | 9107 | | return new LinearMass<T>(C |
| 0 | 9108 | | , a._MassUnits1 |
| 0 | 9109 | | , a._LengthUnits2 |
| 0 | 9110 | | ); |
| 0 | 9111 | | } |
| | 9112 | |
|
| | 9113 | | /// <summary>Mulitplies Force by TimeArea resulting in LinearMass.</summary> |
| | 9114 | | /// <param name="a">The Force to be multiplied.</param> |
| | 9115 | | /// <param name="b">The TimeArea to multiply by.</param> |
| | 9116 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 9117 | | public static LinearMass<T> operator *(Force<T> a, TimeArea<T> b) |
| 0 | 9118 | | { |
| 0 | 9119 | | return Multiply(a, b); |
| 0 | 9120 | | } |
| | 9121 | |
|
| | 9122 | | /// <summary>Mulitplies Force by TimeArea resulting in LinearMass.</summary> |
| | 9123 | | /// <param name="b">The TimeArea to multiply by.</param> |
| | 9124 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 9125 | | public LinearMass<T> Multiply(TimeArea<T> b) |
| 0 | 9126 | | { |
| 0 | 9127 | | return this * b; |
| 0 | 9128 | | } |
| | 9129 | |
|
| | 9130 | | #endregion |
| | 9131 | |
|
| | 9132 | | #endregion |
| | 9133 | |
|
| | 9134 | | #region Divide |
| | 9135 | |
|
| | 9136 | | /// <summary>Divides an Force measurement by another Force measurement resulting in a scalar numeric value.</summary |
| | 9137 | | /// <param name="a">The first operand of the division operation.</param> |
| | 9138 | | /// <param name="b">The second operand of the division operation.</param> |
| | 9139 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 9140 | | public static T Divide(Force<T> a, Force<T> b) |
| 0 | 9141 | | { |
| 0 | 9142 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| 0 | 9143 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| 0 | 9144 | | Time.Units TimeUnits3 = a._TimeUnits3 <= b._TimeUnits3 ? a._TimeUnits3 : b._TimeUnits3; |
| 0 | 9145 | | Time.Units TimeUnits4 = a._TimeUnits4 <= b._TimeUnits4 ? a._TimeUnits4 : b._TimeUnits4; |
| 0 | 9146 | | T A = a[MassUnits1, LengthUnits2, TimeUnits3, TimeUnits4]; |
| 0 | 9147 | | T B = b[MassUnits1, LengthUnits2, TimeUnits3, TimeUnits4]; |
| 0 | 9148 | | return Statics.Division(A, B); |
| 0 | 9149 | | } |
| | 9150 | |
|
| | 9151 | | /// <summary>Divides this Force measurement by a numaric scalar value.</summary> |
| | 9152 | | /// <param name="a">The Force measurement to divide.</param> |
| | 9153 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 9154 | | /// <returns>The result of the division.</returns> |
| | 9155 | | public static Force<T> Divide(Force<T> a, T b) |
| 0 | 9156 | | { |
| 0 | 9157 | | return MathBase(a, b, Statics.Division); |
| 0 | 9158 | | } |
| | 9159 | |
|
| | 9160 | | /// <summary>Divides this Force measurement by a numaric scalar value.</summary> |
| | 9161 | | /// <param name="a">The Force measurement to divide.</param> |
| | 9162 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 9163 | | /// <returns>The result of the division.</returns> |
| | 9164 | | public static Force<T> operator /(Force<T> a, T b) |
| 0 | 9165 | | { |
| 0 | 9166 | | return Divide(a, b); |
| 0 | 9167 | | } |
| | 9168 | |
|
| | 9169 | | /// <summary>Divides this Force measurement by a numaric scalar value.</summary> |
| | 9170 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 9171 | | /// <returns>The result of the division.</returns> |
| | 9172 | | public Force<T> Divide(T b) |
| 0 | 9173 | | { |
| 0 | 9174 | | return this / b; |
| 0 | 9175 | | } |
| | 9176 | |
|
| | 9177 | | /// <summary>Divides an Force measurement by another Force measurement resulting in a scalar numeric value.</summary |
| | 9178 | | /// <param name="a">The first operand of the division operation.</param> |
| | 9179 | | /// <param name="b">The second operand of the division operation.</param> |
| | 9180 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 9181 | | public static T operator /(Force<T> a, Force<T> b) |
| 0 | 9182 | | { |
| 0 | 9183 | | return Divide(a, b); |
| 0 | 9184 | | } |
| | 9185 | |
|
| | 9186 | | /// <summary>Divides an Force measurement by another Force measurement resulting in a scalar numeric value.</summary |
| | 9187 | | /// <param name="b">The second operand of the division operation.</param> |
| | 9188 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 9189 | | public T Divide(Force<T> b) |
| 0 | 9190 | | { |
| 0 | 9191 | | return this / b; |
| 0 | 9192 | | } |
| | 9193 | |
|
| | 9194 | |
|
| | 9195 | | #region Force<T> / Acceleration<T> = Mass<T> |
| | 9196 | |
|
| | 9197 | | /// <summary>Divides Force by Acceleration resulting in Mass.</summary> |
| | 9198 | | /// <param name="a">The Force to be divided.</param> |
| | 9199 | | /// <param name="b">The Acceleration to divide by.</param> |
| | 9200 | | /// <returns>The Mass result of the division.</returns> |
| | 9201 | | public static Mass<T> Divide(Force<T> a, Acceleration<T> b) |
| 0 | 9202 | | { |
| 0 | 9203 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| 0 | 9204 | | Time.Units TimeUnits2 = a._TimeUnits3 <= b._TimeUnits2 ? a._TimeUnits3 : b._TimeUnits2; |
| 0 | 9205 | | Time.Units TimeUnits3 = a._TimeUnits4 <= b._TimeUnits3 ? a._TimeUnits4 : b._TimeUnits3; |
| | 9206 | |
|
| 0 | 9207 | | T A = a[a._MassUnits1, LengthUnits1, TimeUnits2, TimeUnits3]; |
| 0 | 9208 | | T B = b[LengthUnits1, TimeUnits2, TimeUnits3]; |
| 0 | 9209 | | T C = Statics.Division(A, B); |
| | 9210 | |
|
| 0 | 9211 | | return new Mass<T>(C |
| 0 | 9212 | | , a._MassUnits1 |
| 0 | 9213 | | ); |
| 0 | 9214 | | } |
| | 9215 | |
|
| | 9216 | | /// <summary>Divides Force by Acceleration resulting in Mass.</summary> |
| | 9217 | | /// <param name="a">The Force to be divided.</param> |
| | 9218 | | /// <param name="b">The Acceleration to divide by.</param> |
| | 9219 | | /// <returns>The Mass result of the division.</returns> |
| | 9220 | | public static Mass<T> operator /(Force<T> a, Acceleration<T> b) |
| 0 | 9221 | | { |
| 0 | 9222 | | return Divide(a, b); |
| 0 | 9223 | | } |
| | 9224 | |
|
| | 9225 | | /// <summary>Divides Force by Acceleration resulting in Mass.</summary> |
| | 9226 | | /// <param name="b">The Acceleration to divide by.</param> |
| | 9227 | | /// <returns>The Mass result of the division.</returns> |
| | 9228 | | public Mass<T> Divide(Acceleration<T> b) |
| 0 | 9229 | | { |
| 0 | 9230 | | return this / b; |
| 0 | 9231 | | } |
| | 9232 | |
|
| | 9233 | | #endregion |
| | 9234 | |
|
| | 9235 | |
|
| | 9236 | | #region Force<T> / Area<T> = Pressure<T> |
| | 9237 | |
|
| | 9238 | | /// <summary>Divides Force by Area resulting in Pressure.</summary> |
| | 9239 | | /// <param name="a">The Force to be divided.</param> |
| | 9240 | | /// <param name="b">The Area to divide by.</param> |
| | 9241 | | /// <returns>The Pressure result of the division.</returns> |
| | 9242 | | public static Pressure<T> Divide(Force<T> a, Area<T> b) |
| 0 | 9243 | | { |
| 0 | 9244 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 9245 | |
|
| 0 | 9246 | | T A = a[a._MassUnits1, LengthUnits1, a._TimeUnits3, a._TimeUnits4]; |
| 0 | 9247 | | T B = b[LengthUnits1, b._LengthUnits2]; |
| 0 | 9248 | | T C = Statics.Division(A, B); |
| | 9249 | |
|
| 0 | 9250 | | return new Pressure<T>(C |
| 0 | 9251 | | , a._MassUnits1 |
| 0 | 9252 | | , b._LengthUnits2 |
| 0 | 9253 | | , a._TimeUnits3 |
| 0 | 9254 | | , a._TimeUnits4 |
| 0 | 9255 | | ); |
| 0 | 9256 | | } |
| | 9257 | |
|
| | 9258 | | /// <summary>Divides Force by Area resulting in Pressure.</summary> |
| | 9259 | | /// <param name="a">The Force to be divided.</param> |
| | 9260 | | /// <param name="b">The Area to divide by.</param> |
| | 9261 | | /// <returns>The Pressure result of the division.</returns> |
| | 9262 | | public static Pressure<T> operator /(Force<T> a, Area<T> b) |
| 0 | 9263 | | { |
| 0 | 9264 | | return Divide(a, b); |
| 0 | 9265 | | } |
| | 9266 | |
|
| | 9267 | | /// <summary>Divides Force by Area resulting in Pressure.</summary> |
| | 9268 | | /// <param name="b">The Area to divide by.</param> |
| | 9269 | | /// <returns>The Pressure result of the division.</returns> |
| | 9270 | | public Pressure<T> Divide(Area<T> b) |
| 0 | 9271 | | { |
| 0 | 9272 | | return this / b; |
| 0 | 9273 | | } |
| | 9274 | |
|
| | 9275 | | #endregion |
| | 9276 | |
|
| | 9277 | |
|
| | 9278 | | #region Force<T> / Mass<T> = Acceleration<T> |
| | 9279 | |
|
| | 9280 | | /// <summary>Divides Force by Mass resulting in Acceleration.</summary> |
| | 9281 | | /// <param name="a">The Force to be divided.</param> |
| | 9282 | | /// <param name="b">The Mass to divide by.</param> |
| | 9283 | | /// <returns>The Acceleration result of the division.</returns> |
| | 9284 | | public static Acceleration<T> Divide(Force<T> a, Mass<T> b) |
| 0 | 9285 | | { |
| 0 | 9286 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 9287 | |
|
| 0 | 9288 | | T A = a[MassUnits1, a._LengthUnits2, a._TimeUnits3, a._TimeUnits4]; |
| 0 | 9289 | | T B = b[MassUnits1]; |
| 0 | 9290 | | T C = Statics.Division(A, B); |
| | 9291 | |
|
| 0 | 9292 | | return new Acceleration<T>(C |
| 0 | 9293 | | , a._LengthUnits2 |
| 0 | 9294 | | , a._TimeUnits3 |
| 0 | 9295 | | , a._TimeUnits4 |
| 0 | 9296 | | ); |
| 0 | 9297 | | } |
| | 9298 | |
|
| | 9299 | | /// <summary>Divides Force by Mass resulting in Acceleration.</summary> |
| | 9300 | | /// <param name="a">The Force to be divided.</param> |
| | 9301 | | /// <param name="b">The Mass to divide by.</param> |
| | 9302 | | /// <returns>The Acceleration result of the division.</returns> |
| | 9303 | | public static Acceleration<T> operator /(Force<T> a, Mass<T> b) |
| 0 | 9304 | | { |
| 0 | 9305 | | return Divide(a, b); |
| 0 | 9306 | | } |
| | 9307 | |
|
| | 9308 | | /// <summary>Divides Force by Mass resulting in Acceleration.</summary> |
| | 9309 | | /// <param name="b">The Mass to divide by.</param> |
| | 9310 | | /// <returns>The Acceleration result of the division.</returns> |
| | 9311 | | public Acceleration<T> Divide(Mass<T> b) |
| 0 | 9312 | | { |
| 0 | 9313 | | return this / b; |
| 0 | 9314 | | } |
| | 9315 | |
|
| | 9316 | | #endregion |
| | 9317 | |
|
| | 9318 | |
|
| | 9319 | | #region Force<T> / MassRate<T> = Speed<T> |
| | 9320 | |
|
| | 9321 | | /// <summary>Divides Force by MassRate resulting in Speed.</summary> |
| | 9322 | | /// <param name="a">The Force to be divided.</param> |
| | 9323 | | /// <param name="b">The MassRate to divide by.</param> |
| | 9324 | | /// <returns>The Speed result of the division.</returns> |
| | 9325 | | public static Speed<T> Divide(Force<T> a, MassRate<T> b) |
| 0 | 9326 | | { |
| 0 | 9327 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| 0 | 9328 | | Time.Units TimeUnits2 = a._TimeUnits3 <= b._TimeUnits2 ? a._TimeUnits3 : b._TimeUnits2; |
| | 9329 | |
|
| 0 | 9330 | | T A = a[MassUnits1, a._LengthUnits2, TimeUnits2, a._TimeUnits4]; |
| 0 | 9331 | | T B = b[MassUnits1, TimeUnits2]; |
| 0 | 9332 | | T C = Statics.Division(A, B); |
| | 9333 | |
|
| 0 | 9334 | | return new Speed<T>(C |
| 0 | 9335 | | , a._LengthUnits2 |
| 0 | 9336 | | , a._TimeUnits4 |
| 0 | 9337 | | ); |
| 0 | 9338 | | } |
| | 9339 | |
|
| | 9340 | | /// <summary>Divides Force by MassRate resulting in Speed.</summary> |
| | 9341 | | /// <param name="a">The Force to be divided.</param> |
| | 9342 | | /// <param name="b">The MassRate to divide by.</param> |
| | 9343 | | /// <returns>The Speed result of the division.</returns> |
| | 9344 | | public static Speed<T> operator /(Force<T> a, MassRate<T> b) |
| 0 | 9345 | | { |
| 0 | 9346 | | return Divide(a, b); |
| 0 | 9347 | | } |
| | 9348 | |
|
| | 9349 | | /// <summary>Divides Force by MassRate resulting in Speed.</summary> |
| | 9350 | | /// <param name="b">The MassRate to divide by.</param> |
| | 9351 | | /// <returns>The Speed result of the division.</returns> |
| | 9352 | | public Speed<T> Divide(MassRate<T> b) |
| 0 | 9353 | | { |
| 0 | 9354 | | return this / b; |
| 0 | 9355 | | } |
| | 9356 | |
|
| | 9357 | | #endregion |
| | 9358 | |
|
| | 9359 | |
|
| | 9360 | | #region Force<T> / Pressure<T> = Area<T> |
| | 9361 | |
|
| | 9362 | | /// <summary>Divides Force by Pressure resulting in Area.</summary> |
| | 9363 | | /// <param name="a">The Force to be divided.</param> |
| | 9364 | | /// <param name="b">The Pressure to divide by.</param> |
| | 9365 | | /// <returns>The Area result of the division.</returns> |
| | 9366 | | public static Area<T> Divide(Force<T> a, Pressure<T> b) |
| 0 | 9367 | | { |
| 0 | 9368 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| 0 | 9369 | | Time.Units TimeUnits2 = a._TimeUnits3 <= b._TimeUnits3 ? a._TimeUnits3 : b._TimeUnits3; |
| 0 | 9370 | | Time.Units TimeUnits3 = a._TimeUnits4 <= b._TimeUnits4 ? a._TimeUnits4 : b._TimeUnits4; |
| | 9371 | |
|
| 0 | 9372 | | T A = a[MassUnits1, a._LengthUnits2, TimeUnits2, TimeUnits3]; |
| 0 | 9373 | | T B = b[MassUnits1, b._LengthUnits2, TimeUnits2, TimeUnits3]; |
| 0 | 9374 | | T C = Statics.Division(A, B); |
| | 9375 | |
|
| 0 | 9376 | | return new Area<T>(C |
| 0 | 9377 | | , a._LengthUnits2 |
| 0 | 9378 | | , b._LengthUnits2 |
| 0 | 9379 | | ); |
| 0 | 9380 | | } |
| | 9381 | |
|
| | 9382 | | /// <summary>Divides Force by Pressure resulting in Area.</summary> |
| | 9383 | | /// <param name="a">The Force to be divided.</param> |
| | 9384 | | /// <param name="b">The Pressure to divide by.</param> |
| | 9385 | | /// <returns>The Area result of the division.</returns> |
| | 9386 | | public static Area<T> operator /(Force<T> a, Pressure<T> b) |
| 0 | 9387 | | { |
| 0 | 9388 | | return Divide(a, b); |
| 0 | 9389 | | } |
| | 9390 | |
|
| | 9391 | | /// <summary>Divides Force by Pressure resulting in Area.</summary> |
| | 9392 | | /// <param name="b">The Pressure to divide by.</param> |
| | 9393 | | /// <returns>The Area result of the division.</returns> |
| | 9394 | | public Area<T> Divide(Pressure<T> b) |
| 0 | 9395 | | { |
| 0 | 9396 | | return this / b; |
| 0 | 9397 | | } |
| | 9398 | |
|
| | 9399 | | #endregion |
| | 9400 | |
|
| | 9401 | |
|
| | 9402 | | #region Force<T> / Speed<T> = MassRate<T> |
| | 9403 | |
|
| | 9404 | | /// <summary>Divides Force by Speed resulting in MassRate.</summary> |
| | 9405 | | /// <param name="a">The Force to be divided.</param> |
| | 9406 | | /// <param name="b">The Speed to divide by.</param> |
| | 9407 | | /// <returns>The MassRate result of the division.</returns> |
| | 9408 | | public static MassRate<T> Divide(Force<T> a, Speed<T> b) |
| 0 | 9409 | | { |
| 0 | 9410 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| 0 | 9411 | | Time.Units TimeUnits2 = a._TimeUnits3 <= b._TimeUnits2 ? a._TimeUnits3 : b._TimeUnits2; |
| | 9412 | |
|
| 0 | 9413 | | T A = a[a._MassUnits1, LengthUnits1, TimeUnits2, a._TimeUnits4]; |
| 0 | 9414 | | T B = b[LengthUnits1, TimeUnits2]; |
| 0 | 9415 | | T C = Statics.Division(A, B); |
| | 9416 | |
|
| 0 | 9417 | | return new MassRate<T>(C |
| 0 | 9418 | | , a._MassUnits1 |
| 0 | 9419 | | , a._TimeUnits4 |
| 0 | 9420 | | ); |
| 0 | 9421 | | } |
| | 9422 | |
|
| | 9423 | | /// <summary>Divides Force by Speed resulting in MassRate.</summary> |
| | 9424 | | /// <param name="a">The Force to be divided.</param> |
| | 9425 | | /// <param name="b">The Speed to divide by.</param> |
| | 9426 | | /// <returns>The MassRate result of the division.</returns> |
| | 9427 | | public static MassRate<T> operator /(Force<T> a, Speed<T> b) |
| 0 | 9428 | | { |
| 0 | 9429 | | return Divide(a, b); |
| 0 | 9430 | | } |
| | 9431 | |
|
| | 9432 | | /// <summary>Divides Force by Speed resulting in MassRate.</summary> |
| | 9433 | | /// <param name="b">The Speed to divide by.</param> |
| | 9434 | | /// <returns>The MassRate result of the division.</returns> |
| | 9435 | | public MassRate<T> Divide(Speed<T> b) |
| 0 | 9436 | | { |
| 0 | 9437 | | return this / b; |
| 0 | 9438 | | } |
| | 9439 | |
|
| | 9440 | | #endregion |
| | 9441 | |
|
| | 9442 | | #endregion |
| | 9443 | |
|
| | 9444 | | #region LessThan |
| | 9445 | |
|
| | 9446 | | /// <summary>Determines if an Force measurement is less than another Force measurement.</summary> |
| | 9447 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 9448 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 9449 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 9450 | | public static bool LessThan(Force<T> a, Force<T> b) |
| 0 | 9451 | | { |
| 0 | 9452 | | return LogicBase(a, b, Statics.LessThan); |
| 0 | 9453 | | } |
| | 9454 | |
|
| | 9455 | | /// <summary>Determines if an Force measurement is less than another Force measurement.</summary> |
| | 9456 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 9457 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 9458 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 9459 | | public static bool operator <(Force<T> a, Force<T> b) |
| 0 | 9460 | | { |
| 0 | 9461 | | return LessThan(a, b); |
| 0 | 9462 | | } |
| | 9463 | |
|
| | 9464 | | /// <summary>Determines if an Force measurement is less than another Force measurement.</summary> |
| | 9465 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 9466 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 9467 | | public bool LessThan(Force<T> b) |
| 0 | 9468 | | { |
| 0 | 9469 | | return this < b; |
| 0 | 9470 | | } |
| | 9471 | |
|
| | 9472 | | #endregion |
| | 9473 | |
|
| | 9474 | | #region GreaterThan |
| | 9475 | |
|
| | 9476 | | /// <summary>Determines if an Force measurement is greater than another Force measurement.</summary> |
| | 9477 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 9478 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 9479 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 9480 | | public static bool GreaterThan(Force<T> a, Force<T> b) |
| 0 | 9481 | | { |
| 0 | 9482 | | return LogicBase(a, b, Statics.GreaterThan); |
| 0 | 9483 | | } |
| | 9484 | |
|
| | 9485 | | /// <summary>Determines if an Force measurement is greater than another Force measurement.</summary> |
| | 9486 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 9487 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 9488 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 9489 | | public static bool operator >(Force<T> a, Force<T> b) |
| 0 | 9490 | | { |
| 0 | 9491 | | return GreaterThan(a, b); |
| 0 | 9492 | | } |
| | 9493 | |
|
| | 9494 | | /// <summary>Determines if an Force measurement is greater than another Force measurement.</summary> |
| | 9495 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 9496 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 9497 | | public bool GreaterThan(Force<T> b) |
| 0 | 9498 | | { |
| 0 | 9499 | | return this > b; |
| 0 | 9500 | | } |
| | 9501 | |
|
| | 9502 | | #endregion |
| | 9503 | |
|
| | 9504 | | #region LessThanOrEqual |
| | 9505 | |
|
| | 9506 | | /// <summary>Determines if an Force measurement is less than or equal to another Force measurement.</summary> |
| | 9507 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 9508 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 9509 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 9510 | | public static bool LessThanOrEqual(Force<T> a, Force<T> b) |
| 0 | 9511 | | { |
| 0 | 9512 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| 0 | 9513 | | } |
| | 9514 | |
|
| | 9515 | | /// <summary>Determines if an Force measurement is less than or equal to another Force measurement.</summary> |
| | 9516 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 9517 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 9518 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 9519 | | public static bool operator <=(Force<T> a, Force<T> b) |
| 0 | 9520 | | { |
| 0 | 9521 | | return LessThanOrEqual(a, b); |
| 0 | 9522 | | } |
| | 9523 | |
|
| | 9524 | | /// <summary>Determines if an Force measurement is less than or equal to another Force measurement.</summary> |
| | 9525 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 9526 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 9527 | | public bool LessThanOrEqual(Force<T> b) |
| 0 | 9528 | | { |
| 0 | 9529 | | return this <= b; |
| 0 | 9530 | | } |
| | 9531 | |
|
| | 9532 | | #endregion |
| | 9533 | |
|
| | 9534 | | #region GreaterThanOrEqual |
| | 9535 | |
|
| | 9536 | | /// <summary>Determines if an Force measurement is greater than or equal to another Force measurement.</summary> |
| | 9537 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 9538 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 9539 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 9540 | | public static bool GreaterThanOrEqual(Force<T> a, Force<T> b) |
| 0 | 9541 | | { |
| 0 | 9542 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| 0 | 9543 | | } |
| | 9544 | |
|
| | 9545 | | /// <summary>Determines if an Force measurement is greater than or equal to another Force measurement.</summary> |
| | 9546 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 9547 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 9548 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 9549 | | public static bool operator >=(Force<T> a, Force<T> b) |
| 0 | 9550 | | { |
| 0 | 9551 | | return GreaterThanOrEqual(a, b); |
| 0 | 9552 | | } |
| | 9553 | |
|
| | 9554 | | /// <summary>Determines if an Force measurement is greater than or equal to another Force measurement.</summary> |
| | 9555 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 9556 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 9557 | | public bool GreaterThanOrEqual(Force<T> b) |
| 0 | 9558 | | { |
| 0 | 9559 | | return this >= b; |
| 0 | 9560 | | } |
| | 9561 | |
|
| | 9562 | | #endregion |
| | 9563 | |
|
| | 9564 | | #region Equal |
| | 9565 | |
|
| | 9566 | | /// <summary>Determines if an Force measurement is equal to another Force measurement.</summary> |
| | 9567 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 9568 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 9569 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 9570 | | public static bool Equal(Force<T> a, Force<T> b) |
| 0 | 9571 | | { |
| 0 | 9572 | | return LogicBase(a, b, Statics.Equate); |
| 0 | 9573 | | } |
| | 9574 | |
|
| | 9575 | | /// <summary>Determines if an Force measurement is equal to another Force measurement.</summary> |
| | 9576 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 9577 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 9578 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 9579 | | public static bool operator ==(Force<T> a, Force<T> b) |
| 0 | 9580 | | { |
| 0 | 9581 | | return Equal(a, b); |
| 0 | 9582 | | } |
| | 9583 | |
|
| | 9584 | | /// <summary>Determines if an Force measurement is equal to another Force measurement.</summary> |
| | 9585 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 9586 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 9587 | | public bool Equal(Force<T> b) |
| 0 | 9588 | | { |
| 0 | 9589 | | return this == b; |
| 0 | 9590 | | } |
| | 9591 | |
|
| | 9592 | | #endregion |
| | 9593 | |
|
| | 9594 | | #region NotEqual |
| | 9595 | |
|
| | 9596 | | /// <summary>Determines if an Force measurement is not equal to another Force measurement.</summary> |
| | 9597 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 9598 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 9599 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 9600 | | public static bool NotEqual(Force<T> a, Force<T> b) |
| 0 | 9601 | | { |
| 0 | 9602 | | return LogicBase(a, b, Statics.Inequate); |
| 0 | 9603 | | } |
| | 9604 | |
|
| | 9605 | | /// <summary>Determines if an Force measurement is not equal to another Force measurement.</summary> |
| | 9606 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 9607 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 9608 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 9609 | | public static bool operator !=(Force<T> a, Force<T> b) |
| 0 | 9610 | | { |
| 0 | 9611 | | return NotEqual(a, b); |
| 0 | 9612 | | } |
| | 9613 | |
|
| | 9614 | | /// <summary>Determines if an Force measurement is not equal to another Force measurement.</summary> |
| | 9615 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 9616 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 9617 | | public bool NotEqual(Force<T> b) |
| 0 | 9618 | | { |
| 0 | 9619 | | return this != b; |
| 0 | 9620 | | } |
| | 9621 | |
|
| | 9622 | | #endregion |
| | 9623 | |
|
| | 9624 | | #endregion |
| | 9625 | |
|
| | 9626 | | #region Overrides |
| | 9627 | |
|
| | 9628 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 9629 | | /// <param name="obj">The object to check for equality with.</param> |
| | 9630 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 9631 | | public override bool Equals(object obj) |
| 0 | 9632 | | { |
| 0 | 9633 | | if (obj is Force<T>) |
| 0 | 9634 | | { |
| 0 | 9635 | | return this == (Force<T>)obj; |
| | 9636 | | } |
| 0 | 9637 | | return false; |
| 0 | 9638 | | } |
| | 9639 | |
|
| | 9640 | | /// <summary>Converts the Force measurement to a string represenation.</summary> |
| | 9641 | | /// <returns>The string representation of the measurement.</returns> |
| | 9642 | | public override string ToString() |
| 0 | 9643 | | { |
| 0 | 9644 | | return _measurement + " " + |
| 0 | 9645 | | _MassUnits1 + "*" + _LengthUnits2 |
| 0 | 9646 | | + "/" + |
| 0 | 9647 | | _TimeUnits3 + "/" + _TimeUnits4 |
| 0 | 9648 | | ; |
| 0 | 9649 | | } |
| | 9650 | |
|
| | 9651 | | /// <summary>Base hashing function for Force measurements.</summary> |
| | 9652 | | /// <returns>Computed hash code for this instance.</returns> |
| 0 | 9653 | | public override int GetHashCode() => Hash(_measurement); |
| | 9654 | |
|
| | 9655 | | #endregion |
| | 9656 | | } |
| | 9657 | |
|
| | 9658 | | #endregion |
| | 9659 | |
|
| | 9660 | | #region Length |
| | 9661 | |
|
| | 9662 | | internal static partial class ParsingFunctions |
| | 9663 | | { |
| | 9664 | | [Measurement.Parseable("Length")] |
| | 9665 | | public static object Length<T>(T value, object[] units) |
| | 9666 | | { |
| | 9667 | | if (units.Length != 1) |
| | 9668 | | { |
| | 9669 | | throw new Exception("Bug in Towel. Invalid parameters to Length Factory."); |
| | 9670 | | } |
| | 9671 | | if (!(units[0] is Length.Units)) |
| | 9672 | | { |
| | 9673 | | throw new Exception("Bug in Towel. Invalid parameters to Length Factory."); |
| | 9674 | | } |
| | 9675 | | return new Length<T>(value |
| | 9676 | | , (Length.Units)units[0] |
| | 9677 | | ); |
| | 9678 | | } |
| | 9679 | | } |
| | 9680 | |
|
| | 9681 | | /// <summary>Length measurement with a value and the units.</summary> |
| | 9682 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 9683 | | public struct Length<T> |
| | 9684 | | { |
| | 9685 | | internal static Func<T, T>[][] Table = UnitConversionTable.Build<Length.Units, T>(); |
| | 9686 | | internal T _measurement; |
| | 9687 | | internal Length.Units _LengthUnits1; |
| | 9688 | |
|
| | 9689 | | #region Statics |
| | 9690 | |
|
| | 9691 | | /// <summary>Converts a Length measurement from units to another.</summary> |
| | 9692 | | /// <param name="value">The value to convert the units of.</param> |
| | 9693 | | /// <param name="fromLengthUnits1">The current units of the measurement.</param> |
| | 9694 | | /// <param name="toLengthUnits1">The desired units of the measurement.</param> |
| | 9695 | | /// <returns>The Length measurement converted into the desired units.</returns> |
| | 9696 | | public static T Convert(T value |
| | 9697 | | , Length.Units fromLengthUnits1 |
| | 9698 | | , Length.Units toLengthUnits1 |
| | 9699 | | ) |
| | 9700 | | { |
| | 9701 | | Length<T> measurement = new Length<T>(value |
| | 9702 | | , fromLengthUnits1 |
| | 9703 | | ); |
| | 9704 | | return measurement[ |
| | 9705 | | toLengthUnits1 |
| | 9706 | | ]; |
| | 9707 | | } |
| | 9708 | |
|
| | 9709 | | /// <summary>Converts a Length measurement from units to another.</summary> |
| | 9710 | | /// <param name="value">The value to convert the units of.</param> |
| | 9711 | | /// <param name="from">The current units of the measurement.</param> |
| | 9712 | | /// <param name="to">The desired units of the measurement.</param> |
| | 9713 | | /// <returns>The Length measurement converted into the desired units.</returns> |
| | 9714 | | public static T Convert(T value, |
| | 9715 | | MeasurementUnitsSyntaxTypes.LengthUnits from, |
| | 9716 | | MeasurementUnitsSyntaxTypes.LengthUnits to) |
| | 9717 | | { |
| | 9718 | | return Convert(value |
| | 9719 | | , from._LengthUnits1 |
| | 9720 | | , to._LengthUnits1 |
| | 9721 | | ); |
| | 9722 | | } |
| | 9723 | |
|
| | 9724 | | /// <summary>Parses a Length measurement string.</summary> |
| | 9725 | | /// <param name="string">The string to be parsed.</param> |
| | 9726 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 9727 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 9728 | | public static (bool Success, Length<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value)> tryPar |
| | 9729 | |
|
| | 9730 | | #endregion |
| | 9731 | |
|
| | 9732 | | #region Constructors |
| | 9733 | |
|
| | 9734 | | /// <summary>Constructs an Length with the measurement value and units.</summary> |
| | 9735 | | /// <param name="measurement">The measurement value of the Length.</param> |
| | 9736 | | /// <param name="units">The units of the Length.</param> |
| | 9737 | | public Length(T measurement, MeasurementUnitsSyntaxTypes.LengthUnits units) : this(measurement |
| | 9738 | | , units._LengthUnits1 |
| | 9739 | | ) { } |
| | 9740 | |
|
| | 9741 | |
|
| | 9742 | | /// <summary>Constructs an Length with the measurement value and units.</summary> |
| | 9743 | | /// <param name="measurement">The measurement value of the Length.</param> |
| | 9744 | | /// <param name="LengthUnits1">The units of the Length.</param> |
| | 9745 | | public Length(T measurement |
| | 9746 | | , Length.Units LengthUnits1 |
| | 9747 | | ) |
| | 9748 | | { |
| | 9749 | | _measurement = measurement; |
| | 9750 | | _LengthUnits1 = LengthUnits1; |
| | 9751 | | } |
| | 9752 | |
|
| | 9753 | | #endregion |
| | 9754 | |
|
| | 9755 | | #region Properties |
| | 9756 | |
|
| | 9757 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 9758 | | public Length.Units LengthUnits1 |
| | 9759 | | { |
| | 9760 | | get { return _LengthUnits1; } |
| | 9761 | | set |
| | 9762 | | { |
| | 9763 | | if (value != _LengthUnits1) |
| | 9764 | | { |
| | 9765 | | _measurement = this[value]; |
| | 9766 | | _LengthUnits1 = value; |
| | 9767 | | } |
| | 9768 | | } |
| | 9769 | | } |
| | 9770 | |
|
| | 9771 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 9772 | | /// <param name="units">The units to get the measurement in.</param> |
| | 9773 | | /// <returns>The measurement value in the specified units.</returns> |
| | 9774 | | public T this[MeasurementUnitsSyntaxTypes.LengthUnits units] |
| | 9775 | | { |
| | 9776 | | get { return this[units._LengthUnits1]; } |
| | 9777 | | } |
| | 9778 | |
|
| | 9779 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 9780 | | /// <param name="LengthUnits1">The #1 component of this measurements units.</param> |
| | 9781 | | /// <returns>The measurement value in the specified units.</returns> |
| | 9782 | | public T this[Length.Units LengthUnits1] |
| | 9783 | | { |
| | 9784 | | get |
| | 9785 | | { |
| | 9786 | | T measurement = _measurement; |
| | 9787 | | if (LengthUnits1 != _LengthUnits1) |
| | 9788 | | { |
| | 9789 | | measurement = Length<T>.Table[(int)_LengthUnits1][(int)LengthUnits1](measurement); |
| | 9790 | | //if (LengthUnits1 < _LengthUnits1) |
| | 9791 | | //{ |
| | 9792 | | // measurement = Length<T>.Table[(int)_LengthUnits1][(int)LengthUnits1](measurement); |
| | 9793 | | //} |
| | 9794 | | //else |
| | 9795 | | //{ |
| | 9796 | | // measurement = Length<T>.Table[(int)LengthUnits1][(int)_LengthUnits1](measurement); |
| | 9797 | | //} |
| | 9798 | | } |
| | 9799 | | return measurement; |
| | 9800 | | } |
| | 9801 | | } |
| | 9802 | |
|
| | 9803 | | #endregion |
| | 9804 | |
|
| | 9805 | | #region Casting Operators |
| | 9806 | |
|
| | 9807 | | /// <summary>Converts a ValueTuple to a Length measurement.</summary> |
| | 9808 | | /// <param name="valueTuple">The ValueTuple to converted into a Length measurement.</param> |
| | 9809 | | public static implicit operator Length<T>((T, MeasurementUnitsSyntaxTypes.LengthUnits) valueTuple) |
| | 9810 | | { |
| | 9811 | | return new Length<T>(valueTuple.Item1, valueTuple.Item2); |
| | 9812 | | } |
| | 9813 | |
|
| | 9814 | | #endregion |
| | 9815 | |
|
| | 9816 | | #region Mathematics |
| | 9817 | |
|
| | 9818 | | #region Bases |
| | 9819 | |
|
| | 9820 | | internal static Length<T> MathBase(Length<T> a, T b, Func<T, T, T> func) |
| | 9821 | | { |
| | 9822 | | return new Length<T>(func(a._measurement, b) |
| | 9823 | | , a._LengthUnits1 |
| | 9824 | | ); |
| | 9825 | | } |
| | 9826 | |
|
| | 9827 | | internal static Length<T> MathBase(Length<T> a, Length<T> b, Func<T, T, T> func) |
| | 9828 | | { |
| | 9829 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 9830 | | T A = a[LengthUnits1]; |
| | 9831 | | T B = b[LengthUnits1]; |
| | 9832 | | T C = func(A, B); |
| | 9833 | | return new Length<T>(C, LengthUnits1); |
| | 9834 | | } |
| | 9835 | |
|
| | 9836 | | internal static bool LogicBase(Length<T> a, Length<T> b, Func<T, T, bool> func) |
| | 9837 | | { |
| | 9838 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 9839 | | T A = a[LengthUnits1]; |
| | 9840 | | T B = b[LengthUnits1]; |
| | 9841 | | return func(A, B); |
| | 9842 | | } |
| | 9843 | |
|
| | 9844 | | #endregion |
| | 9845 | |
|
| | 9846 | | #region Add |
| | 9847 | |
|
| | 9848 | | /// <summary>Adds two Length measurements.</summary> |
| | 9849 | | /// <param name="a">The first operand of the addition.</param> |
| | 9850 | | /// <param name="b">The second operand of the addition.</param> |
| | 9851 | | /// <returns>The result of the addition operation.</returns> |
| | 9852 | | public static Length<T> Add(Length<T> a, Length<T> b) |
| | 9853 | | { |
| | 9854 | | return MathBase(a, b, Statics.Addition); |
| | 9855 | | } |
| | 9856 | |
|
| | 9857 | | /// <summary>Adds two Length measurements.</summary> |
| | 9858 | | /// <param name="a">The first operand of the addition.</param> |
| | 9859 | | /// <param name="b">The second operand of the addition.</param> |
| | 9860 | | /// <returns>The result of the addition operation.</returns> |
| | 9861 | | public static Length<T> operator +(Length<T> a, Length<T> b) |
| | 9862 | | { |
| | 9863 | | return Add(a, b); |
| | 9864 | | } |
| | 9865 | |
|
| | 9866 | | /// <summary>Adds two Length measurements.</summary> |
| | 9867 | | /// <param name="b">The second operand of the addition.</param> |
| | 9868 | | /// <returns>The result of the addition operation.</returns> |
| | 9869 | | public Length<T> Add(Length<T> b) |
| | 9870 | | { |
| | 9871 | | return this + b; |
| | 9872 | | } |
| | 9873 | |
|
| | 9874 | | #endregion |
| | 9875 | |
|
| | 9876 | | #region Subtract |
| | 9877 | |
|
| | 9878 | | /// <summary>Subtracts two Length measurements.</summary> |
| | 9879 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 9880 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 9881 | | /// <returns>The result of the subtraction.</returns> |
| | 9882 | | public static Length<T> Subtract(Length<T> a, Length<T> b) |
| | 9883 | | { |
| | 9884 | | return MathBase(a, b, Statics.Subtraction); |
| | 9885 | | } |
| | 9886 | |
|
| | 9887 | | /// <summary>Subtracts two Length measurements.</summary> |
| | 9888 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 9889 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 9890 | | /// <returns>The result of the subtraction.</returns> |
| | 9891 | | public static Length<T> operator -(Length<T> a, Length<T> b) |
| | 9892 | | { |
| | 9893 | | return Subtract(a, b); |
| | 9894 | | } |
| | 9895 | |
|
| | 9896 | | /// <summary>Subtracts two Length measurements.</summary> |
| | 9897 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 9898 | | /// <returns>The result of the subtraction.</returns> |
| | 9899 | | public Length<T> Subtract(Length<T> b) |
| | 9900 | | { |
| | 9901 | | return this - b; |
| | 9902 | | } |
| | 9903 | |
|
| | 9904 | | #endregion |
| | 9905 | |
|
| | 9906 | | #region Multiply |
| | 9907 | |
|
| | 9908 | | /// <summary>Multiplies an Length by a scalar numeric value.</summary> |
| | 9909 | | /// <param name="a">The Length measurement to multiply.</param> |
| | 9910 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 9911 | | /// <returns>The result of the multiplication.</returns> |
| | 9912 | | public static Length<T> Multiply(Length<T> a, T b) |
| | 9913 | | { |
| | 9914 | | return MathBase(a, b, Statics.Multiplication); |
| | 9915 | | } |
| | 9916 | |
|
| | 9917 | | /// <summary>Multiplies an Length by a scalar numeric value.</summary> |
| | 9918 | | /// <param name="a">The Length measurement to multiply.</param> |
| | 9919 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 9920 | | /// <returns>The result of the multiplication.</returns> |
| | 9921 | | public static Length<T> Multiply(T b, Length<T> a) |
| | 9922 | | { |
| | 9923 | | return Multiply(a, b); |
| | 9924 | | } |
| | 9925 | |
|
| | 9926 | | /// <summary>Multiplies an Length by a scalar numeric value.</summary> |
| | 9927 | | /// <param name="a">The Length measurement to multiply.</param> |
| | 9928 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 9929 | | /// <returns>The result of the multiplication.</returns> |
| | 9930 | | public static Length<T> operator *(Length<T> a, T b) |
| | 9931 | | { |
| | 9932 | | return Multiply(a, b); |
| | 9933 | | } |
| | 9934 | |
|
| | 9935 | | /// <summary>Multiplies an Length by a scalar numeric value.</summary> |
| | 9936 | | /// <param name="a">The Length measurement to multiply.</param> |
| | 9937 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 9938 | | /// <returns>The result of the multiplication.</returns> |
| | 9939 | | public static Length<T> operator *(T b, Length<T> a) |
| | 9940 | | { |
| | 9941 | | return Multiply(b, a); |
| | 9942 | | } |
| | 9943 | |
|
| | 9944 | | /// <summary>Multiplies an Length by a scalar numeric value.</summary> |
| | 9945 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 9946 | | /// <returns>The result of the multiplication.</returns> |
| | 9947 | | public Length<T> Add(T b) |
| | 9948 | | { |
| | 9949 | | return this * b; |
| | 9950 | | } |
| | 9951 | |
|
| | 9952 | | #region Length<T> * Area<T> = Volume<T> |
| | 9953 | |
|
| | 9954 | | /// <summary>Mulitplies Length by Area resulting in Volume.</summary> |
| | 9955 | | /// <param name="a">The Length to be multiplied.</param> |
| | 9956 | | /// <param name="b">The Area to multiply by.</param> |
| | 9957 | | /// <returns>The Volume result of the multiplication.</returns> |
| | 9958 | | public static Volume<T> Multiply(Length<T> a, Area<T> b) |
| | 9959 | | { |
| | 9960 | |
|
| | 9961 | | T A = a[a._LengthUnits1]; |
| | 9962 | | T B = b[b._LengthUnits1, b._LengthUnits2]; |
| | 9963 | | T C = Statics.Multiplication(A, B); |
| | 9964 | |
|
| | 9965 | | return new Volume<T>(C |
| | 9966 | | , a._LengthUnits1 |
| | 9967 | | , b._LengthUnits1 |
| | 9968 | | , b._LengthUnits2 |
| | 9969 | | ); |
| | 9970 | | } |
| | 9971 | |
|
| | 9972 | | /// <summary>Mulitplies Length by Area resulting in Volume.</summary> |
| | 9973 | | /// <param name="a">The Length to be multiplied.</param> |
| | 9974 | | /// <param name="b">The Area to multiply by.</param> |
| | 9975 | | /// <returns>The Volume result of the multiplication.</returns> |
| | 9976 | | public static Volume<T> operator *(Length<T> a, Area<T> b) |
| | 9977 | | { |
| | 9978 | | return Multiply(a, b); |
| | 9979 | | } |
| | 9980 | |
|
| | 9981 | | /// <summary>Mulitplies Length by Area resulting in Volume.</summary> |
| | 9982 | | /// <param name="b">The Area to multiply by.</param> |
| | 9983 | | /// <returns>The Volume result of the multiplication.</returns> |
| | 9984 | | public Volume<T> Multiply(Area<T> b) |
| | 9985 | | { |
| | 9986 | | return this * b; |
| | 9987 | | } |
| | 9988 | |
|
| | 9989 | | #endregion |
| | 9990 | |
|
| | 9991 | | #region Length<T> * AreaDensity<T> = LinearDensity<T> |
| | 9992 | |
|
| | 9993 | | /// <summary>Mulitplies Length by AreaDensity resulting in LinearDensity.</summary> |
| | 9994 | | /// <param name="a">The Length to be multiplied.</param> |
| | 9995 | | /// <param name="b">The AreaDensity to multiply by.</param> |
| | 9996 | | /// <returns>The LinearDensity result of the multiplication.</returns> |
| | 9997 | | public static LinearDensity<T> Multiply(Length<T> a, AreaDensity<T> b) |
| | 9998 | | { |
| | 9999 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits2 ? a._LengthUnits1 : b._LengthUnits2; |
| | 10000 | |
|
| | 10001 | | T A = a[LengthUnits1]; |
| | 10002 | | T B = b[b._MassUnits1, LengthUnits1, b._LengthUnits3]; |
| | 10003 | | T C = Statics.Multiplication(A, B); |
| | 10004 | |
|
| | 10005 | | return new LinearDensity<T>(C |
| | 10006 | | , b._MassUnits1 |
| | 10007 | | , b._LengthUnits3 |
| | 10008 | | ); |
| | 10009 | | } |
| | 10010 | |
|
| | 10011 | | /// <summary>Mulitplies Length by AreaDensity resulting in LinearDensity.</summary> |
| | 10012 | | /// <param name="a">The Length to be multiplied.</param> |
| | 10013 | | /// <param name="b">The AreaDensity to multiply by.</param> |
| | 10014 | | /// <returns>The LinearDensity result of the multiplication.</returns> |
| | 10015 | | public static LinearDensity<T> operator *(Length<T> a, AreaDensity<T> b) |
| | 10016 | | { |
| | 10017 | | return Multiply(a, b); |
| | 10018 | | } |
| | 10019 | |
|
| | 10020 | | /// <summary>Mulitplies Length by AreaDensity resulting in LinearDensity.</summary> |
| | 10021 | | /// <param name="b">The AreaDensity to multiply by.</param> |
| | 10022 | | /// <returns>The LinearDensity result of the multiplication.</returns> |
| | 10023 | | public LinearDensity<T> Multiply(AreaDensity<T> b) |
| | 10024 | | { |
| | 10025 | | return this * b; |
| | 10026 | | } |
| | 10027 | |
|
| | 10028 | | #endregion |
| | 10029 | |
|
| | 10030 | | #region Length<T> * Density<T> = AreaDensity<T> |
| | 10031 | |
|
| | 10032 | | /// <summary>Mulitplies Length by Density resulting in AreaDensity.</summary> |
| | 10033 | | /// <param name="a">The Length to be multiplied.</param> |
| | 10034 | | /// <param name="b">The Density to multiply by.</param> |
| | 10035 | | /// <returns>The AreaDensity result of the multiplication.</returns> |
| | 10036 | | public static AreaDensity<T> Multiply(Length<T> a, Density<T> b) |
| | 10037 | | { |
| | 10038 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits2 ? a._LengthUnits1 : b._LengthUnits2; |
| | 10039 | |
|
| | 10040 | | T A = a[LengthUnits1]; |
| | 10041 | | T B = b[b._MassUnits1, LengthUnits1, b._LengthUnits3, b._LengthUnits4]; |
| | 10042 | | T C = Statics.Multiplication(A, B); |
| | 10043 | |
|
| | 10044 | | return new AreaDensity<T>(C |
| | 10045 | | , b._MassUnits1 |
| | 10046 | | , b._LengthUnits3 |
| | 10047 | | , b._LengthUnits4 |
| | 10048 | | ); |
| | 10049 | | } |
| | 10050 | |
|
| | 10051 | | /// <summary>Mulitplies Length by Density resulting in AreaDensity.</summary> |
| | 10052 | | /// <param name="a">The Length to be multiplied.</param> |
| | 10053 | | /// <param name="b">The Density to multiply by.</param> |
| | 10054 | | /// <returns>The AreaDensity result of the multiplication.</returns> |
| | 10055 | | public static AreaDensity<T> operator *(Length<T> a, Density<T> b) |
| | 10056 | | { |
| | 10057 | | return Multiply(a, b); |
| | 10058 | | } |
| | 10059 | |
|
| | 10060 | | /// <summary>Mulitplies Length by Density resulting in AreaDensity.</summary> |
| | 10061 | | /// <param name="b">The Density to multiply by.</param> |
| | 10062 | | /// <returns>The AreaDensity result of the multiplication.</returns> |
| | 10063 | | public AreaDensity<T> Multiply(Density<T> b) |
| | 10064 | | { |
| | 10065 | | return this * b; |
| | 10066 | | } |
| | 10067 | |
|
| | 10068 | | #endregion |
| | 10069 | |
|
| | 10070 | | #region Length<T> * Force<T> = Energy<T> |
| | 10071 | |
|
| | 10072 | | /// <summary>Mulitplies Length by Force resulting in Energy.</summary> |
| | 10073 | | /// <param name="a">The Length to be multiplied.</param> |
| | 10074 | | /// <param name="b">The Force to multiply by.</param> |
| | 10075 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 10076 | | public static Energy<T> Multiply(Length<T> a, Force<T> b) |
| | 10077 | | { |
| | 10078 | |
|
| | 10079 | | T A = a[a._LengthUnits1]; |
| | 10080 | | T B = b[b._MassUnits1, b._LengthUnits2, b._TimeUnits3, b._TimeUnits4]; |
| | 10081 | | T C = Statics.Multiplication(A, B); |
| | 10082 | |
|
| | 10083 | | return new Energy<T>(C |
| | 10084 | | , b._MassUnits1 |
| | 10085 | | , a._LengthUnits1 |
| | 10086 | | , b._LengthUnits2 |
| | 10087 | | , b._TimeUnits3 |
| | 10088 | | , b._TimeUnits4 |
| | 10089 | | ); |
| | 10090 | | } |
| | 10091 | |
|
| | 10092 | | /// <summary>Mulitplies Length by Force resulting in Energy.</summary> |
| | 10093 | | /// <param name="a">The Length to be multiplied.</param> |
| | 10094 | | /// <param name="b">The Force to multiply by.</param> |
| | 10095 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 10096 | | public static Energy<T> operator *(Length<T> a, Force<T> b) |
| | 10097 | | { |
| | 10098 | | return Multiply(a, b); |
| | 10099 | | } |
| | 10100 | |
|
| | 10101 | | /// <summary>Mulitplies Length by Force resulting in Energy.</summary> |
| | 10102 | | /// <param name="b">The Force to multiply by.</param> |
| | 10103 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 10104 | | public Energy<T> Multiply(Force<T> b) |
| | 10105 | | { |
| | 10106 | | return this * b; |
| | 10107 | | } |
| | 10108 | |
|
| | 10109 | | #endregion |
| | 10110 | |
|
| | 10111 | | #region Length<T> * Length<T> = Area<T> |
| | 10112 | |
|
| | 10113 | | /// <summary>Mulitplies Length by Length resulting in Area.</summary> |
| | 10114 | | /// <param name="a">The Length to be multiplied.</param> |
| | 10115 | | /// <param name="b">The Length to multiply by.</param> |
| | 10116 | | /// <returns>The Area result of the multiplication.</returns> |
| | 10117 | | public static Area<T> Multiply(Length<T> a, Length<T> b) |
| | 10118 | | { |
| | 10119 | |
|
| | 10120 | | T A = a[a._LengthUnits1]; |
| | 10121 | | T B = b[b._LengthUnits1]; |
| | 10122 | | T C = Statics.Multiplication(A, B); |
| | 10123 | |
|
| | 10124 | | return new Area<T>(C |
| | 10125 | | , a._LengthUnits1 |
| | 10126 | | , b._LengthUnits1 |
| | 10127 | | ); |
| | 10128 | | } |
| | 10129 | |
|
| | 10130 | | /// <summary>Mulitplies Length by Length resulting in Area.</summary> |
| | 10131 | | /// <param name="a">The Length to be multiplied.</param> |
| | 10132 | | /// <param name="b">The Length to multiply by.</param> |
| | 10133 | | /// <returns>The Area result of the multiplication.</returns> |
| | 10134 | | public static Area<T> operator *(Length<T> a, Length<T> b) |
| | 10135 | | { |
| | 10136 | | return Multiply(a, b); |
| | 10137 | | } |
| | 10138 | |
|
| | 10139 | | /// <summary>Mulitplies Length by Length resulting in Area.</summary> |
| | 10140 | | /// <param name="b">The Length to multiply by.</param> |
| | 10141 | | /// <returns>The Area result of the multiplication.</returns> |
| | 10142 | | public Area<T> Multiply(Length<T> b) |
| | 10143 | | { |
| | 10144 | | return this * b; |
| | 10145 | | } |
| | 10146 | |
|
| | 10147 | | #endregion |
| | 10148 | |
|
| | 10149 | | #region Length<T> * LinearDensity<T> = Mass<T> |
| | 10150 | |
|
| | 10151 | | /// <summary>Mulitplies Length by LinearDensity resulting in Mass.</summary> |
| | 10152 | | /// <param name="a">The Length to be multiplied.</param> |
| | 10153 | | /// <param name="b">The LinearDensity to multiply by.</param> |
| | 10154 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 10155 | | public static Mass<T> Multiply(Length<T> a, LinearDensity<T> b) |
| | 10156 | | { |
| | 10157 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits2 ? a._LengthUnits1 : b._LengthUnits2; |
| | 10158 | |
|
| | 10159 | | T A = a[LengthUnits1]; |
| | 10160 | | T B = b[b._MassUnits1, LengthUnits1]; |
| | 10161 | | T C = Statics.Multiplication(A, B); |
| | 10162 | |
|
| | 10163 | | return new Mass<T>(C |
| | 10164 | | , b._MassUnits1 |
| | 10165 | | ); |
| | 10166 | | } |
| | 10167 | |
|
| | 10168 | | /// <summary>Mulitplies Length by LinearDensity resulting in Mass.</summary> |
| | 10169 | | /// <param name="a">The Length to be multiplied.</param> |
| | 10170 | | /// <param name="b">The LinearDensity to multiply by.</param> |
| | 10171 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 10172 | | public static Mass<T> operator *(Length<T> a, LinearDensity<T> b) |
| | 10173 | | { |
| | 10174 | | return Multiply(a, b); |
| | 10175 | | } |
| | 10176 | |
|
| | 10177 | | /// <summary>Mulitplies Length by LinearDensity resulting in Mass.</summary> |
| | 10178 | | /// <param name="b">The LinearDensity to multiply by.</param> |
| | 10179 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 10180 | | public Mass<T> Multiply(LinearDensity<T> b) |
| | 10181 | | { |
| | 10182 | | return this * b; |
| | 10183 | | } |
| | 10184 | |
|
| | 10185 | | #endregion |
| | 10186 | |
|
| | 10187 | | #region Length<T> * Mass<T> = LinearMass<T> |
| | 10188 | |
|
| | 10189 | | /// <summary>Mulitplies Length by Mass resulting in LinearMass.</summary> |
| | 10190 | | /// <param name="a">The Length to be multiplied.</param> |
| | 10191 | | /// <param name="b">The Mass to multiply by.</param> |
| | 10192 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 10193 | | public static LinearMass<T> Multiply(Length<T> a, Mass<T> b) |
| | 10194 | | { |
| | 10195 | |
|
| | 10196 | | T A = a[a._LengthUnits1]; |
| | 10197 | | T B = b[b._MassUnits1]; |
| | 10198 | | T C = Statics.Multiplication(A, B); |
| | 10199 | |
|
| | 10200 | | return new LinearMass<T>(C |
| | 10201 | | , b._MassUnits1 |
| | 10202 | | , a._LengthUnits1 |
| | 10203 | | ); |
| | 10204 | | } |
| | 10205 | |
|
| | 10206 | | /// <summary>Mulitplies Length by Mass resulting in LinearMass.</summary> |
| | 10207 | | /// <param name="a">The Length to be multiplied.</param> |
| | 10208 | | /// <param name="b">The Mass to multiply by.</param> |
| | 10209 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 10210 | | public static LinearMass<T> operator *(Length<T> a, Mass<T> b) |
| | 10211 | | { |
| | 10212 | | return Multiply(a, b); |
| | 10213 | | } |
| | 10214 | |
|
| | 10215 | | /// <summary>Mulitplies Length by Mass resulting in LinearMass.</summary> |
| | 10216 | | /// <param name="b">The Mass to multiply by.</param> |
| | 10217 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 10218 | | public LinearMass<T> Multiply(Mass<T> b) |
| | 10219 | | { |
| | 10220 | | return this * b; |
| | 10221 | | } |
| | 10222 | |
|
| | 10223 | | #endregion |
| | 10224 | |
|
| | 10225 | | #region Length<T> * MassRate<T> = LinearMassFlow<T> |
| | 10226 | |
|
| | 10227 | | /// <summary>Mulitplies Length by MassRate resulting in LinearMassFlow.</summary> |
| | 10228 | | /// <param name="a">The Length to be multiplied.</param> |
| | 10229 | | /// <param name="b">The MassRate to multiply by.</param> |
| | 10230 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 10231 | | public static LinearMassFlow<T> Multiply(Length<T> a, MassRate<T> b) |
| | 10232 | | { |
| | 10233 | |
|
| | 10234 | | T A = a[a._LengthUnits1]; |
| | 10235 | | T B = b[b._MassUnits1, b._TimeUnits2]; |
| | 10236 | | T C = Statics.Multiplication(A, B); |
| | 10237 | |
|
| | 10238 | | return new LinearMassFlow<T>(C |
| | 10239 | | , b._MassUnits1 |
| | 10240 | | , a._LengthUnits1 |
| | 10241 | | , b._TimeUnits2 |
| | 10242 | | ); |
| | 10243 | | } |
| | 10244 | |
|
| | 10245 | | /// <summary>Mulitplies Length by MassRate resulting in LinearMassFlow.</summary> |
| | 10246 | | /// <param name="a">The Length to be multiplied.</param> |
| | 10247 | | /// <param name="b">The MassRate to multiply by.</param> |
| | 10248 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 10249 | | public static LinearMassFlow<T> operator *(Length<T> a, MassRate<T> b) |
| | 10250 | | { |
| | 10251 | | return Multiply(a, b); |
| | 10252 | | } |
| | 10253 | |
|
| | 10254 | | /// <summary>Mulitplies Length by MassRate resulting in LinearMassFlow.</summary> |
| | 10255 | | /// <param name="b">The MassRate to multiply by.</param> |
| | 10256 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 10257 | | public LinearMassFlow<T> Multiply(MassRate<T> b) |
| | 10258 | | { |
| | 10259 | | return this * b; |
| | 10260 | | } |
| | 10261 | |
|
| | 10262 | | #endregion |
| | 10263 | |
|
| | 10264 | | #endregion |
| | 10265 | |
|
| | 10266 | | #region Divide |
| | 10267 | |
|
| | 10268 | | /// <summary>Divides an Length measurement by another Length measurement resulting in a scalar numeric value.</summa |
| | 10269 | | /// <param name="a">The first operand of the division operation.</param> |
| | 10270 | | /// <param name="b">The second operand of the division operation.</param> |
| | 10271 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 10272 | | public static T Divide(Length<T> a, Length<T> b) |
| | 10273 | | { |
| | 10274 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 10275 | | T A = a[LengthUnits1]; |
| | 10276 | | T B = b[LengthUnits1]; |
| | 10277 | | return Statics.Division(A, B); |
| | 10278 | | } |
| | 10279 | |
|
| | 10280 | | /// <summary>Divides this Length measurement by a numaric scalar value.</summary> |
| | 10281 | | /// <param name="a">The Length measurement to divide.</param> |
| | 10282 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 10283 | | /// <returns>The result of the division.</returns> |
| | 10284 | | public static Length<T> Divide(Length<T> a, T b) |
| | 10285 | | { |
| | 10286 | | return MathBase(a, b, Statics.Division); |
| | 10287 | | } |
| | 10288 | |
|
| | 10289 | | /// <summary>Divides this Length measurement by a numaric scalar value.</summary> |
| | 10290 | | /// <param name="a">The Length measurement to divide.</param> |
| | 10291 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 10292 | | /// <returns>The result of the division.</returns> |
| | 10293 | | public static Length<T> operator /(Length<T> a, T b) |
| | 10294 | | { |
| | 10295 | | return Divide(a, b); |
| | 10296 | | } |
| | 10297 | |
|
| | 10298 | | /// <summary>Divides this Length measurement by a numaric scalar value.</summary> |
| | 10299 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 10300 | | /// <returns>The result of the division.</returns> |
| | 10301 | | public Length<T> Divide(T b) |
| | 10302 | | { |
| | 10303 | | return this / b; |
| | 10304 | | } |
| | 10305 | |
|
| | 10306 | | /// <summary>Divides an Length measurement by another Length measurement resulting in a scalar numeric value.</summa |
| | 10307 | | /// <param name="a">The first operand of the division operation.</param> |
| | 10308 | | /// <param name="b">The second operand of the division operation.</param> |
| | 10309 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 10310 | | public static T operator /(Length<T> a, Length<T> b) |
| | 10311 | | { |
| | 10312 | | return Divide(a, b); |
| | 10313 | | } |
| | 10314 | |
|
| | 10315 | | /// <summary>Divides an Length measurement by another Length measurement resulting in a scalar numeric value.</summa |
| | 10316 | | /// <param name="b">The second operand of the division operation.</param> |
| | 10317 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 10318 | | public T Divide(Length<T> b) |
| | 10319 | | { |
| | 10320 | | return this / b; |
| | 10321 | | } |
| | 10322 | |
|
| | 10323 | |
|
| | 10324 | | #region Length<T> / Acceleration<T> = TimeArea<T> |
| | 10325 | |
|
| | 10326 | | /// <summary>Divides Length by Acceleration resulting in TimeArea.</summary> |
| | 10327 | | /// <param name="a">The Length to be divided.</param> |
| | 10328 | | /// <param name="b">The Acceleration to divide by.</param> |
| | 10329 | | /// <returns>The TimeArea result of the division.</returns> |
| | 10330 | | public static TimeArea<T> Divide(Length<T> a, Acceleration<T> b) |
| | 10331 | | { |
| | 10332 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 10333 | |
|
| | 10334 | | T A = a[LengthUnits1]; |
| | 10335 | | T B = b[LengthUnits1, b._TimeUnits2, b._TimeUnits3]; |
| | 10336 | | T C = Statics.Division(A, B); |
| | 10337 | |
|
| | 10338 | | return new TimeArea<T>(C |
| | 10339 | | , b._TimeUnits2 |
| | 10340 | | , b._TimeUnits3 |
| | 10341 | | ); |
| | 10342 | | } |
| | 10343 | |
|
| | 10344 | | /// <summary>Divides Length by Acceleration resulting in TimeArea.</summary> |
| | 10345 | | /// <param name="a">The Length to be divided.</param> |
| | 10346 | | /// <param name="b">The Acceleration to divide by.</param> |
| | 10347 | | /// <returns>The TimeArea result of the division.</returns> |
| | 10348 | | public static TimeArea<T> operator /(Length<T> a, Acceleration<T> b) |
| | 10349 | | { |
| | 10350 | | return Divide(a, b); |
| | 10351 | | } |
| | 10352 | |
|
| | 10353 | | /// <summary>Divides Length by Acceleration resulting in TimeArea.</summary> |
| | 10354 | | /// <param name="b">The Acceleration to divide by.</param> |
| | 10355 | | /// <returns>The TimeArea result of the division.</returns> |
| | 10356 | | public TimeArea<T> Divide(Acceleration<T> b) |
| | 10357 | | { |
| | 10358 | | return this / b; |
| | 10359 | | } |
| | 10360 | |
|
| | 10361 | | #endregion |
| | 10362 | |
|
| | 10363 | |
|
| | 10364 | | #region Length<T> / Speed<T> = Time<T> |
| | 10365 | |
|
| | 10366 | | /// <summary>Divides Length by Speed resulting in Time.</summary> |
| | 10367 | | /// <param name="a">The Length to be divided.</param> |
| | 10368 | | /// <param name="b">The Speed to divide by.</param> |
| | 10369 | | /// <returns>The Time result of the division.</returns> |
| | 10370 | | public static Time<T> Divide(Length<T> a, Speed<T> b) |
| | 10371 | | { |
| | 10372 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 10373 | |
|
| | 10374 | | T A = a[LengthUnits1]; |
| | 10375 | | T B = b[LengthUnits1, b._TimeUnits2]; |
| | 10376 | | T C = Statics.Division(A, B); |
| | 10377 | |
|
| | 10378 | | return new Time<T>(C |
| | 10379 | | , b._TimeUnits2 |
| | 10380 | | ); |
| | 10381 | | } |
| | 10382 | |
|
| | 10383 | | /// <summary>Divides Length by Speed resulting in Time.</summary> |
| | 10384 | | /// <param name="a">The Length to be divided.</param> |
| | 10385 | | /// <param name="b">The Speed to divide by.</param> |
| | 10386 | | /// <returns>The Time result of the division.</returns> |
| | 10387 | | public static Time<T> operator /(Length<T> a, Speed<T> b) |
| | 10388 | | { |
| | 10389 | | return Divide(a, b); |
| | 10390 | | } |
| | 10391 | |
|
| | 10392 | | /// <summary>Divides Length by Speed resulting in Time.</summary> |
| | 10393 | | /// <param name="b">The Speed to divide by.</param> |
| | 10394 | | /// <returns>The Time result of the division.</returns> |
| | 10395 | | public Time<T> Divide(Speed<T> b) |
| | 10396 | | { |
| | 10397 | | return this / b; |
| | 10398 | | } |
| | 10399 | |
|
| | 10400 | | #endregion |
| | 10401 | |
|
| | 10402 | |
|
| | 10403 | | #region Length<T> / Time<T> = Speed<T> |
| | 10404 | |
|
| | 10405 | | /// <summary>Divides Length by Time resulting in Speed.</summary> |
| | 10406 | | /// <param name="a">The Length to be divided.</param> |
| | 10407 | | /// <param name="b">The Time to divide by.</param> |
| | 10408 | | /// <returns>The Speed result of the division.</returns> |
| | 10409 | | public static Speed<T> Divide(Length<T> a, Time<T> b) |
| | 10410 | | { |
| | 10411 | |
|
| | 10412 | | T A = a[a._LengthUnits1]; |
| | 10413 | | T B = b[b._TimeUnits1]; |
| | 10414 | | T C = Statics.Division(A, B); |
| | 10415 | |
|
| | 10416 | | return new Speed<T>(C |
| | 10417 | | , a._LengthUnits1 |
| | 10418 | | , b._TimeUnits1 |
| | 10419 | | ); |
| | 10420 | | } |
| | 10421 | |
|
| | 10422 | | /// <summary>Divides Length by Time resulting in Speed.</summary> |
| | 10423 | | /// <param name="a">The Length to be divided.</param> |
| | 10424 | | /// <param name="b">The Time to divide by.</param> |
| | 10425 | | /// <returns>The Speed result of the division.</returns> |
| | 10426 | | public static Speed<T> operator /(Length<T> a, Time<T> b) |
| | 10427 | | { |
| | 10428 | | return Divide(a, b); |
| | 10429 | | } |
| | 10430 | |
|
| | 10431 | | /// <summary>Divides Length by Time resulting in Speed.</summary> |
| | 10432 | | /// <param name="b">The Time to divide by.</param> |
| | 10433 | | /// <returns>The Speed result of the division.</returns> |
| | 10434 | | public Speed<T> Divide(Time<T> b) |
| | 10435 | | { |
| | 10436 | | return this / b; |
| | 10437 | | } |
| | 10438 | |
|
| | 10439 | | #endregion |
| | 10440 | |
|
| | 10441 | |
|
| | 10442 | | #region Length<T> / TimeArea<T> = Acceleration<T> |
| | 10443 | |
|
| | 10444 | | /// <summary>Divides Length by TimeArea resulting in Acceleration.</summary> |
| | 10445 | | /// <param name="a">The Length to be divided.</param> |
| | 10446 | | /// <param name="b">The TimeArea to divide by.</param> |
| | 10447 | | /// <returns>The Acceleration result of the division.</returns> |
| | 10448 | | public static Acceleration<T> Divide(Length<T> a, TimeArea<T> b) |
| | 10449 | | { |
| | 10450 | |
|
| | 10451 | | T A = a[a._LengthUnits1]; |
| | 10452 | | T B = b[b._TimeUnits1, b._TimeUnits2]; |
| | 10453 | | T C = Statics.Division(A, B); |
| | 10454 | |
|
| | 10455 | | return new Acceleration<T>(C |
| | 10456 | | , a._LengthUnits1 |
| | 10457 | | , b._TimeUnits1 |
| | 10458 | | , b._TimeUnits2 |
| | 10459 | | ); |
| | 10460 | | } |
| | 10461 | |
|
| | 10462 | | /// <summary>Divides Length by TimeArea resulting in Acceleration.</summary> |
| | 10463 | | /// <param name="a">The Length to be divided.</param> |
| | 10464 | | /// <param name="b">The TimeArea to divide by.</param> |
| | 10465 | | /// <returns>The Acceleration result of the division.</returns> |
| | 10466 | | public static Acceleration<T> operator /(Length<T> a, TimeArea<T> b) |
| | 10467 | | { |
| | 10468 | | return Divide(a, b); |
| | 10469 | | } |
| | 10470 | |
|
| | 10471 | | /// <summary>Divides Length by TimeArea resulting in Acceleration.</summary> |
| | 10472 | | /// <param name="b">The TimeArea to divide by.</param> |
| | 10473 | | /// <returns>The Acceleration result of the division.</returns> |
| | 10474 | | public Acceleration<T> Divide(TimeArea<T> b) |
| | 10475 | | { |
| | 10476 | | return this / b; |
| | 10477 | | } |
| | 10478 | |
|
| | 10479 | | #endregion |
| | 10480 | |
|
| | 10481 | | #endregion |
| | 10482 | |
|
| | 10483 | | #region LessThan |
| | 10484 | |
|
| | 10485 | | /// <summary>Determines if an Length measurement is less than another Length measurement.</summary> |
| | 10486 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 10487 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 10488 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 10489 | | public static bool LessThan(Length<T> a, Length<T> b) |
| | 10490 | | { |
| | 10491 | | return LogicBase(a, b, Statics.LessThan); |
| | 10492 | | } |
| | 10493 | |
|
| | 10494 | | /// <summary>Determines if an Length measurement is less than another Length measurement.</summary> |
| | 10495 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 10496 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 10497 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 10498 | | public static bool operator <(Length<T> a, Length<T> b) |
| | 10499 | | { |
| | 10500 | | return LessThan(a, b); |
| | 10501 | | } |
| | 10502 | |
|
| | 10503 | | /// <summary>Determines if an Length measurement is less than another Length measurement.</summary> |
| | 10504 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 10505 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 10506 | | public bool LessThan(Length<T> b) |
| | 10507 | | { |
| | 10508 | | return this < b; |
| | 10509 | | } |
| | 10510 | |
|
| | 10511 | | #endregion |
| | 10512 | |
|
| | 10513 | | #region GreaterThan |
| | 10514 | |
|
| | 10515 | | /// <summary>Determines if an Length measurement is greater than another Length measurement.</summary> |
| | 10516 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 10517 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 10518 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 10519 | | public static bool GreaterThan(Length<T> a, Length<T> b) |
| | 10520 | | { |
| | 10521 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 10522 | | } |
| | 10523 | |
|
| | 10524 | | /// <summary>Determines if an Length measurement is greater than another Length measurement.</summary> |
| | 10525 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 10526 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 10527 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 10528 | | public static bool operator >(Length<T> a, Length<T> b) |
| | 10529 | | { |
| | 10530 | | return GreaterThan(a, b); |
| | 10531 | | } |
| | 10532 | |
|
| | 10533 | | /// <summary>Determines if an Length measurement is greater than another Length measurement.</summary> |
| | 10534 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 10535 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 10536 | | public bool GreaterThan(Length<T> b) |
| | 10537 | | { |
| | 10538 | | return this > b; |
| | 10539 | | } |
| | 10540 | |
|
| | 10541 | | #endregion |
| | 10542 | |
|
| | 10543 | | #region LessThanOrEqual |
| | 10544 | |
|
| | 10545 | | /// <summary>Determines if an Length measurement is less than or equal to another Length measurement.</summary> |
| | 10546 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 10547 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 10548 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 10549 | | public static bool LessThanOrEqual(Length<T> a, Length<T> b) |
| | 10550 | | { |
| | 10551 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 10552 | | } |
| | 10553 | |
|
| | 10554 | | /// <summary>Determines if an Length measurement is less than or equal to another Length measurement.</summary> |
| | 10555 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 10556 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 10557 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 10558 | | public static bool operator <=(Length<T> a, Length<T> b) |
| | 10559 | | { |
| | 10560 | | return LessThanOrEqual(a, b); |
| | 10561 | | } |
| | 10562 | |
|
| | 10563 | | /// <summary>Determines if an Length measurement is less than or equal to another Length measurement.</summary> |
| | 10564 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 10565 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 10566 | | public bool LessThanOrEqual(Length<T> b) |
| | 10567 | | { |
| | 10568 | | return this <= b; |
| | 10569 | | } |
| | 10570 | |
|
| | 10571 | | #endregion |
| | 10572 | |
|
| | 10573 | | #region GreaterThanOrEqual |
| | 10574 | |
|
| | 10575 | | /// <summary>Determines if an Length measurement is greater than or equal to another Length measurement.</summary> |
| | 10576 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 10577 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 10578 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 10579 | | public static bool GreaterThanOrEqual(Length<T> a, Length<T> b) |
| | 10580 | | { |
| | 10581 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 10582 | | } |
| | 10583 | |
|
| | 10584 | | /// <summary>Determines if an Length measurement is greater than or equal to another Length measurement.</summary> |
| | 10585 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 10586 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 10587 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 10588 | | public static bool operator >=(Length<T> a, Length<T> b) |
| | 10589 | | { |
| | 10590 | | return GreaterThanOrEqual(a, b); |
| | 10591 | | } |
| | 10592 | |
|
| | 10593 | | /// <summary>Determines if an Length measurement is greater than or equal to another Length measurement.</summary> |
| | 10594 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 10595 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 10596 | | public bool GreaterThanOrEqual(Length<T> b) |
| | 10597 | | { |
| | 10598 | | return this >= b; |
| | 10599 | | } |
| | 10600 | |
|
| | 10601 | | #endregion |
| | 10602 | |
|
| | 10603 | | #region Equal |
| | 10604 | |
|
| | 10605 | | /// <summary>Determines if an Length measurement is equal to another Length measurement.</summary> |
| | 10606 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 10607 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 10608 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 10609 | | public static bool Equal(Length<T> a, Length<T> b) |
| | 10610 | | { |
| | 10611 | | return LogicBase(a, b, Statics.Equate); |
| | 10612 | | } |
| | 10613 | |
|
| | 10614 | | /// <summary>Determines if an Length measurement is equal to another Length measurement.</summary> |
| | 10615 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 10616 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 10617 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 10618 | | public static bool operator ==(Length<T> a, Length<T> b) |
| | 10619 | | { |
| | 10620 | | return Equal(a, b); |
| | 10621 | | } |
| | 10622 | |
|
| | 10623 | | /// <summary>Determines if an Length measurement is equal to another Length measurement.</summary> |
| | 10624 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 10625 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 10626 | | public bool Equal(Length<T> b) |
| | 10627 | | { |
| | 10628 | | return this == b; |
| | 10629 | | } |
| | 10630 | |
|
| | 10631 | | #endregion |
| | 10632 | |
|
| | 10633 | | #region NotEqual |
| | 10634 | |
|
| | 10635 | | /// <summary>Determines if an Length measurement is not equal to another Length measurement.</summary> |
| | 10636 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 10637 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 10638 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 10639 | | public static bool NotEqual(Length<T> a, Length<T> b) |
| | 10640 | | { |
| | 10641 | | return LogicBase(a, b, Statics.Inequate); |
| | 10642 | | } |
| | 10643 | |
|
| | 10644 | | /// <summary>Determines if an Length measurement is not equal to another Length measurement.</summary> |
| | 10645 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 10646 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 10647 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 10648 | | public static bool operator !=(Length<T> a, Length<T> b) |
| | 10649 | | { |
| | 10650 | | return NotEqual(a, b); |
| | 10651 | | } |
| | 10652 | |
|
| | 10653 | | /// <summary>Determines if an Length measurement is not equal to another Length measurement.</summary> |
| | 10654 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 10655 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 10656 | | public bool NotEqual(Length<T> b) |
| | 10657 | | { |
| | 10658 | | return this != b; |
| | 10659 | | } |
| | 10660 | |
|
| | 10661 | | #endregion |
| | 10662 | |
|
| | 10663 | | #endregion |
| | 10664 | |
|
| | 10665 | | #region Overrides |
| | 10666 | |
|
| | 10667 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 10668 | | /// <param name="obj">The object to check for equality with.</param> |
| | 10669 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 10670 | | public override bool Equals(object obj) |
| | 10671 | | { |
| | 10672 | | if (obj is Length<T>) |
| | 10673 | | { |
| | 10674 | | return this == (Length<T>)obj; |
| | 10675 | | } |
| | 10676 | | return false; |
| | 10677 | | } |
| | 10678 | |
|
| | 10679 | | /// <summary>Converts the Length measurement to a string represenation.</summary> |
| | 10680 | | /// <returns>The string representation of the measurement.</returns> |
| | 10681 | | public override string ToString() |
| | 10682 | | { |
| | 10683 | | return _measurement + " " + |
| | 10684 | | _LengthUnits1 |
| | 10685 | |
|
| | 10686 | | ; |
| | 10687 | | } |
| | 10688 | |
|
| | 10689 | | /// <summary>Base hashing function for Length measurements.</summary> |
| | 10690 | | /// <returns>Computed hash code for this instance.</returns> |
| | 10691 | | public override int GetHashCode() => Hash(_measurement); |
| | 10692 | |
|
| | 10693 | | #endregion |
| | 10694 | | } |
| | 10695 | |
|
| | 10696 | | #endregion |
| | 10697 | |
|
| | 10698 | | #region LinearDensity |
| | 10699 | |
|
| | 10700 | | internal static partial class ParsingFunctions |
| | 10701 | | { |
| | 10702 | | [Measurement.Parseable("Mass/Length")] |
| | 10703 | | public static object LinearDensity<T>(T value, object[] units) |
| | 10704 | | { |
| | 10705 | | if (units.Length != 2) |
| | 10706 | | { |
| | 10707 | | throw new Exception("Bug in Towel. Invalid parameters to LinearDensity Factory."); |
| | 10708 | | } |
| | 10709 | | if (!(units[0] is Mass.Units)) |
| | 10710 | | { |
| | 10711 | | throw new Exception("Bug in Towel. Invalid parameters to LinearDensity Factory."); |
| | 10712 | | } |
| | 10713 | | if (!(units[1] is Length.Units)) |
| | 10714 | | { |
| | 10715 | | throw new Exception("Bug in Towel. Invalid parameters to LinearDensity Factory."); |
| | 10716 | | } |
| | 10717 | | return new LinearDensity<T>(value |
| | 10718 | | , (Mass.Units)units[0] |
| | 10719 | | , (Length.Units)units[1] |
| | 10720 | | ); |
| | 10721 | | } |
| | 10722 | | } |
| | 10723 | |
|
| | 10724 | | /// <summary>LinearDensity measurement with a value and the units.</summary> |
| | 10725 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 10726 | | public struct LinearDensity<T> |
| | 10727 | | { |
| | 10728 | | internal T _measurement; |
| | 10729 | | internal Mass.Units _MassUnits1; |
| | 10730 | | internal Length.Units _LengthUnits2; |
| | 10731 | |
|
| | 10732 | | #region Statics |
| | 10733 | |
|
| | 10734 | | /// <summary>Converts a LinearDensity measurement from units to another.</summary> |
| | 10735 | | /// <param name="value">The value to convert the units of.</param> |
| | 10736 | | /// <param name="fromMassUnits1">The current units of the measurement.</param> |
| | 10737 | | /// <param name="fromLengthUnits2">The current units of the measurement.</param> |
| | 10738 | | /// <param name="toMassUnits1">The desired units of the measurement.</param> |
| | 10739 | | /// <param name="toLengthUnits2">The desired units of the measurement.</param> |
| | 10740 | | /// <returns>The LinearDensity measurement converted into the desired units.</returns> |
| | 10741 | | public static T Convert(T value |
| | 10742 | | , Mass.Units fromMassUnits1 |
| | 10743 | | , Length.Units fromLengthUnits2 |
| | 10744 | | , Mass.Units toMassUnits1 |
| | 10745 | | , Length.Units toLengthUnits2 |
| | 10746 | | ) |
| | 10747 | | { |
| | 10748 | | LinearDensity<T> measurement = new LinearDensity<T>(value |
| | 10749 | | , fromMassUnits1 |
| | 10750 | | , fromLengthUnits2 |
| | 10751 | | ); |
| | 10752 | | return measurement[ |
| | 10753 | | toMassUnits1 |
| | 10754 | | , toLengthUnits2 |
| | 10755 | | ]; |
| | 10756 | | } |
| | 10757 | |
|
| | 10758 | | /// <summary>Converts a LinearDensity measurement from units to another.</summary> |
| | 10759 | | /// <param name="value">The value to convert the units of.</param> |
| | 10760 | | /// <param name="from">The current units of the measurement.</param> |
| | 10761 | | /// <param name="to">The desired units of the measurement.</param> |
| | 10762 | | /// <returns>The LinearDensity measurement converted into the desired units.</returns> |
| | 10763 | | public static T Convert(T value, |
| | 10764 | | MeasurementUnitsSyntaxTypes.LinearDensityBaseUnits from, |
| | 10765 | | MeasurementUnitsSyntaxTypes.LinearDensityBaseUnits to) |
| | 10766 | | { |
| | 10767 | | return Convert(value |
| | 10768 | | , from._MassUnits1 |
| | 10769 | | , from._LengthUnits2 |
| | 10770 | | , to._MassUnits1 |
| | 10771 | | , to._LengthUnits2 |
| | 10772 | | ); |
| | 10773 | | } |
| | 10774 | |
|
| | 10775 | | /// <summary>Parses a LinearDensity measurement string.</summary> |
| | 10776 | | /// <param name="string">The string to be parsed.</param> |
| | 10777 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 10778 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 10779 | | public static (bool Success, LinearDensity<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value)> |
| | 10780 | |
|
| | 10781 | | #endregion |
| | 10782 | |
|
| | 10783 | | #region Constructors |
| | 10784 | |
|
| | 10785 | | /// <summary>Constructs an LinearDensity with the measurement value and units.</summary> |
| | 10786 | | /// <param name="measurement">The measurement value of the LinearDensity.</param> |
| | 10787 | | /// <param name="units">The units of the LinearDensity.</param> |
| | 10788 | | public LinearDensity(T measurement, MeasurementUnitsSyntaxTypes.LinearDensityBaseUnits units) : this(measurement |
| | 10789 | | , units._MassUnits1 |
| | 10790 | | , units._LengthUnits2 |
| | 10791 | | ) { } |
| | 10792 | |
|
| | 10793 | |
|
| | 10794 | | /// <summary>Constructs an LinearDensity with the measurement value and units.</summary> |
| | 10795 | | /// <param name="measurement">The measurement value of the LinearDensity.</param> |
| | 10796 | | /// <param name="MassUnits1">The units of the LinearDensity.</param> |
| | 10797 | | /// <param name="LengthUnits2">The units of the LinearDensity.</param> |
| | 10798 | | public LinearDensity(T measurement |
| | 10799 | | , Mass.Units MassUnits1 |
| | 10800 | | , Length.Units LengthUnits2 |
| | 10801 | | ) |
| | 10802 | | { |
| | 10803 | | _measurement = measurement; |
| | 10804 | | _MassUnits1 = MassUnits1; |
| | 10805 | | _LengthUnits2 = LengthUnits2; |
| | 10806 | | } |
| | 10807 | |
|
| | 10808 | | #endregion |
| | 10809 | |
|
| | 10810 | | #region Properties |
| | 10811 | |
|
| | 10812 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 10813 | | public Mass.Units MassUnits1 |
| | 10814 | | { |
| | 10815 | | get { return _MassUnits1; } |
| | 10816 | | set |
| | 10817 | | { |
| | 10818 | | if (value != _MassUnits1) |
| | 10819 | | { |
| | 10820 | | _measurement = this[value, _LengthUnits2]; |
| | 10821 | | _MassUnits1 = value; |
| | 10822 | | } |
| | 10823 | | } |
| | 10824 | | } |
| | 10825 | |
|
| | 10826 | | /// <summary>The #2 component of this measurements units.</summary> |
| | 10827 | | public Length.Units LengthUnits2 |
| | 10828 | | { |
| | 10829 | | get { return _LengthUnits2; } |
| | 10830 | | set |
| | 10831 | | { |
| | 10832 | | if (value != _LengthUnits2) |
| | 10833 | | { |
| | 10834 | | _measurement = this[_MassUnits1, value]; |
| | 10835 | | _LengthUnits2 = value; |
| | 10836 | | } |
| | 10837 | | } |
| | 10838 | | } |
| | 10839 | |
|
| | 10840 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 10841 | | /// <param name="units">The units to get the measurement in.</param> |
| | 10842 | | /// <returns>The measurement value in the specified units.</returns> |
| | 10843 | | public T this[MeasurementUnitsSyntaxTypes.LinearDensityBaseUnits units] |
| | 10844 | | { |
| | 10845 | | get { return this[units._MassUnits1, units._LengthUnits2]; } |
| | 10846 | | } |
| | 10847 | |
|
| | 10848 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 10849 | | /// <param name="MassUnits1">The #1 component of this measurements units.</param> |
| | 10850 | | /// <param name="LengthUnits2">The #2 component of this measurements units.</param> |
| | 10851 | | /// <returns>The measurement value in the specified units.</returns> |
| | 10852 | | public T this[Mass.Units MassUnits1, Length.Units LengthUnits2] |
| | 10853 | | { |
| | 10854 | | get |
| | 10855 | | { |
| | 10856 | | T measurement = _measurement; |
| | 10857 | | if (MassUnits1 != _MassUnits1) |
| | 10858 | | { |
| | 10859 | | measurement = Mass<T>.Table[(int)_MassUnits1][(int)MassUnits1](measurement); |
| | 10860 | | //if (MassUnits1 < _MassUnits1) |
| | 10861 | | //{ |
| | 10862 | | // measurement = Mass<T>.Table[(int)_MassUnits1][(int)MassUnits1](measurement); |
| | 10863 | | //} |
| | 10864 | | //else |
| | 10865 | | //{ |
| | 10866 | | // measurement = Mass<T>.Table[(int)MassUnits1][(int)_MassUnits1](measurement); |
| | 10867 | | //} |
| | 10868 | | } |
| | 10869 | | if (LengthUnits2 != _LengthUnits2) |
| | 10870 | | { |
| | 10871 | | measurement = Length<T>.Table[(int)LengthUnits2][(int)_LengthUnits2](measurement); |
| | 10872 | | //if (LengthUnits2 > _LengthUnits2) |
| | 10873 | | //{ |
| | 10874 | | // measurement = Length<T>.Table[(int)_LengthUnits2][(int)LengthUnits2](measurement); |
| | 10875 | | //} |
| | 10876 | | //else |
| | 10877 | | //{ |
| | 10878 | | // measurement = Length<T>.Table[(int)LengthUnits2][(int)_LengthUnits2](measurement); |
| | 10879 | | //} |
| | 10880 | | } |
| | 10881 | | return measurement; |
| | 10882 | | } |
| | 10883 | | } |
| | 10884 | |
|
| | 10885 | | #endregion |
| | 10886 | |
|
| | 10887 | | #region Casting Operators |
| | 10888 | |
|
| | 10889 | | /// <summary>Converts a ValueTuple to a LinearDensity measurement.</summary> |
| | 10890 | | /// <param name="valueTuple">The ValueTuple to converted into a LinearDensity measurement.</param> |
| | 10891 | | public static implicit operator LinearDensity<T>((T, MeasurementUnitsSyntaxTypes.LinearDensityBaseUnits) valueTuple) |
| | 10892 | | { |
| | 10893 | | return new LinearDensity<T>(valueTuple.Item1, valueTuple.Item2); |
| | 10894 | | } |
| | 10895 | |
|
| | 10896 | | #endregion |
| | 10897 | |
|
| | 10898 | | #region Mathematics |
| | 10899 | |
|
| | 10900 | | #region Bases |
| | 10901 | |
|
| | 10902 | | internal static LinearDensity<T> MathBase(LinearDensity<T> a, T b, Func<T, T, T> func) |
| | 10903 | | { |
| | 10904 | | return new LinearDensity<T>(func(a._measurement, b) |
| | 10905 | | , a._MassUnits1 |
| | 10906 | | , a._LengthUnits2 |
| | 10907 | | ); |
| | 10908 | | } |
| | 10909 | |
|
| | 10910 | | internal static LinearDensity<T> MathBase(LinearDensity<T> a, LinearDensity<T> b, Func<T, T, T> func) |
| | 10911 | | { |
| | 10912 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 10913 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 10914 | | T A = a[MassUnits1, LengthUnits2]; |
| | 10915 | | T B = b[MassUnits1, LengthUnits2]; |
| | 10916 | | T C = func(A, B); |
| | 10917 | | return new LinearDensity<T>(C, MassUnits1, LengthUnits2); |
| | 10918 | | } |
| | 10919 | |
|
| | 10920 | | internal static bool LogicBase(LinearDensity<T> a, LinearDensity<T> b, Func<T, T, bool> func) |
| | 10921 | | { |
| | 10922 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 10923 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 10924 | | T A = a[MassUnits1, LengthUnits2]; |
| | 10925 | | T B = b[MassUnits1, LengthUnits2]; |
| | 10926 | | return func(A, B); |
| | 10927 | | } |
| | 10928 | |
|
| | 10929 | | #endregion |
| | 10930 | |
|
| | 10931 | | #region Add |
| | 10932 | |
|
| | 10933 | | /// <summary>Adds two LinearDensity measurements.</summary> |
| | 10934 | | /// <param name="a">The first operand of the addition.</param> |
| | 10935 | | /// <param name="b">The second operand of the addition.</param> |
| | 10936 | | /// <returns>The result of the addition operation.</returns> |
| | 10937 | | public static LinearDensity<T> Add(LinearDensity<T> a, LinearDensity<T> b) |
| | 10938 | | { |
| | 10939 | | return MathBase(a, b, Statics.Addition); |
| | 10940 | | } |
| | 10941 | |
|
| | 10942 | | /// <summary>Adds two LinearDensity measurements.</summary> |
| | 10943 | | /// <param name="a">The first operand of the addition.</param> |
| | 10944 | | /// <param name="b">The second operand of the addition.</param> |
| | 10945 | | /// <returns>The result of the addition operation.</returns> |
| | 10946 | | public static LinearDensity<T> operator +(LinearDensity<T> a, LinearDensity<T> b) |
| | 10947 | | { |
| | 10948 | | return Add(a, b); |
| | 10949 | | } |
| | 10950 | |
|
| | 10951 | | /// <summary>Adds two LinearDensity measurements.</summary> |
| | 10952 | | /// <param name="b">The second operand of the addition.</param> |
| | 10953 | | /// <returns>The result of the addition operation.</returns> |
| | 10954 | | public LinearDensity<T> Add(LinearDensity<T> b) |
| | 10955 | | { |
| | 10956 | | return this + b; |
| | 10957 | | } |
| | 10958 | |
|
| | 10959 | | #endregion |
| | 10960 | |
|
| | 10961 | | #region Subtract |
| | 10962 | |
|
| | 10963 | | /// <summary>Subtracts two LinearDensity measurements.</summary> |
| | 10964 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 10965 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 10966 | | /// <returns>The result of the subtraction.</returns> |
| | 10967 | | public static LinearDensity<T> Subtract(LinearDensity<T> a, LinearDensity<T> b) |
| | 10968 | | { |
| | 10969 | | return MathBase(a, b, Statics.Subtraction); |
| | 10970 | | } |
| | 10971 | |
|
| | 10972 | | /// <summary>Subtracts two LinearDensity measurements.</summary> |
| | 10973 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 10974 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 10975 | | /// <returns>The result of the subtraction.</returns> |
| | 10976 | | public static LinearDensity<T> operator -(LinearDensity<T> a, LinearDensity<T> b) |
| | 10977 | | { |
| | 10978 | | return Subtract(a, b); |
| | 10979 | | } |
| | 10980 | |
|
| | 10981 | | /// <summary>Subtracts two LinearDensity measurements.</summary> |
| | 10982 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 10983 | | /// <returns>The result of the subtraction.</returns> |
| | 10984 | | public LinearDensity<T> Subtract(LinearDensity<T> b) |
| | 10985 | | { |
| | 10986 | | return this - b; |
| | 10987 | | } |
| | 10988 | |
|
| | 10989 | | #endregion |
| | 10990 | |
|
| | 10991 | | #region Multiply |
| | 10992 | |
|
| | 10993 | | /// <summary>Multiplies an LinearDensity by a scalar numeric value.</summary> |
| | 10994 | | /// <param name="a">The LinearDensity measurement to multiply.</param> |
| | 10995 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 10996 | | /// <returns>The result of the multiplication.</returns> |
| | 10997 | | public static LinearDensity<T> Multiply(LinearDensity<T> a, T b) |
| | 10998 | | { |
| | 10999 | | return MathBase(a, b, Statics.Multiplication); |
| | 11000 | | } |
| | 11001 | |
|
| | 11002 | | /// <summary>Multiplies an LinearDensity by a scalar numeric value.</summary> |
| | 11003 | | /// <param name="a">The LinearDensity measurement to multiply.</param> |
| | 11004 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 11005 | | /// <returns>The result of the multiplication.</returns> |
| | 11006 | | public static LinearDensity<T> Multiply(T b, LinearDensity<T> a) |
| | 11007 | | { |
| | 11008 | | return Multiply(a, b); |
| | 11009 | | } |
| | 11010 | |
|
| | 11011 | | /// <summary>Multiplies an LinearDensity by a scalar numeric value.</summary> |
| | 11012 | | /// <param name="a">The LinearDensity measurement to multiply.</param> |
| | 11013 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 11014 | | /// <returns>The result of the multiplication.</returns> |
| | 11015 | | public static LinearDensity<T> operator *(LinearDensity<T> a, T b) |
| | 11016 | | { |
| | 11017 | | return Multiply(a, b); |
| | 11018 | | } |
| | 11019 | |
|
| | 11020 | | /// <summary>Multiplies an LinearDensity by a scalar numeric value.</summary> |
| | 11021 | | /// <param name="a">The LinearDensity measurement to multiply.</param> |
| | 11022 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 11023 | | /// <returns>The result of the multiplication.</returns> |
| | 11024 | | public static LinearDensity<T> operator *(T b, LinearDensity<T> a) |
| | 11025 | | { |
| | 11026 | | return Multiply(b, a); |
| | 11027 | | } |
| | 11028 | |
|
| | 11029 | | /// <summary>Multiplies an LinearDensity by a scalar numeric value.</summary> |
| | 11030 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 11031 | | /// <returns>The result of the multiplication.</returns> |
| | 11032 | | public LinearDensity<T> Add(T b) |
| | 11033 | | { |
| | 11034 | | return this * b; |
| | 11035 | | } |
| | 11036 | |
|
| | 11037 | | #region LinearDensity<T> * Area<T> = LinearMass<T> |
| | 11038 | |
|
| | 11039 | | /// <summary>Mulitplies LinearDensity by Area resulting in LinearMass.</summary> |
| | 11040 | | /// <param name="a">The LinearDensity to be multiplied.</param> |
| | 11041 | | /// <param name="b">The Area to multiply by.</param> |
| | 11042 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 11043 | | public static LinearMass<T> Multiply(LinearDensity<T> a, Area<T> b) |
| | 11044 | | { |
| | 11045 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 11046 | |
|
| | 11047 | | T A = a[a._MassUnits1, LengthUnits1]; |
| | 11048 | | T B = b[LengthUnits1, b._LengthUnits2]; |
| | 11049 | | T C = Statics.Multiplication(A, B); |
| | 11050 | |
|
| | 11051 | | return new LinearMass<T>(C |
| | 11052 | | , a._MassUnits1 |
| | 11053 | | , b._LengthUnits2 |
| | 11054 | | ); |
| | 11055 | | } |
| | 11056 | |
|
| | 11057 | | /// <summary>Mulitplies LinearDensity by Area resulting in LinearMass.</summary> |
| | 11058 | | /// <param name="a">The LinearDensity to be multiplied.</param> |
| | 11059 | | /// <param name="b">The Area to multiply by.</param> |
| | 11060 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 11061 | | public static LinearMass<T> operator *(LinearDensity<T> a, Area<T> b) |
| | 11062 | | { |
| | 11063 | | return Multiply(a, b); |
| | 11064 | | } |
| | 11065 | |
|
| | 11066 | | /// <summary>Mulitplies LinearDensity by Area resulting in LinearMass.</summary> |
| | 11067 | | /// <param name="b">The Area to multiply by.</param> |
| | 11068 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 11069 | | public LinearMass<T> Multiply(Area<T> b) |
| | 11070 | | { |
| | 11071 | | return this * b; |
| | 11072 | | } |
| | 11073 | |
|
| | 11074 | | #endregion |
| | 11075 | |
|
| | 11076 | | #region LinearDensity<T> * Length<T> = Mass<T> |
| | 11077 | |
|
| | 11078 | | /// <summary>Mulitplies LinearDensity by Length resulting in Mass.</summary> |
| | 11079 | | /// <param name="a">The LinearDensity to be multiplied.</param> |
| | 11080 | | /// <param name="b">The Length to multiply by.</param> |
| | 11081 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 11082 | | public static Mass<T> Multiply(LinearDensity<T> a, Length<T> b) |
| | 11083 | | { |
| | 11084 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 11085 | |
|
| | 11086 | | T A = a[a._MassUnits1, LengthUnits1]; |
| | 11087 | | T B = b[LengthUnits1]; |
| | 11088 | | T C = Statics.Multiplication(A, B); |
| | 11089 | |
|
| | 11090 | | return new Mass<T>(C |
| | 11091 | | , a._MassUnits1 |
| | 11092 | | ); |
| | 11093 | | } |
| | 11094 | |
|
| | 11095 | | /// <summary>Mulitplies LinearDensity by Length resulting in Mass.</summary> |
| | 11096 | | /// <param name="a">The LinearDensity to be multiplied.</param> |
| | 11097 | | /// <param name="b">The Length to multiply by.</param> |
| | 11098 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 11099 | | public static Mass<T> operator *(LinearDensity<T> a, Length<T> b) |
| | 11100 | | { |
| | 11101 | | return Multiply(a, b); |
| | 11102 | | } |
| | 11103 | |
|
| | 11104 | | /// <summary>Mulitplies LinearDensity by Length resulting in Mass.</summary> |
| | 11105 | | /// <param name="b">The Length to multiply by.</param> |
| | 11106 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 11107 | | public Mass<T> Multiply(Length<T> b) |
| | 11108 | | { |
| | 11109 | | return this * b; |
| | 11110 | | } |
| | 11111 | |
|
| | 11112 | | #endregion |
| | 11113 | |
|
| | 11114 | | #region LinearDensity<T> * Speed<T> = MassRate<T> |
| | 11115 | |
|
| | 11116 | | /// <summary>Mulitplies LinearDensity by Speed resulting in MassRate.</summary> |
| | 11117 | | /// <param name="a">The LinearDensity to be multiplied.</param> |
| | 11118 | | /// <param name="b">The Speed to multiply by.</param> |
| | 11119 | | /// <returns>The MassRate result of the multiplication.</returns> |
| | 11120 | | public static MassRate<T> Multiply(LinearDensity<T> a, Speed<T> b) |
| | 11121 | | { |
| | 11122 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 11123 | |
|
| | 11124 | | T A = a[a._MassUnits1, LengthUnits1]; |
| | 11125 | | T B = b[LengthUnits1, b._TimeUnits2]; |
| | 11126 | | T C = Statics.Multiplication(A, B); |
| | 11127 | |
|
| | 11128 | | return new MassRate<T>(C |
| | 11129 | | , a._MassUnits1 |
| | 11130 | | , b._TimeUnits2 |
| | 11131 | | ); |
| | 11132 | | } |
| | 11133 | |
|
| | 11134 | | /// <summary>Mulitplies LinearDensity by Speed resulting in MassRate.</summary> |
| | 11135 | | /// <param name="a">The LinearDensity to be multiplied.</param> |
| | 11136 | | /// <param name="b">The Speed to multiply by.</param> |
| | 11137 | | /// <returns>The MassRate result of the multiplication.</returns> |
| | 11138 | | public static MassRate<T> operator *(LinearDensity<T> a, Speed<T> b) |
| | 11139 | | { |
| | 11140 | | return Multiply(a, b); |
| | 11141 | | } |
| | 11142 | |
|
| | 11143 | | /// <summary>Mulitplies LinearDensity by Speed resulting in MassRate.</summary> |
| | 11144 | | /// <param name="b">The Speed to multiply by.</param> |
| | 11145 | | /// <returns>The MassRate result of the multiplication.</returns> |
| | 11146 | | public MassRate<T> Multiply(Speed<T> b) |
| | 11147 | | { |
| | 11148 | | return this * b; |
| | 11149 | | } |
| | 11150 | |
|
| | 11151 | | #endregion |
| | 11152 | |
|
| | 11153 | | #endregion |
| | 11154 | |
|
| | 11155 | | #region Divide |
| | 11156 | |
|
| | 11157 | | /// <summary>Divides an LinearDensity measurement by another LinearDensity measurement resulting in a scalar numeric |
| | 11158 | | /// <param name="a">The first operand of the division operation.</param> |
| | 11159 | | /// <param name="b">The second operand of the division operation.</param> |
| | 11160 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 11161 | | public static T Divide(LinearDensity<T> a, LinearDensity<T> b) |
| | 11162 | | { |
| | 11163 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 11164 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 11165 | | T A = a[MassUnits1, LengthUnits2]; |
| | 11166 | | T B = b[MassUnits1, LengthUnits2]; |
| | 11167 | | return Statics.Division(A, B); |
| | 11168 | | } |
| | 11169 | |
|
| | 11170 | | /// <summary>Divides this LinearDensity measurement by a numaric scalar value.</summary> |
| | 11171 | | /// <param name="a">The LinearDensity measurement to divide.</param> |
| | 11172 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 11173 | | /// <returns>The result of the division.</returns> |
| | 11174 | | public static LinearDensity<T> Divide(LinearDensity<T> a, T b) |
| | 11175 | | { |
| | 11176 | | return MathBase(a, b, Statics.Division); |
| | 11177 | | } |
| | 11178 | |
|
| | 11179 | | /// <summary>Divides this LinearDensity measurement by a numaric scalar value.</summary> |
| | 11180 | | /// <param name="a">The LinearDensity measurement to divide.</param> |
| | 11181 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 11182 | | /// <returns>The result of the division.</returns> |
| | 11183 | | public static LinearDensity<T> operator /(LinearDensity<T> a, T b) |
| | 11184 | | { |
| | 11185 | | return Divide(a, b); |
| | 11186 | | } |
| | 11187 | |
|
| | 11188 | | /// <summary>Divides this LinearDensity measurement by a numaric scalar value.</summary> |
| | 11189 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 11190 | | /// <returns>The result of the division.</returns> |
| | 11191 | | public LinearDensity<T> Divide(T b) |
| | 11192 | | { |
| | 11193 | | return this / b; |
| | 11194 | | } |
| | 11195 | |
|
| | 11196 | | /// <summary>Divides an LinearDensity measurement by another LinearDensity measurement resulting in a scalar numeric |
| | 11197 | | /// <param name="a">The first operand of the division operation.</param> |
| | 11198 | | /// <param name="b">The second operand of the division operation.</param> |
| | 11199 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 11200 | | public static T operator /(LinearDensity<T> a, LinearDensity<T> b) |
| | 11201 | | { |
| | 11202 | | return Divide(a, b); |
| | 11203 | | } |
| | 11204 | |
|
| | 11205 | | /// <summary>Divides an LinearDensity measurement by another LinearDensity measurement resulting in a scalar numeric |
| | 11206 | | /// <param name="b">The second operand of the division operation.</param> |
| | 11207 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 11208 | | public T Divide(LinearDensity<T> b) |
| | 11209 | | { |
| | 11210 | | return this / b; |
| | 11211 | | } |
| | 11212 | |
|
| | 11213 | |
|
| | 11214 | | #region LinearDensity<T> / Area<T> = Density<T> |
| | 11215 | |
|
| | 11216 | | /// <summary>Divides LinearDensity by Area resulting in Density.</summary> |
| | 11217 | | /// <param name="a">The LinearDensity to be divided.</param> |
| | 11218 | | /// <param name="b">The Area to divide by.</param> |
| | 11219 | | /// <returns>The Density result of the division.</returns> |
| | 11220 | | public static Density<T> Divide(LinearDensity<T> a, Area<T> b) |
| | 11221 | | { |
| | 11222 | |
|
| | 11223 | | T A = a[a._MassUnits1, a._LengthUnits2]; |
| | 11224 | | T B = b[b._LengthUnits1, b._LengthUnits2]; |
| | 11225 | | T C = Statics.Division(A, B); |
| | 11226 | |
|
| | 11227 | | return new Density<T>(C |
| | 11228 | | , a._MassUnits1 |
| | 11229 | | , a._LengthUnits2 |
| | 11230 | | , b._LengthUnits1 |
| | 11231 | | , b._LengthUnits2 |
| | 11232 | | ); |
| | 11233 | | } |
| | 11234 | |
|
| | 11235 | | /// <summary>Divides LinearDensity by Area resulting in Density.</summary> |
| | 11236 | | /// <param name="a">The LinearDensity to be divided.</param> |
| | 11237 | | /// <param name="b">The Area to divide by.</param> |
| | 11238 | | /// <returns>The Density result of the division.</returns> |
| | 11239 | | public static Density<T> operator /(LinearDensity<T> a, Area<T> b) |
| | 11240 | | { |
| | 11241 | | return Divide(a, b); |
| | 11242 | | } |
| | 11243 | |
|
| | 11244 | | /// <summary>Divides LinearDensity by Area resulting in Density.</summary> |
| | 11245 | | /// <param name="b">The Area to divide by.</param> |
| | 11246 | | /// <returns>The Density result of the division.</returns> |
| | 11247 | | public Density<T> Divide(Area<T> b) |
| | 11248 | | { |
| | 11249 | | return this / b; |
| | 11250 | | } |
| | 11251 | |
|
| | 11252 | | #endregion |
| | 11253 | |
|
| | 11254 | |
|
| | 11255 | | #region LinearDensity<T> / AreaDensity<T> = Length<T> |
| | 11256 | |
|
| | 11257 | | /// <summary>Divides LinearDensity by AreaDensity resulting in Length.</summary> |
| | 11258 | | /// <param name="a">The LinearDensity to be divided.</param> |
| | 11259 | | /// <param name="b">The AreaDensity to divide by.</param> |
| | 11260 | | /// <returns>The Length result of the division.</returns> |
| | 11261 | | public static Length<T> Divide(LinearDensity<T> a, AreaDensity<T> b) |
| | 11262 | | { |
| | 11263 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 11264 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 11265 | |
|
| | 11266 | | T A = a[MassUnits1, LengthUnits2]; |
| | 11267 | | T B = b[MassUnits1, LengthUnits2, b._LengthUnits3]; |
| | 11268 | | T C = Statics.Division(A, B); |
| | 11269 | |
|
| | 11270 | | return new Length<T>(C |
| | 11271 | | , b._LengthUnits3 |
| | 11272 | | ); |
| | 11273 | | } |
| | 11274 | |
|
| | 11275 | | /// <summary>Divides LinearDensity by AreaDensity resulting in Length.</summary> |
| | 11276 | | /// <param name="a">The LinearDensity to be divided.</param> |
| | 11277 | | /// <param name="b">The AreaDensity to divide by.</param> |
| | 11278 | | /// <returns>The Length result of the division.</returns> |
| | 11279 | | public static Length<T> operator /(LinearDensity<T> a, AreaDensity<T> b) |
| | 11280 | | { |
| | 11281 | | return Divide(a, b); |
| | 11282 | | } |
| | 11283 | |
|
| | 11284 | | /// <summary>Divides LinearDensity by AreaDensity resulting in Length.</summary> |
| | 11285 | | /// <param name="b">The AreaDensity to divide by.</param> |
| | 11286 | | /// <returns>The Length result of the division.</returns> |
| | 11287 | | public Length<T> Divide(AreaDensity<T> b) |
| | 11288 | | { |
| | 11289 | | return this / b; |
| | 11290 | | } |
| | 11291 | |
|
| | 11292 | | #endregion |
| | 11293 | |
|
| | 11294 | |
|
| | 11295 | | #region LinearDensity<T> / Density<T> = Area<T> |
| | 11296 | |
|
| | 11297 | | /// <summary>Divides LinearDensity by Density resulting in Area.</summary> |
| | 11298 | | /// <param name="a">The LinearDensity to be divided.</param> |
| | 11299 | | /// <param name="b">The Density to divide by.</param> |
| | 11300 | | /// <returns>The Area result of the division.</returns> |
| | 11301 | | public static Area<T> Divide(LinearDensity<T> a, Density<T> b) |
| | 11302 | | { |
| | 11303 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 11304 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 11305 | |
|
| | 11306 | | T A = a[MassUnits1, LengthUnits2]; |
| | 11307 | | T B = b[MassUnits1, LengthUnits2, b._LengthUnits3, b._LengthUnits4]; |
| | 11308 | | T C = Statics.Division(A, B); |
| | 11309 | |
|
| | 11310 | | return new Area<T>(C |
| | 11311 | | , b._LengthUnits3 |
| | 11312 | | , b._LengthUnits4 |
| | 11313 | | ); |
| | 11314 | | } |
| | 11315 | |
|
| | 11316 | | /// <summary>Divides LinearDensity by Density resulting in Area.</summary> |
| | 11317 | | /// <param name="a">The LinearDensity to be divided.</param> |
| | 11318 | | /// <param name="b">The Density to divide by.</param> |
| | 11319 | | /// <returns>The Area result of the division.</returns> |
| | 11320 | | public static Area<T> operator /(LinearDensity<T> a, Density<T> b) |
| | 11321 | | { |
| | 11322 | | return Divide(a, b); |
| | 11323 | | } |
| | 11324 | |
|
| | 11325 | | /// <summary>Divides LinearDensity by Density resulting in Area.</summary> |
| | 11326 | | /// <param name="b">The Density to divide by.</param> |
| | 11327 | | /// <returns>The Area result of the division.</returns> |
| | 11328 | | public Area<T> Divide(Density<T> b) |
| | 11329 | | { |
| | 11330 | | return this / b; |
| | 11331 | | } |
| | 11332 | |
|
| | 11333 | | #endregion |
| | 11334 | |
|
| | 11335 | |
|
| | 11336 | | #region LinearDensity<T> / Length<T> = AreaDensity<T> |
| | 11337 | |
|
| | 11338 | | /// <summary>Divides LinearDensity by Length resulting in AreaDensity.</summary> |
| | 11339 | | /// <param name="a">The LinearDensity to be divided.</param> |
| | 11340 | | /// <param name="b">The Length to divide by.</param> |
| | 11341 | | /// <returns>The AreaDensity result of the division.</returns> |
| | 11342 | | public static AreaDensity<T> Divide(LinearDensity<T> a, Length<T> b) |
| | 11343 | | { |
| | 11344 | |
|
| | 11345 | | T A = a[a._MassUnits1, a._LengthUnits2]; |
| | 11346 | | T B = b[b._LengthUnits1]; |
| | 11347 | | T C = Statics.Division(A, B); |
| | 11348 | |
|
| | 11349 | | return new AreaDensity<T>(C |
| | 11350 | | , a._MassUnits1 |
| | 11351 | | , a._LengthUnits2 |
| | 11352 | | , b._LengthUnits1 |
| | 11353 | | ); |
| | 11354 | | } |
| | 11355 | |
|
| | 11356 | | /// <summary>Divides LinearDensity by Length resulting in AreaDensity.</summary> |
| | 11357 | | /// <param name="a">The LinearDensity to be divided.</param> |
| | 11358 | | /// <param name="b">The Length to divide by.</param> |
| | 11359 | | /// <returns>The AreaDensity result of the division.</returns> |
| | 11360 | | public static AreaDensity<T> operator /(LinearDensity<T> a, Length<T> b) |
| | 11361 | | { |
| | 11362 | | return Divide(a, b); |
| | 11363 | | } |
| | 11364 | |
|
| | 11365 | | /// <summary>Divides LinearDensity by Length resulting in AreaDensity.</summary> |
| | 11366 | | /// <param name="b">The Length to divide by.</param> |
| | 11367 | | /// <returns>The AreaDensity result of the division.</returns> |
| | 11368 | | public AreaDensity<T> Divide(Length<T> b) |
| | 11369 | | { |
| | 11370 | | return this / b; |
| | 11371 | | } |
| | 11372 | |
|
| | 11373 | | #endregion |
| | 11374 | |
|
| | 11375 | |
|
| | 11376 | | #region LinearDensity<T> / Pressure<T> = TimeArea<T> |
| | 11377 | |
|
| | 11378 | | /// <summary>Divides LinearDensity by Pressure resulting in TimeArea.</summary> |
| | 11379 | | /// <param name="a">The LinearDensity to be divided.</param> |
| | 11380 | | /// <param name="b">The Pressure to divide by.</param> |
| | 11381 | | /// <returns>The TimeArea result of the division.</returns> |
| | 11382 | | public static TimeArea<T> Divide(LinearDensity<T> a, Pressure<T> b) |
| | 11383 | | { |
| | 11384 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 11385 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 11386 | |
|
| | 11387 | | T A = a[MassUnits1, LengthUnits2]; |
| | 11388 | | T B = b[MassUnits1, LengthUnits2, b._TimeUnits3, b._TimeUnits4]; |
| | 11389 | | T C = Statics.Division(A, B); |
| | 11390 | |
|
| | 11391 | | return new TimeArea<T>(C |
| | 11392 | | , b._TimeUnits3 |
| | 11393 | | , b._TimeUnits4 |
| | 11394 | | ); |
| | 11395 | | } |
| | 11396 | |
|
| | 11397 | | /// <summary>Divides LinearDensity by Pressure resulting in TimeArea.</summary> |
| | 11398 | | /// <param name="a">The LinearDensity to be divided.</param> |
| | 11399 | | /// <param name="b">The Pressure to divide by.</param> |
| | 11400 | | /// <returns>The TimeArea result of the division.</returns> |
| | 11401 | | public static TimeArea<T> operator /(LinearDensity<T> a, Pressure<T> b) |
| | 11402 | | { |
| | 11403 | | return Divide(a, b); |
| | 11404 | | } |
| | 11405 | |
|
| | 11406 | | /// <summary>Divides LinearDensity by Pressure resulting in TimeArea.</summary> |
| | 11407 | | /// <param name="b">The Pressure to divide by.</param> |
| | 11408 | | /// <returns>The TimeArea result of the division.</returns> |
| | 11409 | | public TimeArea<T> Divide(Pressure<T> b) |
| | 11410 | | { |
| | 11411 | | return this / b; |
| | 11412 | | } |
| | 11413 | |
|
| | 11414 | | #endregion |
| | 11415 | |
|
| | 11416 | |
|
| | 11417 | | #region LinearDensity<T> / TimeArea<T> = Pressure<T> |
| | 11418 | |
|
| | 11419 | | /// <summary>Divides LinearDensity by TimeArea resulting in Pressure.</summary> |
| | 11420 | | /// <param name="a">The LinearDensity to be divided.</param> |
| | 11421 | | /// <param name="b">The TimeArea to divide by.</param> |
| | 11422 | | /// <returns>The Pressure result of the division.</returns> |
| | 11423 | | public static Pressure<T> Divide(LinearDensity<T> a, TimeArea<T> b) |
| | 11424 | | { |
| | 11425 | |
|
| | 11426 | | T A = a[a._MassUnits1, a._LengthUnits2]; |
| | 11427 | | T B = b[b._TimeUnits1, b._TimeUnits2]; |
| | 11428 | | T C = Statics.Division(A, B); |
| | 11429 | |
|
| | 11430 | | return new Pressure<T>(C |
| | 11431 | | , a._MassUnits1 |
| | 11432 | | , a._LengthUnits2 |
| | 11433 | | , b._TimeUnits1 |
| | 11434 | | , b._TimeUnits2 |
| | 11435 | | ); |
| | 11436 | | } |
| | 11437 | |
|
| | 11438 | | /// <summary>Divides LinearDensity by TimeArea resulting in Pressure.</summary> |
| | 11439 | | /// <param name="a">The LinearDensity to be divided.</param> |
| | 11440 | | /// <param name="b">The TimeArea to divide by.</param> |
| | 11441 | | /// <returns>The Pressure result of the division.</returns> |
| | 11442 | | public static Pressure<T> operator /(LinearDensity<T> a, TimeArea<T> b) |
| | 11443 | | { |
| | 11444 | | return Divide(a, b); |
| | 11445 | | } |
| | 11446 | |
|
| | 11447 | | /// <summary>Divides LinearDensity by TimeArea resulting in Pressure.</summary> |
| | 11448 | | /// <param name="b">The TimeArea to divide by.</param> |
| | 11449 | | /// <returns>The Pressure result of the division.</returns> |
| | 11450 | | public Pressure<T> Divide(TimeArea<T> b) |
| | 11451 | | { |
| | 11452 | | return this / b; |
| | 11453 | | } |
| | 11454 | |
|
| | 11455 | | #endregion |
| | 11456 | |
|
| | 11457 | | #endregion |
| | 11458 | |
|
| | 11459 | | #region LessThan |
| | 11460 | |
|
| | 11461 | | /// <summary>Determines if an LinearDensity measurement is less than another LinearDensity measurement.</summary> |
| | 11462 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 11463 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 11464 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 11465 | | public static bool LessThan(LinearDensity<T> a, LinearDensity<T> b) |
| | 11466 | | { |
| | 11467 | | return LogicBase(a, b, Statics.LessThan); |
| | 11468 | | } |
| | 11469 | |
|
| | 11470 | | /// <summary>Determines if an LinearDensity measurement is less than another LinearDensity measurement.</summary> |
| | 11471 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 11472 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 11473 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 11474 | | public static bool operator <(LinearDensity<T> a, LinearDensity<T> b) |
| | 11475 | | { |
| | 11476 | | return LessThan(a, b); |
| | 11477 | | } |
| | 11478 | |
|
| | 11479 | | /// <summary>Determines if an LinearDensity measurement is less than another LinearDensity measurement.</summary> |
| | 11480 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 11481 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 11482 | | public bool LessThan(LinearDensity<T> b) |
| | 11483 | | { |
| | 11484 | | return this < b; |
| | 11485 | | } |
| | 11486 | |
|
| | 11487 | | #endregion |
| | 11488 | |
|
| | 11489 | | #region GreaterThan |
| | 11490 | |
|
| | 11491 | | /// <summary>Determines if an LinearDensity measurement is greater than another LinearDensity measurement.</summary> |
| | 11492 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 11493 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 11494 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 11495 | | public static bool GreaterThan(LinearDensity<T> a, LinearDensity<T> b) |
| | 11496 | | { |
| | 11497 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 11498 | | } |
| | 11499 | |
|
| | 11500 | | /// <summary>Determines if an LinearDensity measurement is greater than another LinearDensity measurement.</summary> |
| | 11501 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 11502 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 11503 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 11504 | | public static bool operator >(LinearDensity<T> a, LinearDensity<T> b) |
| | 11505 | | { |
| | 11506 | | return GreaterThan(a, b); |
| | 11507 | | } |
| | 11508 | |
|
| | 11509 | | /// <summary>Determines if an LinearDensity measurement is greater than another LinearDensity measurement.</summary> |
| | 11510 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 11511 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 11512 | | public bool GreaterThan(LinearDensity<T> b) |
| | 11513 | | { |
| | 11514 | | return this > b; |
| | 11515 | | } |
| | 11516 | |
|
| | 11517 | | #endregion |
| | 11518 | |
|
| | 11519 | | #region LessThanOrEqual |
| | 11520 | |
|
| | 11521 | | /// <summary>Determines if an LinearDensity measurement is less than or equal to another LinearDensity measurement.< |
| | 11522 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 11523 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 11524 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 11525 | | public static bool LessThanOrEqual(LinearDensity<T> a, LinearDensity<T> b) |
| | 11526 | | { |
| | 11527 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 11528 | | } |
| | 11529 | |
|
| | 11530 | | /// <summary>Determines if an LinearDensity measurement is less than or equal to another LinearDensity measurement.< |
| | 11531 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 11532 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 11533 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 11534 | | public static bool operator <=(LinearDensity<T> a, LinearDensity<T> b) |
| | 11535 | | { |
| | 11536 | | return LessThanOrEqual(a, b); |
| | 11537 | | } |
| | 11538 | |
|
| | 11539 | | /// <summary>Determines if an LinearDensity measurement is less than or equal to another LinearDensity measurement.< |
| | 11540 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 11541 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 11542 | | public bool LessThanOrEqual(LinearDensity<T> b) |
| | 11543 | | { |
| | 11544 | | return this <= b; |
| | 11545 | | } |
| | 11546 | |
|
| | 11547 | | #endregion |
| | 11548 | |
|
| | 11549 | | #region GreaterThanOrEqual |
| | 11550 | |
|
| | 11551 | | /// <summary>Determines if an LinearDensity measurement is greater than or equal to another LinearDensity measuremen |
| | 11552 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 11553 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 11554 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 11555 | | public static bool GreaterThanOrEqual(LinearDensity<T> a, LinearDensity<T> b) |
| | 11556 | | { |
| | 11557 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 11558 | | } |
| | 11559 | |
|
| | 11560 | | /// <summary>Determines if an LinearDensity measurement is greater than or equal to another LinearDensity measuremen |
| | 11561 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 11562 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 11563 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 11564 | | public static bool operator >=(LinearDensity<T> a, LinearDensity<T> b) |
| | 11565 | | { |
| | 11566 | | return GreaterThanOrEqual(a, b); |
| | 11567 | | } |
| | 11568 | |
|
| | 11569 | | /// <summary>Determines if an LinearDensity measurement is greater than or equal to another LinearDensity measuremen |
| | 11570 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 11571 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 11572 | | public bool GreaterThanOrEqual(LinearDensity<T> b) |
| | 11573 | | { |
| | 11574 | | return this >= b; |
| | 11575 | | } |
| | 11576 | |
|
| | 11577 | | #endregion |
| | 11578 | |
|
| | 11579 | | #region Equal |
| | 11580 | |
|
| | 11581 | | /// <summary>Determines if an LinearDensity measurement is equal to another LinearDensity measurement.</summary> |
| | 11582 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 11583 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 11584 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 11585 | | public static bool Equal(LinearDensity<T> a, LinearDensity<T> b) |
| | 11586 | | { |
| | 11587 | | return LogicBase(a, b, Statics.Equate); |
| | 11588 | | } |
| | 11589 | |
|
| | 11590 | | /// <summary>Determines if an LinearDensity measurement is equal to another LinearDensity measurement.</summary> |
| | 11591 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 11592 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 11593 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 11594 | | public static bool operator ==(LinearDensity<T> a, LinearDensity<T> b) |
| | 11595 | | { |
| | 11596 | | return Equal(a, b); |
| | 11597 | | } |
| | 11598 | |
|
| | 11599 | | /// <summary>Determines if an LinearDensity measurement is equal to another LinearDensity measurement.</summary> |
| | 11600 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 11601 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 11602 | | public bool Equal(LinearDensity<T> b) |
| | 11603 | | { |
| | 11604 | | return this == b; |
| | 11605 | | } |
| | 11606 | |
|
| | 11607 | | #endregion |
| | 11608 | |
|
| | 11609 | | #region NotEqual |
| | 11610 | |
|
| | 11611 | | /// <summary>Determines if an LinearDensity measurement is not equal to another LinearDensity measurement.</summary> |
| | 11612 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 11613 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 11614 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 11615 | | public static bool NotEqual(LinearDensity<T> a, LinearDensity<T> b) |
| | 11616 | | { |
| | 11617 | | return LogicBase(a, b, Statics.Inequate); |
| | 11618 | | } |
| | 11619 | |
|
| | 11620 | | /// <summary>Determines if an LinearDensity measurement is not equal to another LinearDensity measurement.</summary> |
| | 11621 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 11622 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 11623 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 11624 | | public static bool operator !=(LinearDensity<T> a, LinearDensity<T> b) |
| | 11625 | | { |
| | 11626 | | return NotEqual(a, b); |
| | 11627 | | } |
| | 11628 | |
|
| | 11629 | | /// <summary>Determines if an LinearDensity measurement is not equal to another LinearDensity measurement.</summary> |
| | 11630 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 11631 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 11632 | | public bool NotEqual(LinearDensity<T> b) |
| | 11633 | | { |
| | 11634 | | return this != b; |
| | 11635 | | } |
| | 11636 | |
|
| | 11637 | | #endregion |
| | 11638 | |
|
| | 11639 | | #endregion |
| | 11640 | |
|
| | 11641 | | #region Overrides |
| | 11642 | |
|
| | 11643 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 11644 | | /// <param name="obj">The object to check for equality with.</param> |
| | 11645 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 11646 | | public override bool Equals(object obj) |
| | 11647 | | { |
| | 11648 | | if (obj is LinearDensity<T>) |
| | 11649 | | { |
| | 11650 | | return this == (LinearDensity<T>)obj; |
| | 11651 | | } |
| | 11652 | | return false; |
| | 11653 | | } |
| | 11654 | |
|
| | 11655 | | /// <summary>Converts the LinearDensity measurement to a string represenation.</summary> |
| | 11656 | | /// <returns>The string representation of the measurement.</returns> |
| | 11657 | | public override string ToString() |
| | 11658 | | { |
| | 11659 | | return _measurement + " " + |
| | 11660 | | _MassUnits1 |
| | 11661 | | + "/" + |
| | 11662 | | _LengthUnits2 |
| | 11663 | | ; |
| | 11664 | | } |
| | 11665 | |
|
| | 11666 | | /// <summary>Base hashing function for LinearDensity measurements.</summary> |
| | 11667 | | /// <returns>Computed hash code for this instance.</returns> |
| | 11668 | | public override int GetHashCode() => Hash(_measurement); |
| | 11669 | |
|
| | 11670 | | #endregion |
| | 11671 | | } |
| | 11672 | |
|
| | 11673 | | #endregion |
| | 11674 | |
|
| | 11675 | | #region LinearMass |
| | 11676 | |
|
| | 11677 | | internal static partial class ParsingFunctions |
| | 11678 | | { |
| | 11679 | | [Measurement.Parseable("Mass*Length")] |
| | 11680 | | public static object LinearMass<T>(T value, object[] units) |
| | 11681 | | { |
| | 11682 | | if (units.Length != 2) |
| | 11683 | | { |
| | 11684 | | throw new Exception("Bug in Towel. Invalid parameters to LinearMass Factory."); |
| | 11685 | | } |
| | 11686 | | if (!(units[0] is Mass.Units)) |
| | 11687 | | { |
| | 11688 | | throw new Exception("Bug in Towel. Invalid parameters to LinearMass Factory."); |
| | 11689 | | } |
| | 11690 | | if (!(units[1] is Length.Units)) |
| | 11691 | | { |
| | 11692 | | throw new Exception("Bug in Towel. Invalid parameters to LinearMass Factory."); |
| | 11693 | | } |
| | 11694 | | return new LinearMass<T>(value |
| | 11695 | | , (Mass.Units)units[0] |
| | 11696 | | , (Length.Units)units[1] |
| | 11697 | | ); |
| | 11698 | | } |
| | 11699 | | } |
| | 11700 | |
|
| | 11701 | | /// <summary>LinearMass measurement with a value and the units.</summary> |
| | 11702 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 11703 | | public struct LinearMass<T> |
| | 11704 | | { |
| | 11705 | | internal T _measurement; |
| | 11706 | | internal Mass.Units _MassUnits1; |
| | 11707 | | internal Length.Units _LengthUnits2; |
| | 11708 | |
|
| | 11709 | | #region Statics |
| | 11710 | |
|
| | 11711 | | /// <summary>Converts a LinearMass measurement from units to another.</summary> |
| | 11712 | | /// <param name="value">The value to convert the units of.</param> |
| | 11713 | | /// <param name="fromMassUnits1">The current units of the measurement.</param> |
| | 11714 | | /// <param name="fromLengthUnits2">The current units of the measurement.</param> |
| | 11715 | | /// <param name="toMassUnits1">The desired units of the measurement.</param> |
| | 11716 | | /// <param name="toLengthUnits2">The desired units of the measurement.</param> |
| | 11717 | | /// <returns>The LinearMass measurement converted into the desired units.</returns> |
| | 11718 | | public static T Convert(T value |
| | 11719 | | , Mass.Units fromMassUnits1 |
| | 11720 | | , Length.Units fromLengthUnits2 |
| | 11721 | | , Mass.Units toMassUnits1 |
| | 11722 | | , Length.Units toLengthUnits2 |
| | 11723 | | ) |
| | 11724 | | { |
| | 11725 | | LinearMass<T> measurement = new LinearMass<T>(value |
| | 11726 | | , fromMassUnits1 |
| | 11727 | | , fromLengthUnits2 |
| | 11728 | | ); |
| | 11729 | | return measurement[ |
| | 11730 | | toMassUnits1 |
| | 11731 | | , toLengthUnits2 |
| | 11732 | | ]; |
| | 11733 | | } |
| | 11734 | |
|
| | 11735 | | /// <summary>Converts a LinearMass measurement from units to another.</summary> |
| | 11736 | | /// <param name="value">The value to convert the units of.</param> |
| | 11737 | | /// <param name="from">The current units of the measurement.</param> |
| | 11738 | | /// <param name="to">The desired units of the measurement.</param> |
| | 11739 | | /// <returns>The LinearMass measurement converted into the desired units.</returns> |
| | 11740 | | public static T Convert(T value, |
| | 11741 | | MeasurementUnitsSyntaxTypes.LinearMassBaseUnits from, |
| | 11742 | | MeasurementUnitsSyntaxTypes.LinearMassBaseUnits to) |
| | 11743 | | { |
| | 11744 | | return Convert(value |
| | 11745 | | , from._MassUnits1 |
| | 11746 | | , from._LengthUnits2 |
| | 11747 | | , to._MassUnits1 |
| | 11748 | | , to._LengthUnits2 |
| | 11749 | | ); |
| | 11750 | | } |
| | 11751 | |
|
| | 11752 | | /// <summary>Parses a LinearMass measurement string.</summary> |
| | 11753 | | /// <param name="string">The string to be parsed.</param> |
| | 11754 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 11755 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 11756 | | public static (bool Success, LinearMass<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value)> tr |
| | 11757 | |
|
| | 11758 | | #endregion |
| | 11759 | |
|
| | 11760 | | #region Constructors |
| | 11761 | |
|
| | 11762 | | /// <summary>Constructs an LinearMass with the measurement value and units.</summary> |
| | 11763 | | /// <param name="measurement">The measurement value of the LinearMass.</param> |
| | 11764 | | /// <param name="units">The units of the LinearMass.</param> |
| | 11765 | | public LinearMass(T measurement, MeasurementUnitsSyntaxTypes.LinearMassBaseUnits units) : this(measurement |
| | 11766 | | , units._MassUnits1 |
| | 11767 | | , units._LengthUnits2 |
| | 11768 | | ) { } |
| | 11769 | |
|
| | 11770 | |
|
| | 11771 | | /// <summary>Constructs an LinearMass with the measurement value and units.</summary> |
| | 11772 | | /// <param name="measurement">The measurement value of the LinearMass.</param> |
| | 11773 | | /// <param name="MassUnits1">The units of the LinearMass.</param> |
| | 11774 | | /// <param name="LengthUnits2">The units of the LinearMass.</param> |
| | 11775 | | public LinearMass(T measurement |
| | 11776 | | , Mass.Units MassUnits1 |
| | 11777 | | , Length.Units LengthUnits2 |
| | 11778 | | ) |
| | 11779 | | { |
| | 11780 | | _measurement = measurement; |
| | 11781 | | _MassUnits1 = MassUnits1; |
| | 11782 | | _LengthUnits2 = LengthUnits2; |
| | 11783 | | } |
| | 11784 | |
|
| | 11785 | | #endregion |
| | 11786 | |
|
| | 11787 | | #region Properties |
| | 11788 | |
|
| | 11789 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 11790 | | public Mass.Units MassUnits1 |
| | 11791 | | { |
| | 11792 | | get { return _MassUnits1; } |
| | 11793 | | set |
| | 11794 | | { |
| | 11795 | | if (value != _MassUnits1) |
| | 11796 | | { |
| | 11797 | | _measurement = this[value, _LengthUnits2]; |
| | 11798 | | _MassUnits1 = value; |
| | 11799 | | } |
| | 11800 | | } |
| | 11801 | | } |
| | 11802 | |
|
| | 11803 | | /// <summary>The #2 component of this measurements units.</summary> |
| | 11804 | | public Length.Units LengthUnits2 |
| | 11805 | | { |
| | 11806 | | get { return _LengthUnits2; } |
| | 11807 | | set |
| | 11808 | | { |
| | 11809 | | if (value != _LengthUnits2) |
| | 11810 | | { |
| | 11811 | | _measurement = this[_MassUnits1, value]; |
| | 11812 | | _LengthUnits2 = value; |
| | 11813 | | } |
| | 11814 | | } |
| | 11815 | | } |
| | 11816 | |
|
| | 11817 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 11818 | | /// <param name="units">The units to get the measurement in.</param> |
| | 11819 | | /// <returns>The measurement value in the specified units.</returns> |
| | 11820 | | public T this[MeasurementUnitsSyntaxTypes.LinearMassBaseUnits units] |
| | 11821 | | { |
| | 11822 | | get { return this[units._MassUnits1, units._LengthUnits2]; } |
| | 11823 | | } |
| | 11824 | |
|
| | 11825 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 11826 | | /// <param name="MassUnits1">The #1 component of this measurements units.</param> |
| | 11827 | | /// <param name="LengthUnits2">The #2 component of this measurements units.</param> |
| | 11828 | | /// <returns>The measurement value in the specified units.</returns> |
| | 11829 | | public T this[Mass.Units MassUnits1, Length.Units LengthUnits2] |
| | 11830 | | { |
| | 11831 | | get |
| | 11832 | | { |
| | 11833 | | T measurement = _measurement; |
| | 11834 | | if (MassUnits1 != _MassUnits1) |
| | 11835 | | { |
| | 11836 | | measurement = Mass<T>.Table[(int)_MassUnits1][(int)MassUnits1](measurement); |
| | 11837 | | //if (MassUnits1 < _MassUnits1) |
| | 11838 | | //{ |
| | 11839 | | // measurement = Mass<T>.Table[(int)_MassUnits1][(int)MassUnits1](measurement); |
| | 11840 | | //} |
| | 11841 | | //else |
| | 11842 | | //{ |
| | 11843 | | // measurement = Mass<T>.Table[(int)MassUnits1][(int)_MassUnits1](measurement); |
| | 11844 | | //} |
| | 11845 | | } |
| | 11846 | | if (LengthUnits2 != _LengthUnits2) |
| | 11847 | | { |
| | 11848 | | measurement = Length<T>.Table[(int)_LengthUnits2][(int)LengthUnits2](measurement); |
| | 11849 | | //if (LengthUnits2 < _LengthUnits2) |
| | 11850 | | //{ |
| | 11851 | | // measurement = Length<T>.Table[(int)_LengthUnits2][(int)LengthUnits2](measurement); |
| | 11852 | | //} |
| | 11853 | | //else |
| | 11854 | | //{ |
| | 11855 | | // measurement = Length<T>.Table[(int)LengthUnits2][(int)_LengthUnits2](measurement); |
| | 11856 | | //} |
| | 11857 | | } |
| | 11858 | | return measurement; |
| | 11859 | | } |
| | 11860 | | } |
| | 11861 | |
|
| | 11862 | | #endregion |
| | 11863 | |
|
| | 11864 | | #region Casting Operators |
| | 11865 | |
|
| | 11866 | | /// <summary>Converts a ValueTuple to a LinearMass measurement.</summary> |
| | 11867 | | /// <param name="valueTuple">The ValueTuple to converted into a LinearMass measurement.</param> |
| | 11868 | | public static implicit operator LinearMass<T>((T, MeasurementUnitsSyntaxTypes.LinearMassBaseUnits) valueTuple) |
| | 11869 | | { |
| | 11870 | | return new LinearMass<T>(valueTuple.Item1, valueTuple.Item2); |
| | 11871 | | } |
| | 11872 | |
|
| | 11873 | | #endregion |
| | 11874 | |
|
| | 11875 | | #region Mathematics |
| | 11876 | |
|
| | 11877 | | #region Bases |
| | 11878 | |
|
| | 11879 | | internal static LinearMass<T> MathBase(LinearMass<T> a, T b, Func<T, T, T> func) |
| | 11880 | | { |
| | 11881 | | return new LinearMass<T>(func(a._measurement, b) |
| | 11882 | | , a._MassUnits1 |
| | 11883 | | , a._LengthUnits2 |
| | 11884 | | ); |
| | 11885 | | } |
| | 11886 | |
|
| | 11887 | | internal static LinearMass<T> MathBase(LinearMass<T> a, LinearMass<T> b, Func<T, T, T> func) |
| | 11888 | | { |
| | 11889 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 11890 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 11891 | | T A = a[MassUnits1, LengthUnits2]; |
| | 11892 | | T B = b[MassUnits1, LengthUnits2]; |
| | 11893 | | T C = func(A, B); |
| | 11894 | | return new LinearMass<T>(C, MassUnits1, LengthUnits2); |
| | 11895 | | } |
| | 11896 | |
|
| | 11897 | | internal static bool LogicBase(LinearMass<T> a, LinearMass<T> b, Func<T, T, bool> func) |
| | 11898 | | { |
| | 11899 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 11900 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 11901 | | T A = a[MassUnits1, LengthUnits2]; |
| | 11902 | | T B = b[MassUnits1, LengthUnits2]; |
| | 11903 | | return func(A, B); |
| | 11904 | | } |
| | 11905 | |
|
| | 11906 | | #endregion |
| | 11907 | |
|
| | 11908 | | #region Add |
| | 11909 | |
|
| | 11910 | | /// <summary>Adds two LinearMass measurements.</summary> |
| | 11911 | | /// <param name="a">The first operand of the addition.</param> |
| | 11912 | | /// <param name="b">The second operand of the addition.</param> |
| | 11913 | | /// <returns>The result of the addition operation.</returns> |
| | 11914 | | public static LinearMass<T> Add(LinearMass<T> a, LinearMass<T> b) |
| | 11915 | | { |
| | 11916 | | return MathBase(a, b, Statics.Addition); |
| | 11917 | | } |
| | 11918 | |
|
| | 11919 | | /// <summary>Adds two LinearMass measurements.</summary> |
| | 11920 | | /// <param name="a">The first operand of the addition.</param> |
| | 11921 | | /// <param name="b">The second operand of the addition.</param> |
| | 11922 | | /// <returns>The result of the addition operation.</returns> |
| | 11923 | | public static LinearMass<T> operator +(LinearMass<T> a, LinearMass<T> b) |
| | 11924 | | { |
| | 11925 | | return Add(a, b); |
| | 11926 | | } |
| | 11927 | |
|
| | 11928 | | /// <summary>Adds two LinearMass measurements.</summary> |
| | 11929 | | /// <param name="b">The second operand of the addition.</param> |
| | 11930 | | /// <returns>The result of the addition operation.</returns> |
| | 11931 | | public LinearMass<T> Add(LinearMass<T> b) |
| | 11932 | | { |
| | 11933 | | return this + b; |
| | 11934 | | } |
| | 11935 | |
|
| | 11936 | | #endregion |
| | 11937 | |
|
| | 11938 | | #region Subtract |
| | 11939 | |
|
| | 11940 | | /// <summary>Subtracts two LinearMass measurements.</summary> |
| | 11941 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 11942 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 11943 | | /// <returns>The result of the subtraction.</returns> |
| | 11944 | | public static LinearMass<T> Subtract(LinearMass<T> a, LinearMass<T> b) |
| | 11945 | | { |
| | 11946 | | return MathBase(a, b, Statics.Subtraction); |
| | 11947 | | } |
| | 11948 | |
|
| | 11949 | | /// <summary>Subtracts two LinearMass measurements.</summary> |
| | 11950 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 11951 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 11952 | | /// <returns>The result of the subtraction.</returns> |
| | 11953 | | public static LinearMass<T> operator -(LinearMass<T> a, LinearMass<T> b) |
| | 11954 | | { |
| | 11955 | | return Subtract(a, b); |
| | 11956 | | } |
| | 11957 | |
|
| | 11958 | | /// <summary>Subtracts two LinearMass measurements.</summary> |
| | 11959 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 11960 | | /// <returns>The result of the subtraction.</returns> |
| | 11961 | | public LinearMass<T> Subtract(LinearMass<T> b) |
| | 11962 | | { |
| | 11963 | | return this - b; |
| | 11964 | | } |
| | 11965 | |
|
| | 11966 | | #endregion |
| | 11967 | |
|
| | 11968 | | #region Multiply |
| | 11969 | |
|
| | 11970 | | /// <summary>Multiplies an LinearMass by a scalar numeric value.</summary> |
| | 11971 | | /// <param name="a">The LinearMass measurement to multiply.</param> |
| | 11972 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 11973 | | /// <returns>The result of the multiplication.</returns> |
| | 11974 | | public static LinearMass<T> Multiply(LinearMass<T> a, T b) |
| | 11975 | | { |
| | 11976 | | return MathBase(a, b, Statics.Multiplication); |
| | 11977 | | } |
| | 11978 | |
|
| | 11979 | | /// <summary>Multiplies an LinearMass by a scalar numeric value.</summary> |
| | 11980 | | /// <param name="a">The LinearMass measurement to multiply.</param> |
| | 11981 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 11982 | | /// <returns>The result of the multiplication.</returns> |
| | 11983 | | public static LinearMass<T> Multiply(T b, LinearMass<T> a) |
| | 11984 | | { |
| | 11985 | | return Multiply(a, b); |
| | 11986 | | } |
| | 11987 | |
|
| | 11988 | | /// <summary>Multiplies an LinearMass by a scalar numeric value.</summary> |
| | 11989 | | /// <param name="a">The LinearMass measurement to multiply.</param> |
| | 11990 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 11991 | | /// <returns>The result of the multiplication.</returns> |
| | 11992 | | public static LinearMass<T> operator *(LinearMass<T> a, T b) |
| | 11993 | | { |
| | 11994 | | return Multiply(a, b); |
| | 11995 | | } |
| | 11996 | |
|
| | 11997 | | /// <summary>Multiplies an LinearMass by a scalar numeric value.</summary> |
| | 11998 | | /// <param name="a">The LinearMass measurement to multiply.</param> |
| | 11999 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 12000 | | /// <returns>The result of the multiplication.</returns> |
| | 12001 | | public static LinearMass<T> operator *(T b, LinearMass<T> a) |
| | 12002 | | { |
| | 12003 | | return Multiply(b, a); |
| | 12004 | | } |
| | 12005 | |
|
| | 12006 | | /// <summary>Multiplies an LinearMass by a scalar numeric value.</summary> |
| | 12007 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 12008 | | /// <returns>The result of the multiplication.</returns> |
| | 12009 | | public LinearMass<T> Add(T b) |
| | 12010 | | { |
| | 12011 | | return this * b; |
| | 12012 | | } |
| | 12013 | |
|
| | 12014 | | #region LinearMass<T> * Acceleration<T> = Energy<T> |
| | 12015 | |
|
| | 12016 | | /// <summary>Mulitplies LinearMass by Acceleration resulting in Energy.</summary> |
| | 12017 | | /// <param name="a">The LinearMass to be multiplied.</param> |
| | 12018 | | /// <param name="b">The Acceleration to multiply by.</param> |
| | 12019 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 12020 | | public static Energy<T> Multiply(LinearMass<T> a, Acceleration<T> b) |
| | 12021 | | { |
| | 12022 | |
|
| | 12023 | | T A = a[a._MassUnits1, a._LengthUnits2]; |
| | 12024 | | T B = b[b._LengthUnits1, b._TimeUnits2, b._TimeUnits3]; |
| | 12025 | | T C = Statics.Multiplication(A, B); |
| | 12026 | |
|
| | 12027 | | return new Energy<T>(C |
| | 12028 | | , a._MassUnits1 |
| | 12029 | | , a._LengthUnits2 |
| | 12030 | | , b._LengthUnits1 |
| | 12031 | | , b._TimeUnits2 |
| | 12032 | | , b._TimeUnits3 |
| | 12033 | | ); |
| | 12034 | | } |
| | 12035 | |
|
| | 12036 | | /// <summary>Mulitplies LinearMass by Acceleration resulting in Energy.</summary> |
| | 12037 | | /// <param name="a">The LinearMass to be multiplied.</param> |
| | 12038 | | /// <param name="b">The Acceleration to multiply by.</param> |
| | 12039 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 12040 | | public static Energy<T> operator *(LinearMass<T> a, Acceleration<T> b) |
| | 12041 | | { |
| | 12042 | | return Multiply(a, b); |
| | 12043 | | } |
| | 12044 | |
|
| | 12045 | | /// <summary>Mulitplies LinearMass by Acceleration resulting in Energy.</summary> |
| | 12046 | | /// <param name="b">The Acceleration to multiply by.</param> |
| | 12047 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 12048 | | public Energy<T> Multiply(Acceleration<T> b) |
| | 12049 | | { |
| | 12050 | | return this * b; |
| | 12051 | | } |
| | 12052 | |
|
| | 12053 | | #endregion |
| | 12054 | |
|
| | 12055 | | #endregion |
| | 12056 | |
|
| | 12057 | | #region Divide |
| | 12058 | |
|
| | 12059 | | /// <summary>Divides an LinearMass measurement by another LinearMass measurement resulting in a scalar numeric value |
| | 12060 | | /// <param name="a">The first operand of the division operation.</param> |
| | 12061 | | /// <param name="b">The second operand of the division operation.</param> |
| | 12062 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 12063 | | public static T Divide(LinearMass<T> a, LinearMass<T> b) |
| | 12064 | | { |
| | 12065 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 12066 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 12067 | | T A = a[MassUnits1, LengthUnits2]; |
| | 12068 | | T B = b[MassUnits1, LengthUnits2]; |
| | 12069 | | return Statics.Division(A, B); |
| | 12070 | | } |
| | 12071 | |
|
| | 12072 | | /// <summary>Divides this LinearMass measurement by a numaric scalar value.</summary> |
| | 12073 | | /// <param name="a">The LinearMass measurement to divide.</param> |
| | 12074 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 12075 | | /// <returns>The result of the division.</returns> |
| | 12076 | | public static LinearMass<T> Divide(LinearMass<T> a, T b) |
| | 12077 | | { |
| | 12078 | | return MathBase(a, b, Statics.Division); |
| | 12079 | | } |
| | 12080 | |
|
| | 12081 | | /// <summary>Divides this LinearMass measurement by a numaric scalar value.</summary> |
| | 12082 | | /// <param name="a">The LinearMass measurement to divide.</param> |
| | 12083 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 12084 | | /// <returns>The result of the division.</returns> |
| | 12085 | | public static LinearMass<T> operator /(LinearMass<T> a, T b) |
| | 12086 | | { |
| | 12087 | | return Divide(a, b); |
| | 12088 | | } |
| | 12089 | |
|
| | 12090 | | /// <summary>Divides this LinearMass measurement by a numaric scalar value.</summary> |
| | 12091 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 12092 | | /// <returns>The result of the division.</returns> |
| | 12093 | | public LinearMass<T> Divide(T b) |
| | 12094 | | { |
| | 12095 | | return this / b; |
| | 12096 | | } |
| | 12097 | |
|
| | 12098 | | /// <summary>Divides an LinearMass measurement by another LinearMass measurement resulting in a scalar numeric value |
| | 12099 | | /// <param name="a">The first operand of the division operation.</param> |
| | 12100 | | /// <param name="b">The second operand of the division operation.</param> |
| | 12101 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 12102 | | public static T operator /(LinearMass<T> a, LinearMass<T> b) |
| | 12103 | | { |
| | 12104 | | return Divide(a, b); |
| | 12105 | | } |
| | 12106 | |
|
| | 12107 | | /// <summary>Divides an LinearMass measurement by another LinearMass measurement resulting in a scalar numeric value |
| | 12108 | | /// <param name="b">The second operand of the division operation.</param> |
| | 12109 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 12110 | | public T Divide(LinearMass<T> b) |
| | 12111 | | { |
| | 12112 | | return this / b; |
| | 12113 | | } |
| | 12114 | |
|
| | 12115 | |
|
| | 12116 | | #region LinearMass<T> / Area<T> = LinearDensity<T> |
| | 12117 | |
|
| | 12118 | | /// <summary>Divides LinearMass by Area resulting in LinearDensity.</summary> |
| | 12119 | | /// <param name="a">The LinearMass to be divided.</param> |
| | 12120 | | /// <param name="b">The Area to divide by.</param> |
| | 12121 | | /// <returns>The LinearDensity result of the division.</returns> |
| | 12122 | | public static LinearDensity<T> Divide(LinearMass<T> a, Area<T> b) |
| | 12123 | | { |
| | 12124 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 12125 | |
|
| | 12126 | | T A = a[a._MassUnits1, LengthUnits1]; |
| | 12127 | | T B = b[LengthUnits1, b._LengthUnits2]; |
| | 12128 | | T C = Statics.Division(A, B); |
| | 12129 | |
|
| | 12130 | | return new LinearDensity<T>(C |
| | 12131 | | , a._MassUnits1 |
| | 12132 | | , b._LengthUnits2 |
| | 12133 | | ); |
| | 12134 | | } |
| | 12135 | |
|
| | 12136 | | /// <summary>Divides LinearMass by Area resulting in LinearDensity.</summary> |
| | 12137 | | /// <param name="a">The LinearMass to be divided.</param> |
| | 12138 | | /// <param name="b">The Area to divide by.</param> |
| | 12139 | | /// <returns>The LinearDensity result of the division.</returns> |
| | 12140 | | public static LinearDensity<T> operator /(LinearMass<T> a, Area<T> b) |
| | 12141 | | { |
| | 12142 | | return Divide(a, b); |
| | 12143 | | } |
| | 12144 | |
|
| | 12145 | | /// <summary>Divides LinearMass by Area resulting in LinearDensity.</summary> |
| | 12146 | | /// <param name="b">The Area to divide by.</param> |
| | 12147 | | /// <returns>The LinearDensity result of the division.</returns> |
| | 12148 | | public LinearDensity<T> Divide(Area<T> b) |
| | 12149 | | { |
| | 12150 | | return this / b; |
| | 12151 | | } |
| | 12152 | |
|
| | 12153 | | #endregion |
| | 12154 | |
|
| | 12155 | |
|
| | 12156 | | #region LinearMass<T> / AreaDensity<T> = Volume<T> |
| | 12157 | |
|
| | 12158 | | /// <summary>Divides LinearMass by AreaDensity resulting in Volume.</summary> |
| | 12159 | | /// <param name="a">The LinearMass to be divided.</param> |
| | 12160 | | /// <param name="b">The AreaDensity to divide by.</param> |
| | 12161 | | /// <returns>The Volume result of the division.</returns> |
| | 12162 | | public static Volume<T> Divide(LinearMass<T> a, AreaDensity<T> b) |
| | 12163 | | { |
| | 12164 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 12165 | |
|
| | 12166 | | T A = a[MassUnits1, a._LengthUnits2]; |
| | 12167 | | T B = b[MassUnits1, b._LengthUnits2, b._LengthUnits3]; |
| | 12168 | | T C = Statics.Division(A, B); |
| | 12169 | |
|
| | 12170 | | return new Volume<T>(C |
| | 12171 | | , a._LengthUnits2 |
| | 12172 | | , b._LengthUnits2 |
| | 12173 | | , b._LengthUnits3 |
| | 12174 | | ); |
| | 12175 | | } |
| | 12176 | |
|
| | 12177 | | /// <summary>Divides LinearMass by AreaDensity resulting in Volume.</summary> |
| | 12178 | | /// <param name="a">The LinearMass to be divided.</param> |
| | 12179 | | /// <param name="b">The AreaDensity to divide by.</param> |
| | 12180 | | /// <returns>The Volume result of the division.</returns> |
| | 12181 | | public static Volume<T> operator /(LinearMass<T> a, AreaDensity<T> b) |
| | 12182 | | { |
| | 12183 | | return Divide(a, b); |
| | 12184 | | } |
| | 12185 | |
|
| | 12186 | | /// <summary>Divides LinearMass by AreaDensity resulting in Volume.</summary> |
| | 12187 | | /// <param name="b">The AreaDensity to divide by.</param> |
| | 12188 | | /// <returns>The Volume result of the division.</returns> |
| | 12189 | | public Volume<T> Divide(AreaDensity<T> b) |
| | 12190 | | { |
| | 12191 | | return this / b; |
| | 12192 | | } |
| | 12193 | |
|
| | 12194 | | #endregion |
| | 12195 | |
|
| | 12196 | |
|
| | 12197 | | #region LinearMass<T> / Force<T> = TimeArea<T> |
| | 12198 | |
|
| | 12199 | | /// <summary>Divides LinearMass by Force resulting in TimeArea.</summary> |
| | 12200 | | /// <param name="a">The LinearMass to be divided.</param> |
| | 12201 | | /// <param name="b">The Force to divide by.</param> |
| | 12202 | | /// <returns>The TimeArea result of the division.</returns> |
| | 12203 | | public static TimeArea<T> Divide(LinearMass<T> a, Force<T> b) |
| | 12204 | | { |
| | 12205 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 12206 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 12207 | |
|
| | 12208 | | T A = a[MassUnits1, LengthUnits2]; |
| | 12209 | | T B = b[MassUnits1, LengthUnits2, b._TimeUnits3, b._TimeUnits4]; |
| | 12210 | | T C = Statics.Division(A, B); |
| | 12211 | |
|
| | 12212 | | return new TimeArea<T>(C |
| | 12213 | | , b._TimeUnits3 |
| | 12214 | | , b._TimeUnits4 |
| | 12215 | | ); |
| | 12216 | | } |
| | 12217 | |
|
| | 12218 | | /// <summary>Divides LinearMass by Force resulting in TimeArea.</summary> |
| | 12219 | | /// <param name="a">The LinearMass to be divided.</param> |
| | 12220 | | /// <param name="b">The Force to divide by.</param> |
| | 12221 | | /// <returns>The TimeArea result of the division.</returns> |
| | 12222 | | public static TimeArea<T> operator /(LinearMass<T> a, Force<T> b) |
| | 12223 | | { |
| | 12224 | | return Divide(a, b); |
| | 12225 | | } |
| | 12226 | |
|
| | 12227 | | /// <summary>Divides LinearMass by Force resulting in TimeArea.</summary> |
| | 12228 | | /// <param name="b">The Force to divide by.</param> |
| | 12229 | | /// <returns>The TimeArea result of the division.</returns> |
| | 12230 | | public TimeArea<T> Divide(Force<T> b) |
| | 12231 | | { |
| | 12232 | | return this / b; |
| | 12233 | | } |
| | 12234 | |
|
| | 12235 | | #endregion |
| | 12236 | |
|
| | 12237 | |
|
| | 12238 | | #region LinearMass<T> / Length<T> = Mass<T> |
| | 12239 | |
|
| | 12240 | | /// <summary>Divides LinearMass by Length resulting in Mass.</summary> |
| | 12241 | | /// <param name="a">The LinearMass to be divided.</param> |
| | 12242 | | /// <param name="b">The Length to divide by.</param> |
| | 12243 | | /// <returns>The Mass result of the division.</returns> |
| | 12244 | | public static Mass<T> Divide(LinearMass<T> a, Length<T> b) |
| | 12245 | | { |
| | 12246 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 12247 | |
|
| | 12248 | | T A = a[a._MassUnits1, LengthUnits1]; |
| | 12249 | | T B = b[LengthUnits1]; |
| | 12250 | | T C = Statics.Division(A, B); |
| | 12251 | |
|
| | 12252 | | return new Mass<T>(C |
| | 12253 | | , a._MassUnits1 |
| | 12254 | | ); |
| | 12255 | | } |
| | 12256 | |
|
| | 12257 | | /// <summary>Divides LinearMass by Length resulting in Mass.</summary> |
| | 12258 | | /// <param name="a">The LinearMass to be divided.</param> |
| | 12259 | | /// <param name="b">The Length to divide by.</param> |
| | 12260 | | /// <returns>The Mass result of the division.</returns> |
| | 12261 | | public static Mass<T> operator /(LinearMass<T> a, Length<T> b) |
| | 12262 | | { |
| | 12263 | | return Divide(a, b); |
| | 12264 | | } |
| | 12265 | |
|
| | 12266 | | /// <summary>Divides LinearMass by Length resulting in Mass.</summary> |
| | 12267 | | /// <param name="b">The Length to divide by.</param> |
| | 12268 | | /// <returns>The Mass result of the division.</returns> |
| | 12269 | | public Mass<T> Divide(Length<T> b) |
| | 12270 | | { |
| | 12271 | | return this / b; |
| | 12272 | | } |
| | 12273 | |
|
| | 12274 | | #endregion |
| | 12275 | |
|
| | 12276 | |
|
| | 12277 | | #region LinearMass<T> / LinearDensity<T> = Area<T> |
| | 12278 | |
|
| | 12279 | | /// <summary>Divides LinearMass by LinearDensity resulting in Area.</summary> |
| | 12280 | | /// <param name="a">The LinearMass to be divided.</param> |
| | 12281 | | /// <param name="b">The LinearDensity to divide by.</param> |
| | 12282 | | /// <returns>The Area result of the division.</returns> |
| | 12283 | | public static Area<T> Divide(LinearMass<T> a, LinearDensity<T> b) |
| | 12284 | | { |
| | 12285 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 12286 | |
|
| | 12287 | | T A = a[MassUnits1, a._LengthUnits2]; |
| | 12288 | | T B = b[MassUnits1, b._LengthUnits2]; |
| | 12289 | | T C = Statics.Division(A, B); |
| | 12290 | |
|
| | 12291 | | return new Area<T>(C |
| | 12292 | | , a._LengthUnits2 |
| | 12293 | | , b._LengthUnits2 |
| | 12294 | | ); |
| | 12295 | | } |
| | 12296 | |
|
| | 12297 | | /// <summary>Divides LinearMass by LinearDensity resulting in Area.</summary> |
| | 12298 | | /// <param name="a">The LinearMass to be divided.</param> |
| | 12299 | | /// <param name="b">The LinearDensity to divide by.</param> |
| | 12300 | | /// <returns>The Area result of the division.</returns> |
| | 12301 | | public static Area<T> operator /(LinearMass<T> a, LinearDensity<T> b) |
| | 12302 | | { |
| | 12303 | | return Divide(a, b); |
| | 12304 | | } |
| | 12305 | |
|
| | 12306 | | /// <summary>Divides LinearMass by LinearDensity resulting in Area.</summary> |
| | 12307 | | /// <param name="b">The LinearDensity to divide by.</param> |
| | 12308 | | /// <returns>The Area result of the division.</returns> |
| | 12309 | | public Area<T> Divide(LinearDensity<T> b) |
| | 12310 | | { |
| | 12311 | | return this / b; |
| | 12312 | | } |
| | 12313 | |
|
| | 12314 | | #endregion |
| | 12315 | |
|
| | 12316 | |
|
| | 12317 | | #region LinearMass<T> / LinearMassFlow<T> = Time<T> |
| | 12318 | |
|
| | 12319 | | /// <summary>Divides LinearMass by LinearMassFlow resulting in Time.</summary> |
| | 12320 | | /// <param name="a">The LinearMass to be divided.</param> |
| | 12321 | | /// <param name="b">The LinearMassFlow to divide by.</param> |
| | 12322 | | /// <returns>The Time result of the division.</returns> |
| | 12323 | | public static Time<T> Divide(LinearMass<T> a, LinearMassFlow<T> b) |
| | 12324 | | { |
| | 12325 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 12326 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 12327 | |
|
| | 12328 | | T A = a[MassUnits1, LengthUnits2]; |
| | 12329 | | T B = b[MassUnits1, LengthUnits2, b._TimeUnits3]; |
| | 12330 | | T C = Statics.Division(A, B); |
| | 12331 | |
|
| | 12332 | | return new Time<T>(C |
| | 12333 | | , b._TimeUnits3 |
| | 12334 | | ); |
| | 12335 | | } |
| | 12336 | |
|
| | 12337 | | /// <summary>Divides LinearMass by LinearMassFlow resulting in Time.</summary> |
| | 12338 | | /// <param name="a">The LinearMass to be divided.</param> |
| | 12339 | | /// <param name="b">The LinearMassFlow to divide by.</param> |
| | 12340 | | /// <returns>The Time result of the division.</returns> |
| | 12341 | | public static Time<T> operator /(LinearMass<T> a, LinearMassFlow<T> b) |
| | 12342 | | { |
| | 12343 | | return Divide(a, b); |
| | 12344 | | } |
| | 12345 | |
|
| | 12346 | | /// <summary>Divides LinearMass by LinearMassFlow resulting in Time.</summary> |
| | 12347 | | /// <param name="b">The LinearMassFlow to divide by.</param> |
| | 12348 | | /// <returns>The Time result of the division.</returns> |
| | 12349 | | public Time<T> Divide(LinearMassFlow<T> b) |
| | 12350 | | { |
| | 12351 | | return this / b; |
| | 12352 | | } |
| | 12353 | |
|
| | 12354 | | #endregion |
| | 12355 | |
|
| | 12356 | |
|
| | 12357 | | #region LinearMass<T> / Mass<T> = Length<T> |
| | 12358 | |
|
| | 12359 | | /// <summary>Divides LinearMass by Mass resulting in Length.</summary> |
| | 12360 | | /// <param name="a">The LinearMass to be divided.</param> |
| | 12361 | | /// <param name="b">The Mass to divide by.</param> |
| | 12362 | | /// <returns>The Length result of the division.</returns> |
| | 12363 | | public static Length<T> Divide(LinearMass<T> a, Mass<T> b) |
| | 12364 | | { |
| | 12365 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 12366 | |
|
| | 12367 | | T A = a[MassUnits1, a._LengthUnits2]; |
| | 12368 | | T B = b[MassUnits1]; |
| | 12369 | | T C = Statics.Division(A, B); |
| | 12370 | |
|
| | 12371 | | return new Length<T>(C |
| | 12372 | | , a._LengthUnits2 |
| | 12373 | | ); |
| | 12374 | | } |
| | 12375 | |
|
| | 12376 | | /// <summary>Divides LinearMass by Mass resulting in Length.</summary> |
| | 12377 | | /// <param name="a">The LinearMass to be divided.</param> |
| | 12378 | | /// <param name="b">The Mass to divide by.</param> |
| | 12379 | | /// <returns>The Length result of the division.</returns> |
| | 12380 | | public static Length<T> operator /(LinearMass<T> a, Mass<T> b) |
| | 12381 | | { |
| | 12382 | | return Divide(a, b); |
| | 12383 | | } |
| | 12384 | |
|
| | 12385 | | /// <summary>Divides LinearMass by Mass resulting in Length.</summary> |
| | 12386 | | /// <param name="b">The Mass to divide by.</param> |
| | 12387 | | /// <returns>The Length result of the division.</returns> |
| | 12388 | | public Length<T> Divide(Mass<T> b) |
| | 12389 | | { |
| | 12390 | | return this / b; |
| | 12391 | | } |
| | 12392 | |
|
| | 12393 | | #endregion |
| | 12394 | |
|
| | 12395 | |
|
| | 12396 | | #region LinearMass<T> / Time<T> = LinearMassFlow<T> |
| | 12397 | |
|
| | 12398 | | /// <summary>Divides LinearMass by Time resulting in LinearMassFlow.</summary> |
| | 12399 | | /// <param name="a">The LinearMass to be divided.</param> |
| | 12400 | | /// <param name="b">The Time to divide by.</param> |
| | 12401 | | /// <returns>The LinearMassFlow result of the division.</returns> |
| | 12402 | | public static LinearMassFlow<T> Divide(LinearMass<T> a, Time<T> b) |
| | 12403 | | { |
| | 12404 | |
|
| | 12405 | | T A = a[a._MassUnits1, a._LengthUnits2]; |
| | 12406 | | T B = b[b._TimeUnits1]; |
| | 12407 | | T C = Statics.Division(A, B); |
| | 12408 | |
|
| | 12409 | | return new LinearMassFlow<T>(C |
| | 12410 | | , a._MassUnits1 |
| | 12411 | | , a._LengthUnits2 |
| | 12412 | | , b._TimeUnits1 |
| | 12413 | | ); |
| | 12414 | | } |
| | 12415 | |
|
| | 12416 | | /// <summary>Divides LinearMass by Time resulting in LinearMassFlow.</summary> |
| | 12417 | | /// <param name="a">The LinearMass to be divided.</param> |
| | 12418 | | /// <param name="b">The Time to divide by.</param> |
| | 12419 | | /// <returns>The LinearMassFlow result of the division.</returns> |
| | 12420 | | public static LinearMassFlow<T> operator /(LinearMass<T> a, Time<T> b) |
| | 12421 | | { |
| | 12422 | | return Divide(a, b); |
| | 12423 | | } |
| | 12424 | |
|
| | 12425 | | /// <summary>Divides LinearMass by Time resulting in LinearMassFlow.</summary> |
| | 12426 | | /// <param name="b">The Time to divide by.</param> |
| | 12427 | | /// <returns>The LinearMassFlow result of the division.</returns> |
| | 12428 | | public LinearMassFlow<T> Divide(Time<T> b) |
| | 12429 | | { |
| | 12430 | | return this / b; |
| | 12431 | | } |
| | 12432 | |
|
| | 12433 | | #endregion |
| | 12434 | |
|
| | 12435 | |
|
| | 12436 | | #region LinearMass<T> / TimeArea<T> = Force<T> |
| | 12437 | |
|
| | 12438 | | /// <summary>Divides LinearMass by TimeArea resulting in Force.</summary> |
| | 12439 | | /// <param name="a">The LinearMass to be divided.</param> |
| | 12440 | | /// <param name="b">The TimeArea to divide by.</param> |
| | 12441 | | /// <returns>The Force result of the division.</returns> |
| | 12442 | | public static Force<T> Divide(LinearMass<T> a, TimeArea<T> b) |
| | 12443 | | { |
| | 12444 | |
|
| | 12445 | | T A = a[a._MassUnits1, a._LengthUnits2]; |
| | 12446 | | T B = b[b._TimeUnits1, b._TimeUnits2]; |
| | 12447 | | T C = Statics.Division(A, B); |
| | 12448 | |
|
| | 12449 | | return new Force<T>(C |
| | 12450 | | , a._MassUnits1 |
| | 12451 | | , a._LengthUnits2 |
| | 12452 | | , b._TimeUnits1 |
| | 12453 | | , b._TimeUnits2 |
| | 12454 | | ); |
| | 12455 | | } |
| | 12456 | |
|
| | 12457 | | /// <summary>Divides LinearMass by TimeArea resulting in Force.</summary> |
| | 12458 | | /// <param name="a">The LinearMass to be divided.</param> |
| | 12459 | | /// <param name="b">The TimeArea to divide by.</param> |
| | 12460 | | /// <returns>The Force result of the division.</returns> |
| | 12461 | | public static Force<T> operator /(LinearMass<T> a, TimeArea<T> b) |
| | 12462 | | { |
| | 12463 | | return Divide(a, b); |
| | 12464 | | } |
| | 12465 | |
|
| | 12466 | | /// <summary>Divides LinearMass by TimeArea resulting in Force.</summary> |
| | 12467 | | /// <param name="b">The TimeArea to divide by.</param> |
| | 12468 | | /// <returns>The Force result of the division.</returns> |
| | 12469 | | public Force<T> Divide(TimeArea<T> b) |
| | 12470 | | { |
| | 12471 | | return this / b; |
| | 12472 | | } |
| | 12473 | |
|
| | 12474 | | #endregion |
| | 12475 | |
|
| | 12476 | |
|
| | 12477 | | #region LinearMass<T> / Volume<T> = AreaDensity<T> |
| | 12478 | |
|
| | 12479 | | /// <summary>Divides LinearMass by Volume resulting in AreaDensity.</summary> |
| | 12480 | | /// <param name="a">The LinearMass to be divided.</param> |
| | 12481 | | /// <param name="b">The Volume to divide by.</param> |
| | 12482 | | /// <returns>The AreaDensity result of the division.</returns> |
| | 12483 | | public static AreaDensity<T> Divide(LinearMass<T> a, Volume<T> b) |
| | 12484 | | { |
| | 12485 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 12486 | |
|
| | 12487 | | T A = a[a._MassUnits1, LengthUnits1]; |
| | 12488 | | T B = b[LengthUnits1, b._LengthUnits2, b._LengthUnits3]; |
| | 12489 | | T C = Statics.Division(A, B); |
| | 12490 | |
|
| | 12491 | | return new AreaDensity<T>(C |
| | 12492 | | , a._MassUnits1 |
| | 12493 | | , b._LengthUnits2 |
| | 12494 | | , b._LengthUnits3 |
| | 12495 | | ); |
| | 12496 | | } |
| | 12497 | |
|
| | 12498 | | /// <summary>Divides LinearMass by Volume resulting in AreaDensity.</summary> |
| | 12499 | | /// <param name="a">The LinearMass to be divided.</param> |
| | 12500 | | /// <param name="b">The Volume to divide by.</param> |
| | 12501 | | /// <returns>The AreaDensity result of the division.</returns> |
| | 12502 | | public static AreaDensity<T> operator /(LinearMass<T> a, Volume<T> b) |
| | 12503 | | { |
| | 12504 | | return Divide(a, b); |
| | 12505 | | } |
| | 12506 | |
|
| | 12507 | | /// <summary>Divides LinearMass by Volume resulting in AreaDensity.</summary> |
| | 12508 | | /// <param name="b">The Volume to divide by.</param> |
| | 12509 | | /// <returns>The AreaDensity result of the division.</returns> |
| | 12510 | | public AreaDensity<T> Divide(Volume<T> b) |
| | 12511 | | { |
| | 12512 | | return this / b; |
| | 12513 | | } |
| | 12514 | |
|
| | 12515 | | #endregion |
| | 12516 | |
|
| | 12517 | | #endregion |
| | 12518 | |
|
| | 12519 | | #region LessThan |
| | 12520 | |
|
| | 12521 | | /// <summary>Determines if an LinearMass measurement is less than another LinearMass measurement.</summary> |
| | 12522 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 12523 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 12524 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 12525 | | public static bool LessThan(LinearMass<T> a, LinearMass<T> b) |
| | 12526 | | { |
| | 12527 | | return LogicBase(a, b, Statics.LessThan); |
| | 12528 | | } |
| | 12529 | |
|
| | 12530 | | /// <summary>Determines if an LinearMass measurement is less than another LinearMass measurement.</summary> |
| | 12531 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 12532 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 12533 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 12534 | | public static bool operator <(LinearMass<T> a, LinearMass<T> b) |
| | 12535 | | { |
| | 12536 | | return LessThan(a, b); |
| | 12537 | | } |
| | 12538 | |
|
| | 12539 | | /// <summary>Determines if an LinearMass measurement is less than another LinearMass measurement.</summary> |
| | 12540 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 12541 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 12542 | | public bool LessThan(LinearMass<T> b) |
| | 12543 | | { |
| | 12544 | | return this < b; |
| | 12545 | | } |
| | 12546 | |
|
| | 12547 | | #endregion |
| | 12548 | |
|
| | 12549 | | #region GreaterThan |
| | 12550 | |
|
| | 12551 | | /// <summary>Determines if an LinearMass measurement is greater than another LinearMass measurement.</summary> |
| | 12552 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 12553 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 12554 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 12555 | | public static bool GreaterThan(LinearMass<T> a, LinearMass<T> b) |
| | 12556 | | { |
| | 12557 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 12558 | | } |
| | 12559 | |
|
| | 12560 | | /// <summary>Determines if an LinearMass measurement is greater than another LinearMass measurement.</summary> |
| | 12561 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 12562 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 12563 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 12564 | | public static bool operator >(LinearMass<T> a, LinearMass<T> b) |
| | 12565 | | { |
| | 12566 | | return GreaterThan(a, b); |
| | 12567 | | } |
| | 12568 | |
|
| | 12569 | | /// <summary>Determines if an LinearMass measurement is greater than another LinearMass measurement.</summary> |
| | 12570 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 12571 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 12572 | | public bool GreaterThan(LinearMass<T> b) |
| | 12573 | | { |
| | 12574 | | return this > b; |
| | 12575 | | } |
| | 12576 | |
|
| | 12577 | | #endregion |
| | 12578 | |
|
| | 12579 | | #region LessThanOrEqual |
| | 12580 | |
|
| | 12581 | | /// <summary>Determines if an LinearMass measurement is less than or equal to another LinearMass measurement.</summa |
| | 12582 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 12583 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 12584 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 12585 | | public static bool LessThanOrEqual(LinearMass<T> a, LinearMass<T> b) |
| | 12586 | | { |
| | 12587 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 12588 | | } |
| | 12589 | |
|
| | 12590 | | /// <summary>Determines if an LinearMass measurement is less than or equal to another LinearMass measurement.</summa |
| | 12591 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 12592 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 12593 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 12594 | | public static bool operator <=(LinearMass<T> a, LinearMass<T> b) |
| | 12595 | | { |
| | 12596 | | return LessThanOrEqual(a, b); |
| | 12597 | | } |
| | 12598 | |
|
| | 12599 | | /// <summary>Determines if an LinearMass measurement is less than or equal to another LinearMass measurement.</summa |
| | 12600 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 12601 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 12602 | | public bool LessThanOrEqual(LinearMass<T> b) |
| | 12603 | | { |
| | 12604 | | return this <= b; |
| | 12605 | | } |
| | 12606 | |
|
| | 12607 | | #endregion |
| | 12608 | |
|
| | 12609 | | #region GreaterThanOrEqual |
| | 12610 | |
|
| | 12611 | | /// <summary>Determines if an LinearMass measurement is greater than or equal to another LinearMass measurement.</su |
| | 12612 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 12613 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 12614 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 12615 | | public static bool GreaterThanOrEqual(LinearMass<T> a, LinearMass<T> b) |
| | 12616 | | { |
| | 12617 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 12618 | | } |
| | 12619 | |
|
| | 12620 | | /// <summary>Determines if an LinearMass measurement is greater than or equal to another LinearMass measurement.</su |
| | 12621 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 12622 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 12623 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 12624 | | public static bool operator >=(LinearMass<T> a, LinearMass<T> b) |
| | 12625 | | { |
| | 12626 | | return GreaterThanOrEqual(a, b); |
| | 12627 | | } |
| | 12628 | |
|
| | 12629 | | /// <summary>Determines if an LinearMass measurement is greater than or equal to another LinearMass measurement.</su |
| | 12630 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 12631 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 12632 | | public bool GreaterThanOrEqual(LinearMass<T> b) |
| | 12633 | | { |
| | 12634 | | return this >= b; |
| | 12635 | | } |
| | 12636 | |
|
| | 12637 | | #endregion |
| | 12638 | |
|
| | 12639 | | #region Equal |
| | 12640 | |
|
| | 12641 | | /// <summary>Determines if an LinearMass measurement is equal to another LinearMass measurement.</summary> |
| | 12642 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 12643 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 12644 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 12645 | | public static bool Equal(LinearMass<T> a, LinearMass<T> b) |
| | 12646 | | { |
| | 12647 | | return LogicBase(a, b, Statics.Equate); |
| | 12648 | | } |
| | 12649 | |
|
| | 12650 | | /// <summary>Determines if an LinearMass measurement is equal to another LinearMass measurement.</summary> |
| | 12651 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 12652 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 12653 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 12654 | | public static bool operator ==(LinearMass<T> a, LinearMass<T> b) |
| | 12655 | | { |
| | 12656 | | return Equal(a, b); |
| | 12657 | | } |
| | 12658 | |
|
| | 12659 | | /// <summary>Determines if an LinearMass measurement is equal to another LinearMass measurement.</summary> |
| | 12660 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 12661 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 12662 | | public bool Equal(LinearMass<T> b) |
| | 12663 | | { |
| | 12664 | | return this == b; |
| | 12665 | | } |
| | 12666 | |
|
| | 12667 | | #endregion |
| | 12668 | |
|
| | 12669 | | #region NotEqual |
| | 12670 | |
|
| | 12671 | | /// <summary>Determines if an LinearMass measurement is not equal to another LinearMass measurement.</summary> |
| | 12672 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 12673 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 12674 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 12675 | | public static bool NotEqual(LinearMass<T> a, LinearMass<T> b) |
| | 12676 | | { |
| | 12677 | | return LogicBase(a, b, Statics.Inequate); |
| | 12678 | | } |
| | 12679 | |
|
| | 12680 | | /// <summary>Determines if an LinearMass measurement is not equal to another LinearMass measurement.</summary> |
| | 12681 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 12682 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 12683 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 12684 | | public static bool operator !=(LinearMass<T> a, LinearMass<T> b) |
| | 12685 | | { |
| | 12686 | | return NotEqual(a, b); |
| | 12687 | | } |
| | 12688 | |
|
| | 12689 | | /// <summary>Determines if an LinearMass measurement is not equal to another LinearMass measurement.</summary> |
| | 12690 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 12691 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 12692 | | public bool NotEqual(LinearMass<T> b) |
| | 12693 | | { |
| | 12694 | | return this != b; |
| | 12695 | | } |
| | 12696 | |
|
| | 12697 | | #endregion |
| | 12698 | |
|
| | 12699 | | #endregion |
| | 12700 | |
|
| | 12701 | | #region Overrides |
| | 12702 | |
|
| | 12703 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 12704 | | /// <param name="obj">The object to check for equality with.</param> |
| | 12705 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 12706 | | public override bool Equals(object obj) |
| | 12707 | | { |
| | 12708 | | if (obj is LinearMass<T>) |
| | 12709 | | { |
| | 12710 | | return this == (LinearMass<T>)obj; |
| | 12711 | | } |
| | 12712 | | return false; |
| | 12713 | | } |
| | 12714 | |
|
| | 12715 | | /// <summary>Converts the LinearMass measurement to a string represenation.</summary> |
| | 12716 | | /// <returns>The string representation of the measurement.</returns> |
| | 12717 | | public override string ToString() |
| | 12718 | | { |
| | 12719 | | return _measurement + " " + |
| | 12720 | | _MassUnits1 + "*" + _LengthUnits2 |
| | 12721 | |
|
| | 12722 | | ; |
| | 12723 | | } |
| | 12724 | |
|
| | 12725 | | /// <summary>Base hashing function for LinearMass measurements.</summary> |
| | 12726 | | /// <returns>Computed hash code for this instance.</returns> |
| | 12727 | | public override int GetHashCode() => Hash(_measurement); |
| | 12728 | |
|
| | 12729 | | #endregion |
| | 12730 | | } |
| | 12731 | |
|
| | 12732 | | #endregion |
| | 12733 | |
|
| | 12734 | | #region LinearMassFlow |
| | 12735 | |
|
| | 12736 | | internal static partial class ParsingFunctions |
| | 12737 | | { |
| | 12738 | | [Measurement.Parseable("Mass*Length/Time")] |
| | 12739 | | public static object LinearMassFlow<T>(T value, object[] units) |
| | 12740 | | { |
| | 12741 | | if (units.Length != 3) |
| | 12742 | | { |
| | 12743 | | throw new Exception("Bug in Towel. Invalid parameters to LinearMassFlow Factory."); |
| | 12744 | | } |
| | 12745 | | if (!(units[0] is Mass.Units)) |
| | 12746 | | { |
| | 12747 | | throw new Exception("Bug in Towel. Invalid parameters to LinearMassFlow Factory."); |
| | 12748 | | } |
| | 12749 | | if (!(units[1] is Length.Units)) |
| | 12750 | | { |
| | 12751 | | throw new Exception("Bug in Towel. Invalid parameters to LinearMassFlow Factory."); |
| | 12752 | | } |
| | 12753 | | if (!(units[2] is Time.Units)) |
| | 12754 | | { |
| | 12755 | | throw new Exception("Bug in Towel. Invalid parameters to LinearMassFlow Factory."); |
| | 12756 | | } |
| | 12757 | | return new LinearMassFlow<T>(value |
| | 12758 | | , (Mass.Units)units[0] |
| | 12759 | | , (Length.Units)units[1] |
| | 12760 | | , (Time.Units)units[2] |
| | 12761 | | ); |
| | 12762 | | } |
| | 12763 | | } |
| | 12764 | |
|
| | 12765 | | /// <summary>LinearMassFlow measurement with a value and the units.</summary> |
| | 12766 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 12767 | | public struct LinearMassFlow<T> |
| | 12768 | | { |
| | 12769 | | internal T _measurement; |
| | 12770 | | internal Mass.Units _MassUnits1; |
| | 12771 | | internal Length.Units _LengthUnits2; |
| | 12772 | | internal Time.Units _TimeUnits3; |
| | 12773 | |
|
| | 12774 | | #region Statics |
| | 12775 | |
|
| | 12776 | | /// <summary>Converts a LinearMassFlow measurement from units to another.</summary> |
| | 12777 | | /// <param name="value">The value to convert the units of.</param> |
| | 12778 | | /// <param name="fromMassUnits1">The current units of the measurement.</param> |
| | 12779 | | /// <param name="fromLengthUnits2">The current units of the measurement.</param> |
| | 12780 | | /// <param name="fromTimeUnits3">The current units of the measurement.</param> |
| | 12781 | | /// <param name="toMassUnits1">The desired units of the measurement.</param> |
| | 12782 | | /// <param name="toLengthUnits2">The desired units of the measurement.</param> |
| | 12783 | | /// <param name="toTimeUnits3">The desired units of the measurement.</param> |
| | 12784 | | /// <returns>The LinearMassFlow measurement converted into the desired units.</returns> |
| | 12785 | | public static T Convert(T value |
| | 12786 | | , Mass.Units fromMassUnits1 |
| | 12787 | | , Length.Units fromLengthUnits2 |
| | 12788 | | , Time.Units fromTimeUnits3 |
| | 12789 | | , Mass.Units toMassUnits1 |
| | 12790 | | , Length.Units toLengthUnits2 |
| | 12791 | | , Time.Units toTimeUnits3 |
| | 12792 | | ) |
| | 12793 | | { |
| | 12794 | | LinearMassFlow<T> measurement = new LinearMassFlow<T>(value |
| | 12795 | | , fromMassUnits1 |
| | 12796 | | , fromLengthUnits2 |
| | 12797 | | , fromTimeUnits3 |
| | 12798 | | ); |
| | 12799 | | return measurement[ |
| | 12800 | | toMassUnits1 |
| | 12801 | | , toLengthUnits2 |
| | 12802 | | , toTimeUnits3 |
| | 12803 | | ]; |
| | 12804 | | } |
| | 12805 | |
|
| | 12806 | | /// <summary>Converts a LinearMassFlow measurement from units to another.</summary> |
| | 12807 | | /// <param name="value">The value to convert the units of.</param> |
| | 12808 | | /// <param name="from">The current units of the measurement.</param> |
| | 12809 | | /// <param name="to">The desired units of the measurement.</param> |
| | 12810 | | /// <returns>The LinearMassFlow measurement converted into the desired units.</returns> |
| | 12811 | | public static T Convert(T value, |
| | 12812 | | MeasurementUnitsSyntaxTypes.LinearMassFlowBaseUnits from, |
| | 12813 | | MeasurementUnitsSyntaxTypes.LinearMassFlowBaseUnits to) |
| | 12814 | | { |
| | 12815 | | return Convert(value |
| | 12816 | | , from._MassUnits1 |
| | 12817 | | , from._LengthUnits2 |
| | 12818 | | , from._TimeUnits3 |
| | 12819 | | , to._MassUnits1 |
| | 12820 | | , to._LengthUnits2 |
| | 12821 | | , to._TimeUnits3 |
| | 12822 | | ); |
| | 12823 | | } |
| | 12824 | |
|
| | 12825 | | /// <summary>Parses a LinearMassFlow measurement string.</summary> |
| | 12826 | | /// <param name="string">The string to be parsed.</param> |
| | 12827 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 12828 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 12829 | | public static (bool Success, LinearMassFlow<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value) |
| | 12830 | |
|
| | 12831 | | #endregion |
| | 12832 | |
|
| | 12833 | | #region Constructors |
| | 12834 | |
|
| | 12835 | | /// <summary>Constructs an LinearMassFlow with the measurement value and units.</summary> |
| | 12836 | | /// <param name="measurement">The measurement value of the LinearMassFlow.</param> |
| | 12837 | | /// <param name="units">The units of the LinearMassFlow.</param> |
| | 12838 | | public LinearMassFlow(T measurement, MeasurementUnitsSyntaxTypes.LinearMassFlowBaseUnits units) : this(measurement |
| | 12839 | | , units._MassUnits1 |
| | 12840 | | , units._LengthUnits2 |
| | 12841 | | , units._TimeUnits3 |
| | 12842 | | ) { } |
| | 12843 | |
|
| | 12844 | |
|
| | 12845 | | /// <summary>Constructs an LinearMassFlow with the measurement value and units.</summary> |
| | 12846 | | /// <param name="measurement">The measurement value of the LinearMassFlow.</param> |
| | 12847 | | /// <param name="MassUnits1">The units of the LinearMassFlow.</param> |
| | 12848 | | /// <param name="LengthUnits2">The units of the LinearMassFlow.</param> |
| | 12849 | | /// <param name="TimeUnits3">The units of the LinearMassFlow.</param> |
| | 12850 | | public LinearMassFlow(T measurement |
| | 12851 | | , Mass.Units MassUnits1 |
| | 12852 | | , Length.Units LengthUnits2 |
| | 12853 | | , Time.Units TimeUnits3 |
| | 12854 | | ) |
| | 12855 | | { |
| | 12856 | | _measurement = measurement; |
| | 12857 | | _MassUnits1 = MassUnits1; |
| | 12858 | | _LengthUnits2 = LengthUnits2; |
| | 12859 | | _TimeUnits3 = TimeUnits3; |
| | 12860 | | } |
| | 12861 | |
|
| | 12862 | | #endregion |
| | 12863 | |
|
| | 12864 | | #region Properties |
| | 12865 | |
|
| | 12866 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 12867 | | public Mass.Units MassUnits1 |
| | 12868 | | { |
| | 12869 | | get { return _MassUnits1; } |
| | 12870 | | set |
| | 12871 | | { |
| | 12872 | | if (value != _MassUnits1) |
| | 12873 | | { |
| | 12874 | | _measurement = this[value, _LengthUnits2, _TimeUnits3]; |
| | 12875 | | _MassUnits1 = value; |
| | 12876 | | } |
| | 12877 | | } |
| | 12878 | | } |
| | 12879 | |
|
| | 12880 | | /// <summary>The #2 component of this measurements units.</summary> |
| | 12881 | | public Length.Units LengthUnits2 |
| | 12882 | | { |
| | 12883 | | get { return _LengthUnits2; } |
| | 12884 | | set |
| | 12885 | | { |
| | 12886 | | if (value != _LengthUnits2) |
| | 12887 | | { |
| | 12888 | | _measurement = this[_MassUnits1, value, _TimeUnits3]; |
| | 12889 | | _LengthUnits2 = value; |
| | 12890 | | } |
| | 12891 | | } |
| | 12892 | | } |
| | 12893 | |
|
| | 12894 | | /// <summary>The #3 component of this measurements units.</summary> |
| | 12895 | | public Time.Units TimeUnits3 |
| | 12896 | | { |
| | 12897 | | get { return _TimeUnits3; } |
| | 12898 | | set |
| | 12899 | | { |
| | 12900 | | if (value != _TimeUnits3) |
| | 12901 | | { |
| | 12902 | | _measurement = this[_MassUnits1, _LengthUnits2, value]; |
| | 12903 | | _TimeUnits3 = value; |
| | 12904 | | } |
| | 12905 | | } |
| | 12906 | | } |
| | 12907 | |
|
| | 12908 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 12909 | | /// <param name="units">The units to get the measurement in.</param> |
| | 12910 | | /// <returns>The measurement value in the specified units.</returns> |
| | 12911 | | public T this[MeasurementUnitsSyntaxTypes.LinearMassFlowBaseUnits units] |
| | 12912 | | { |
| | 12913 | | get { return this[units._MassUnits1, units._LengthUnits2, units._TimeUnits3]; } |
| | 12914 | | } |
| | 12915 | |
|
| | 12916 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 12917 | | /// <param name="MassUnits1">The #1 component of this measurements units.</param> |
| | 12918 | | /// <param name="LengthUnits2">The #2 component of this measurements units.</param> |
| | 12919 | | /// <param name="TimeUnits3">The #3 component of this measurements units.</param> |
| | 12920 | | /// <returns>The measurement value in the specified units.</returns> |
| | 12921 | | public T this[Mass.Units MassUnits1, Length.Units LengthUnits2, Time.Units TimeUnits3] |
| | 12922 | | { |
| | 12923 | | get |
| | 12924 | | { |
| | 12925 | | T measurement = _measurement; |
| | 12926 | | if (MassUnits1 != _MassUnits1) |
| | 12927 | | { |
| | 12928 | | measurement = Mass<T>.Table[(int)_MassUnits1][(int)MassUnits1](measurement); |
| | 12929 | | //if (MassUnits1 < _MassUnits1) |
| | 12930 | | //{ |
| | 12931 | | // measurement = Mass<T>.Table[(int)_MassUnits1][(int)MassUnits1](measurement); |
| | 12932 | | //} |
| | 12933 | | //else |
| | 12934 | | //{ |
| | 12935 | | // measurement = Mass<T>.Table[(int)MassUnits1][(int)_MassUnits1](measurement); |
| | 12936 | | //} |
| | 12937 | | } |
| | 12938 | | if (LengthUnits2 != _LengthUnits2) |
| | 12939 | | { |
| | 12940 | | measurement = Length<T>.Table[(int)_LengthUnits2][(int)LengthUnits2](measurement); |
| | 12941 | | //if (LengthUnits2 < _LengthUnits2) |
| | 12942 | | //{ |
| | 12943 | | // measurement = Length<T>.Table[(int)_LengthUnits2][(int)LengthUnits2](measurement); |
| | 12944 | | //} |
| | 12945 | | //else |
| | 12946 | | //{ |
| | 12947 | | // measurement = Length<T>.Table[(int)LengthUnits2][(int)_LengthUnits2](measurement); |
| | 12948 | | //} |
| | 12949 | | } |
| | 12950 | | if (TimeUnits3 != _TimeUnits3) |
| | 12951 | | { |
| | 12952 | | measurement = Time<T>.Table[(int)TimeUnits3][(int)_TimeUnits3](measurement); |
| | 12953 | | //if (TimeUnits3 > _TimeUnits3) |
| | 12954 | | //{ |
| | 12955 | | // measurement = Time<T>.Table[(int)_TimeUnits3][(int)TimeUnits3](measurement); |
| | 12956 | | //} |
| | 12957 | | //else |
| | 12958 | | //{ |
| | 12959 | | // measurement = Time<T>.Table[(int)TimeUnits3][(int)_TimeUnits3](measurement); |
| | 12960 | | //} |
| | 12961 | | } |
| | 12962 | | return measurement; |
| | 12963 | | } |
| | 12964 | | } |
| | 12965 | |
|
| | 12966 | | #endregion |
| | 12967 | |
|
| | 12968 | | #region Casting Operators |
| | 12969 | |
|
| | 12970 | | /// <summary>Converts a ValueTuple to a LinearMassFlow measurement.</summary> |
| | 12971 | | /// <param name="valueTuple">The ValueTuple to converted into a LinearMassFlow measurement.</param> |
| | 12972 | | public static implicit operator LinearMassFlow<T>((T, MeasurementUnitsSyntaxTypes.LinearMassFlowBaseUnits) valueTupl |
| | 12973 | | { |
| | 12974 | | return new LinearMassFlow<T>(valueTuple.Item1, valueTuple.Item2); |
| | 12975 | | } |
| | 12976 | |
|
| | 12977 | | #endregion |
| | 12978 | |
|
| | 12979 | | #region Mathematics |
| | 12980 | |
|
| | 12981 | | #region Bases |
| | 12982 | |
|
| | 12983 | | internal static LinearMassFlow<T> MathBase(LinearMassFlow<T> a, T b, Func<T, T, T> func) |
| | 12984 | | { |
| | 12985 | | return new LinearMassFlow<T>(func(a._measurement, b) |
| | 12986 | | , a._MassUnits1 |
| | 12987 | | , a._LengthUnits2 |
| | 12988 | | , a._TimeUnits3 |
| | 12989 | | ); |
| | 12990 | | } |
| | 12991 | |
|
| | 12992 | | internal static LinearMassFlow<T> MathBase(LinearMassFlow<T> a, LinearMassFlow<T> b, Func<T, T, T> func) |
| | 12993 | | { |
| | 12994 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 12995 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 12996 | | Time.Units TimeUnits3 = a._TimeUnits3 <= b._TimeUnits3 ? a._TimeUnits3 : b._TimeUnits3; |
| | 12997 | | T A = a[MassUnits1, LengthUnits2, TimeUnits3]; |
| | 12998 | | T B = b[MassUnits1, LengthUnits2, TimeUnits3]; |
| | 12999 | | T C = func(A, B); |
| | 13000 | | return new LinearMassFlow<T>(C, MassUnits1, LengthUnits2, TimeUnits3); |
| | 13001 | | } |
| | 13002 | |
|
| | 13003 | | internal static bool LogicBase(LinearMassFlow<T> a, LinearMassFlow<T> b, Func<T, T, bool> func) |
| | 13004 | | { |
| | 13005 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 13006 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 13007 | | Time.Units TimeUnits3 = a._TimeUnits3 <= b._TimeUnits3 ? a._TimeUnits3 : b._TimeUnits3; |
| | 13008 | | T A = a[MassUnits1, LengthUnits2, TimeUnits3]; |
| | 13009 | | T B = b[MassUnits1, LengthUnits2, TimeUnits3]; |
| | 13010 | | return func(A, B); |
| | 13011 | | } |
| | 13012 | |
|
| | 13013 | | #endregion |
| | 13014 | |
|
| | 13015 | | #region Add |
| | 13016 | |
|
| | 13017 | | /// <summary>Adds two LinearMassFlow measurements.</summary> |
| | 13018 | | /// <param name="a">The first operand of the addition.</param> |
| | 13019 | | /// <param name="b">The second operand of the addition.</param> |
| | 13020 | | /// <returns>The result of the addition operation.</returns> |
| | 13021 | | public static LinearMassFlow<T> Add(LinearMassFlow<T> a, LinearMassFlow<T> b) |
| | 13022 | | { |
| | 13023 | | return MathBase(a, b, Statics.Addition); |
| | 13024 | | } |
| | 13025 | |
|
| | 13026 | | /// <summary>Adds two LinearMassFlow measurements.</summary> |
| | 13027 | | /// <param name="a">The first operand of the addition.</param> |
| | 13028 | | /// <param name="b">The second operand of the addition.</param> |
| | 13029 | | /// <returns>The result of the addition operation.</returns> |
| | 13030 | | public static LinearMassFlow<T> operator +(LinearMassFlow<T> a, LinearMassFlow<T> b) |
| | 13031 | | { |
| | 13032 | | return Add(a, b); |
| | 13033 | | } |
| | 13034 | |
|
| | 13035 | | /// <summary>Adds two LinearMassFlow measurements.</summary> |
| | 13036 | | /// <param name="b">The second operand of the addition.</param> |
| | 13037 | | /// <returns>The result of the addition operation.</returns> |
| | 13038 | | public LinearMassFlow<T> Add(LinearMassFlow<T> b) |
| | 13039 | | { |
| | 13040 | | return this + b; |
| | 13041 | | } |
| | 13042 | |
|
| | 13043 | | #endregion |
| | 13044 | |
|
| | 13045 | | #region Subtract |
| | 13046 | |
|
| | 13047 | | /// <summary>Subtracts two LinearMassFlow measurements.</summary> |
| | 13048 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 13049 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 13050 | | /// <returns>The result of the subtraction.</returns> |
| | 13051 | | public static LinearMassFlow<T> Subtract(LinearMassFlow<T> a, LinearMassFlow<T> b) |
| | 13052 | | { |
| | 13053 | | return MathBase(a, b, Statics.Subtraction); |
| | 13054 | | } |
| | 13055 | |
|
| | 13056 | | /// <summary>Subtracts two LinearMassFlow measurements.</summary> |
| | 13057 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 13058 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 13059 | | /// <returns>The result of the subtraction.</returns> |
| | 13060 | | public static LinearMassFlow<T> operator -(LinearMassFlow<T> a, LinearMassFlow<T> b) |
| | 13061 | | { |
| | 13062 | | return Subtract(a, b); |
| | 13063 | | } |
| | 13064 | |
|
| | 13065 | | /// <summary>Subtracts two LinearMassFlow measurements.</summary> |
| | 13066 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 13067 | | /// <returns>The result of the subtraction.</returns> |
| | 13068 | | public LinearMassFlow<T> Subtract(LinearMassFlow<T> b) |
| | 13069 | | { |
| | 13070 | | return this - b; |
| | 13071 | | } |
| | 13072 | |
|
| | 13073 | | #endregion |
| | 13074 | |
|
| | 13075 | | #region Multiply |
| | 13076 | |
|
| | 13077 | | /// <summary>Multiplies an LinearMassFlow by a scalar numeric value.</summary> |
| | 13078 | | /// <param name="a">The LinearMassFlow measurement to multiply.</param> |
| | 13079 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 13080 | | /// <returns>The result of the multiplication.</returns> |
| | 13081 | | public static LinearMassFlow<T> Multiply(LinearMassFlow<T> a, T b) |
| | 13082 | | { |
| | 13083 | | return MathBase(a, b, Statics.Multiplication); |
| | 13084 | | } |
| | 13085 | |
|
| | 13086 | | /// <summary>Multiplies an LinearMassFlow by a scalar numeric value.</summary> |
| | 13087 | | /// <param name="a">The LinearMassFlow measurement to multiply.</param> |
| | 13088 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 13089 | | /// <returns>The result of the multiplication.</returns> |
| | 13090 | | public static LinearMassFlow<T> Multiply(T b, LinearMassFlow<T> a) |
| | 13091 | | { |
| | 13092 | | return Multiply(a, b); |
| | 13093 | | } |
| | 13094 | |
|
| | 13095 | | /// <summary>Multiplies an LinearMassFlow by a scalar numeric value.</summary> |
| | 13096 | | /// <param name="a">The LinearMassFlow measurement to multiply.</param> |
| | 13097 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 13098 | | /// <returns>The result of the multiplication.</returns> |
| | 13099 | | public static LinearMassFlow<T> operator *(LinearMassFlow<T> a, T b) |
| | 13100 | | { |
| | 13101 | | return Multiply(a, b); |
| | 13102 | | } |
| | 13103 | |
|
| | 13104 | | /// <summary>Multiplies an LinearMassFlow by a scalar numeric value.</summary> |
| | 13105 | | /// <param name="a">The LinearMassFlow measurement to multiply.</param> |
| | 13106 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 13107 | | /// <returns>The result of the multiplication.</returns> |
| | 13108 | | public static LinearMassFlow<T> operator *(T b, LinearMassFlow<T> a) |
| | 13109 | | { |
| | 13110 | | return Multiply(b, a); |
| | 13111 | | } |
| | 13112 | |
|
| | 13113 | | /// <summary>Multiplies an LinearMassFlow by a scalar numeric value.</summary> |
| | 13114 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 13115 | | /// <returns>The result of the multiplication.</returns> |
| | 13116 | | public LinearMassFlow<T> Add(T b) |
| | 13117 | | { |
| | 13118 | | return this * b; |
| | 13119 | | } |
| | 13120 | |
|
| | 13121 | | #region LinearMassFlow<T> * Acceleration<T> = Power<T> |
| | 13122 | |
|
| | 13123 | | /// <summary>Mulitplies LinearMassFlow by Acceleration resulting in Power.</summary> |
| | 13124 | | /// <param name="a">The LinearMassFlow to be multiplied.</param> |
| | 13125 | | /// <param name="b">The Acceleration to multiply by.</param> |
| | 13126 | | /// <returns>The Power result of the multiplication.</returns> |
| | 13127 | | public static Power<T> Multiply(LinearMassFlow<T> a, Acceleration<T> b) |
| | 13128 | | { |
| | 13129 | |
|
| | 13130 | | T A = a[a._MassUnits1, a._LengthUnits2, a._TimeUnits3]; |
| | 13131 | | T B = b[b._LengthUnits1, b._TimeUnits2, b._TimeUnits3]; |
| | 13132 | | T C = Statics.Multiplication(A, B); |
| | 13133 | |
|
| | 13134 | | return new Power<T>(C |
| | 13135 | | , a._MassUnits1 |
| | 13136 | | , a._LengthUnits2 |
| | 13137 | | , b._LengthUnits1 |
| | 13138 | | , a._TimeUnits3 |
| | 13139 | | , b._TimeUnits2 |
| | 13140 | | , b._TimeUnits3 |
| | 13141 | | ); |
| | 13142 | | } |
| | 13143 | |
|
| | 13144 | | /// <summary>Mulitplies LinearMassFlow by Acceleration resulting in Power.</summary> |
| | 13145 | | /// <param name="a">The LinearMassFlow to be multiplied.</param> |
| | 13146 | | /// <param name="b">The Acceleration to multiply by.</param> |
| | 13147 | | /// <returns>The Power result of the multiplication.</returns> |
| | 13148 | | public static Power<T> operator *(LinearMassFlow<T> a, Acceleration<T> b) |
| | 13149 | | { |
| | 13150 | | return Multiply(a, b); |
| | 13151 | | } |
| | 13152 | |
|
| | 13153 | | /// <summary>Mulitplies LinearMassFlow by Acceleration resulting in Power.</summary> |
| | 13154 | | /// <param name="b">The Acceleration to multiply by.</param> |
| | 13155 | | /// <returns>The Power result of the multiplication.</returns> |
| | 13156 | | public Power<T> Multiply(Acceleration<T> b) |
| | 13157 | | { |
| | 13158 | | return this * b; |
| | 13159 | | } |
| | 13160 | |
|
| | 13161 | | #endregion |
| | 13162 | |
|
| | 13163 | | #region LinearMassFlow<T> * Speed<T> = Energy<T> |
| | 13164 | |
|
| | 13165 | | /// <summary>Mulitplies LinearMassFlow by Speed resulting in Energy.</summary> |
| | 13166 | | /// <param name="a">The LinearMassFlow to be multiplied.</param> |
| | 13167 | | /// <param name="b">The Speed to multiply by.</param> |
| | 13168 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 13169 | | public static Energy<T> Multiply(LinearMassFlow<T> a, Speed<T> b) |
| | 13170 | | { |
| | 13171 | |
|
| | 13172 | | T A = a[a._MassUnits1, a._LengthUnits2, a._TimeUnits3]; |
| | 13173 | | T B = b[b._LengthUnits1, b._TimeUnits2]; |
| | 13174 | | T C = Statics.Multiplication(A, B); |
| | 13175 | |
|
| | 13176 | | return new Energy<T>(C |
| | 13177 | | , a._MassUnits1 |
| | 13178 | | , a._LengthUnits2 |
| | 13179 | | , b._LengthUnits1 |
| | 13180 | | , a._TimeUnits3 |
| | 13181 | | , b._TimeUnits2 |
| | 13182 | | ); |
| | 13183 | | } |
| | 13184 | |
|
| | 13185 | | /// <summary>Mulitplies LinearMassFlow by Speed resulting in Energy.</summary> |
| | 13186 | | /// <param name="a">The LinearMassFlow to be multiplied.</param> |
| | 13187 | | /// <param name="b">The Speed to multiply by.</param> |
| | 13188 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 13189 | | public static Energy<T> operator *(LinearMassFlow<T> a, Speed<T> b) |
| | 13190 | | { |
| | 13191 | | return Multiply(a, b); |
| | 13192 | | } |
| | 13193 | |
|
| | 13194 | | /// <summary>Mulitplies LinearMassFlow by Speed resulting in Energy.</summary> |
| | 13195 | | /// <param name="b">The Speed to multiply by.</param> |
| | 13196 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 13197 | | public Energy<T> Multiply(Speed<T> b) |
| | 13198 | | { |
| | 13199 | | return this * b; |
| | 13200 | | } |
| | 13201 | |
|
| | 13202 | | #endregion |
| | 13203 | |
|
| | 13204 | | #region LinearMassFlow<T> * Time<T> = LinearMass<T> |
| | 13205 | |
|
| | 13206 | | /// <summary>Mulitplies LinearMassFlow by Time resulting in LinearMass.</summary> |
| | 13207 | | /// <param name="a">The LinearMassFlow to be multiplied.</param> |
| | 13208 | | /// <param name="b">The Time to multiply by.</param> |
| | 13209 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 13210 | | public static LinearMass<T> Multiply(LinearMassFlow<T> a, Time<T> b) |
| | 13211 | | { |
| | 13212 | | Time.Units TimeUnits1 = a._TimeUnits3 <= b._TimeUnits1 ? a._TimeUnits3 : b._TimeUnits1; |
| | 13213 | |
|
| | 13214 | | T A = a[a._MassUnits1, a._LengthUnits2, TimeUnits1]; |
| | 13215 | | T B = b[TimeUnits1]; |
| | 13216 | | T C = Statics.Multiplication(A, B); |
| | 13217 | |
|
| | 13218 | | return new LinearMass<T>(C |
| | 13219 | | , a._MassUnits1 |
| | 13220 | | , a._LengthUnits2 |
| | 13221 | | ); |
| | 13222 | | } |
| | 13223 | |
|
| | 13224 | | /// <summary>Mulitplies LinearMassFlow by Time resulting in LinearMass.</summary> |
| | 13225 | | /// <param name="a">The LinearMassFlow to be multiplied.</param> |
| | 13226 | | /// <param name="b">The Time to multiply by.</param> |
| | 13227 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 13228 | | public static LinearMass<T> operator *(LinearMassFlow<T> a, Time<T> b) |
| | 13229 | | { |
| | 13230 | | return Multiply(a, b); |
| | 13231 | | } |
| | 13232 | |
|
| | 13233 | | /// <summary>Mulitplies LinearMassFlow by Time resulting in LinearMass.</summary> |
| | 13234 | | /// <param name="b">The Time to multiply by.</param> |
| | 13235 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 13236 | | public LinearMass<T> Multiply(Time<T> b) |
| | 13237 | | { |
| | 13238 | | return this * b; |
| | 13239 | | } |
| | 13240 | |
|
| | 13241 | | #endregion |
| | 13242 | |
|
| | 13243 | | #endregion |
| | 13244 | |
|
| | 13245 | | #region Divide |
| | 13246 | |
|
| | 13247 | | /// <summary>Divides an LinearMassFlow measurement by another LinearMassFlow measurement resulting in a scalar numer |
| | 13248 | | /// <param name="a">The first operand of the division operation.</param> |
| | 13249 | | /// <param name="b">The second operand of the division operation.</param> |
| | 13250 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 13251 | | public static T Divide(LinearMassFlow<T> a, LinearMassFlow<T> b) |
| | 13252 | | { |
| | 13253 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 13254 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 13255 | | Time.Units TimeUnits3 = a._TimeUnits3 <= b._TimeUnits3 ? a._TimeUnits3 : b._TimeUnits3; |
| | 13256 | | T A = a[MassUnits1, LengthUnits2, TimeUnits3]; |
| | 13257 | | T B = b[MassUnits1, LengthUnits2, TimeUnits3]; |
| | 13258 | | return Statics.Division(A, B); |
| | 13259 | | } |
| | 13260 | |
|
| | 13261 | | /// <summary>Divides this LinearMassFlow measurement by a numaric scalar value.</summary> |
| | 13262 | | /// <param name="a">The LinearMassFlow measurement to divide.</param> |
| | 13263 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 13264 | | /// <returns>The result of the division.</returns> |
| | 13265 | | public static LinearMassFlow<T> Divide(LinearMassFlow<T> a, T b) |
| | 13266 | | { |
| | 13267 | | return MathBase(a, b, Statics.Division); |
| | 13268 | | } |
| | 13269 | |
|
| | 13270 | | /// <summary>Divides this LinearMassFlow measurement by a numaric scalar value.</summary> |
| | 13271 | | /// <param name="a">The LinearMassFlow measurement to divide.</param> |
| | 13272 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 13273 | | /// <returns>The result of the division.</returns> |
| | 13274 | | public static LinearMassFlow<T> operator /(LinearMassFlow<T> a, T b) |
| | 13275 | | { |
| | 13276 | | return Divide(a, b); |
| | 13277 | | } |
| | 13278 | |
|
| | 13279 | | /// <summary>Divides this LinearMassFlow measurement by a numaric scalar value.</summary> |
| | 13280 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 13281 | | /// <returns>The result of the division.</returns> |
| | 13282 | | public LinearMassFlow<T> Divide(T b) |
| | 13283 | | { |
| | 13284 | | return this / b; |
| | 13285 | | } |
| | 13286 | |
|
| | 13287 | | /// <summary>Divides an LinearMassFlow measurement by another LinearMassFlow measurement resulting in a scalar numer |
| | 13288 | | /// <param name="a">The first operand of the division operation.</param> |
| | 13289 | | /// <param name="b">The second operand of the division operation.</param> |
| | 13290 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 13291 | | public static T operator /(LinearMassFlow<T> a, LinearMassFlow<T> b) |
| | 13292 | | { |
| | 13293 | | return Divide(a, b); |
| | 13294 | | } |
| | 13295 | |
|
| | 13296 | | /// <summary>Divides an LinearMassFlow measurement by another LinearMassFlow measurement resulting in a scalar numer |
| | 13297 | | /// <param name="b">The second operand of the division operation.</param> |
| | 13298 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 13299 | | public T Divide(LinearMassFlow<T> b) |
| | 13300 | | { |
| | 13301 | | return this / b; |
| | 13302 | | } |
| | 13303 | |
|
| | 13304 | |
|
| | 13305 | | #region LinearMassFlow<T> / AreaDensity<T> = VolumeRate<T> |
| | 13306 | |
|
| | 13307 | | /// <summary>Divides LinearMassFlow by AreaDensity resulting in VolumeRate.</summary> |
| | 13308 | | /// <param name="a">The LinearMassFlow to be divided.</param> |
| | 13309 | | /// <param name="b">The AreaDensity to divide by.</param> |
| | 13310 | | /// <returns>The VolumeRate result of the division.</returns> |
| | 13311 | | public static VolumeRate<T> Divide(LinearMassFlow<T> a, AreaDensity<T> b) |
| | 13312 | | { |
| | 13313 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 13314 | |
|
| | 13315 | | T A = a[MassUnits1, a._LengthUnits2, a._TimeUnits3]; |
| | 13316 | | T B = b[MassUnits1, b._LengthUnits2, b._LengthUnits3]; |
| | 13317 | | T C = Statics.Division(A, B); |
| | 13318 | |
|
| | 13319 | | return new VolumeRate<T>(C |
| | 13320 | | , a._LengthUnits2 |
| | 13321 | | , b._LengthUnits2 |
| | 13322 | | , b._LengthUnits3 |
| | 13323 | | , a._TimeUnits3 |
| | 13324 | | ); |
| | 13325 | | } |
| | 13326 | |
|
| | 13327 | | /// <summary>Divides LinearMassFlow by AreaDensity resulting in VolumeRate.</summary> |
| | 13328 | | /// <param name="a">The LinearMassFlow to be divided.</param> |
| | 13329 | | /// <param name="b">The AreaDensity to divide by.</param> |
| | 13330 | | /// <returns>The VolumeRate result of the division.</returns> |
| | 13331 | | public static VolumeRate<T> operator /(LinearMassFlow<T> a, AreaDensity<T> b) |
| | 13332 | | { |
| | 13333 | | return Divide(a, b); |
| | 13334 | | } |
| | 13335 | |
|
| | 13336 | | /// <summary>Divides LinearMassFlow by AreaDensity resulting in VolumeRate.</summary> |
| | 13337 | | /// <param name="b">The AreaDensity to divide by.</param> |
| | 13338 | | /// <returns>The VolumeRate result of the division.</returns> |
| | 13339 | | public VolumeRate<T> Divide(AreaDensity<T> b) |
| | 13340 | | { |
| | 13341 | | return this / b; |
| | 13342 | | } |
| | 13343 | |
|
| | 13344 | | #endregion |
| | 13345 | |
|
| | 13346 | |
|
| | 13347 | | #region LinearMassFlow<T> / Force<T> = Time<T> |
| | 13348 | |
|
| | 13349 | | /// <summary>Divides LinearMassFlow by Force resulting in Time.</summary> |
| | 13350 | | /// <param name="a">The LinearMassFlow to be divided.</param> |
| | 13351 | | /// <param name="b">The Force to divide by.</param> |
| | 13352 | | /// <returns>The Time result of the division.</returns> |
| | 13353 | | public static Time<T> Divide(LinearMassFlow<T> a, Force<T> b) |
| | 13354 | | { |
| | 13355 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 13356 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 13357 | | Time.Units TimeUnits3 = a._TimeUnits3 <= b._TimeUnits3 ? a._TimeUnits3 : b._TimeUnits3; |
| | 13358 | |
|
| | 13359 | | T A = a[MassUnits1, LengthUnits2, TimeUnits3]; |
| | 13360 | | T B = b[MassUnits1, LengthUnits2, TimeUnits3, b._TimeUnits4]; |
| | 13361 | | T C = Statics.Division(A, B); |
| | 13362 | |
|
| | 13363 | | return new Time<T>(C |
| | 13364 | | , b._TimeUnits4 |
| | 13365 | | ); |
| | 13366 | | } |
| | 13367 | |
|
| | 13368 | | /// <summary>Divides LinearMassFlow by Force resulting in Time.</summary> |
| | 13369 | | /// <param name="a">The LinearMassFlow to be divided.</param> |
| | 13370 | | /// <param name="b">The Force to divide by.</param> |
| | 13371 | | /// <returns>The Time result of the division.</returns> |
| | 13372 | | public static Time<T> operator /(LinearMassFlow<T> a, Force<T> b) |
| | 13373 | | { |
| | 13374 | | return Divide(a, b); |
| | 13375 | | } |
| | 13376 | |
|
| | 13377 | | /// <summary>Divides LinearMassFlow by Force resulting in Time.</summary> |
| | 13378 | | /// <param name="b">The Force to divide by.</param> |
| | 13379 | | /// <returns>The Time result of the division.</returns> |
| | 13380 | | public Time<T> Divide(Force<T> b) |
| | 13381 | | { |
| | 13382 | | return this / b; |
| | 13383 | | } |
| | 13384 | |
|
| | 13385 | | #endregion |
| | 13386 | |
|
| | 13387 | |
|
| | 13388 | | #region LinearMassFlow<T> / Length<T> = MassRate<T> |
| | 13389 | |
|
| | 13390 | | /// <summary>Divides LinearMassFlow by Length resulting in MassRate.</summary> |
| | 13391 | | /// <param name="a">The LinearMassFlow to be divided.</param> |
| | 13392 | | /// <param name="b">The Length to divide by.</param> |
| | 13393 | | /// <returns>The MassRate result of the division.</returns> |
| | 13394 | | public static MassRate<T> Divide(LinearMassFlow<T> a, Length<T> b) |
| | 13395 | | { |
| | 13396 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 13397 | |
|
| | 13398 | | T A = a[a._MassUnits1, LengthUnits1, a._TimeUnits3]; |
| | 13399 | | T B = b[LengthUnits1]; |
| | 13400 | | T C = Statics.Division(A, B); |
| | 13401 | |
|
| | 13402 | | return new MassRate<T>(C |
| | 13403 | | , a._MassUnits1 |
| | 13404 | | , a._TimeUnits3 |
| | 13405 | | ); |
| | 13406 | | } |
| | 13407 | |
|
| | 13408 | | /// <summary>Divides LinearMassFlow by Length resulting in MassRate.</summary> |
| | 13409 | | /// <param name="a">The LinearMassFlow to be divided.</param> |
| | 13410 | | /// <param name="b">The Length to divide by.</param> |
| | 13411 | | /// <returns>The MassRate result of the division.</returns> |
| | 13412 | | public static MassRate<T> operator /(LinearMassFlow<T> a, Length<T> b) |
| | 13413 | | { |
| | 13414 | | return Divide(a, b); |
| | 13415 | | } |
| | 13416 | |
|
| | 13417 | | /// <summary>Divides LinearMassFlow by Length resulting in MassRate.</summary> |
| | 13418 | | /// <param name="b">The Length to divide by.</param> |
| | 13419 | | /// <returns>The MassRate result of the division.</returns> |
| | 13420 | | public MassRate<T> Divide(Length<T> b) |
| | 13421 | | { |
| | 13422 | | return this / b; |
| | 13423 | | } |
| | 13424 | |
|
| | 13425 | | #endregion |
| | 13426 | |
|
| | 13427 | |
|
| | 13428 | | #region LinearMassFlow<T> / Mass<T> = Speed<T> |
| | 13429 | |
|
| | 13430 | | /// <summary>Divides LinearMassFlow by Mass resulting in Speed.</summary> |
| | 13431 | | /// <param name="a">The LinearMassFlow to be divided.</param> |
| | 13432 | | /// <param name="b">The Mass to divide by.</param> |
| | 13433 | | /// <returns>The Speed result of the division.</returns> |
| | 13434 | | public static Speed<T> Divide(LinearMassFlow<T> a, Mass<T> b) |
| | 13435 | | { |
| | 13436 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 13437 | |
|
| | 13438 | | T A = a[MassUnits1, a._LengthUnits2, a._TimeUnits3]; |
| | 13439 | | T B = b[MassUnits1]; |
| | 13440 | | T C = Statics.Division(A, B); |
| | 13441 | |
|
| | 13442 | | return new Speed<T>(C |
| | 13443 | | , a._LengthUnits2 |
| | 13444 | | , a._TimeUnits3 |
| | 13445 | | ); |
| | 13446 | | } |
| | 13447 | |
|
| | 13448 | | /// <summary>Divides LinearMassFlow by Mass resulting in Speed.</summary> |
| | 13449 | | /// <param name="a">The LinearMassFlow to be divided.</param> |
| | 13450 | | /// <param name="b">The Mass to divide by.</param> |
| | 13451 | | /// <returns>The Speed result of the division.</returns> |
| | 13452 | | public static Speed<T> operator /(LinearMassFlow<T> a, Mass<T> b) |
| | 13453 | | { |
| | 13454 | | return Divide(a, b); |
| | 13455 | | } |
| | 13456 | |
|
| | 13457 | | /// <summary>Divides LinearMassFlow by Mass resulting in Speed.</summary> |
| | 13458 | | /// <param name="b">The Mass to divide by.</param> |
| | 13459 | | /// <returns>The Speed result of the division.</returns> |
| | 13460 | | public Speed<T> Divide(Mass<T> b) |
| | 13461 | | { |
| | 13462 | | return this / b; |
| | 13463 | | } |
| | 13464 | |
|
| | 13465 | | #endregion |
| | 13466 | |
|
| | 13467 | |
|
| | 13468 | | #region LinearMassFlow<T> / MassRate<T> = Length<T> |
| | 13469 | |
|
| | 13470 | | /// <summary>Divides LinearMassFlow by MassRate resulting in Length.</summary> |
| | 13471 | | /// <param name="a">The LinearMassFlow to be divided.</param> |
| | 13472 | | /// <param name="b">The MassRate to divide by.</param> |
| | 13473 | | /// <returns>The Length result of the division.</returns> |
| | 13474 | | public static Length<T> Divide(LinearMassFlow<T> a, MassRate<T> b) |
| | 13475 | | { |
| | 13476 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 13477 | | Time.Units TimeUnits2 = a._TimeUnits3 <= b._TimeUnits2 ? a._TimeUnits3 : b._TimeUnits2; |
| | 13478 | |
|
| | 13479 | | T A = a[MassUnits1, a._LengthUnits2, TimeUnits2]; |
| | 13480 | | T B = b[MassUnits1, TimeUnits2]; |
| | 13481 | | T C = Statics.Division(A, B); |
| | 13482 | |
|
| | 13483 | | return new Length<T>(C |
| | 13484 | | , a._LengthUnits2 |
| | 13485 | | ); |
| | 13486 | | } |
| | 13487 | |
|
| | 13488 | | /// <summary>Divides LinearMassFlow by MassRate resulting in Length.</summary> |
| | 13489 | | /// <param name="a">The LinearMassFlow to be divided.</param> |
| | 13490 | | /// <param name="b">The MassRate to divide by.</param> |
| | 13491 | | /// <returns>The Length result of the division.</returns> |
| | 13492 | | public static Length<T> operator /(LinearMassFlow<T> a, MassRate<T> b) |
| | 13493 | | { |
| | 13494 | | return Divide(a, b); |
| | 13495 | | } |
| | 13496 | |
|
| | 13497 | | /// <summary>Divides LinearMassFlow by MassRate resulting in Length.</summary> |
| | 13498 | | /// <param name="b">The MassRate to divide by.</param> |
| | 13499 | | /// <returns>The Length result of the division.</returns> |
| | 13500 | | public Length<T> Divide(MassRate<T> b) |
| | 13501 | | { |
| | 13502 | | return this / b; |
| | 13503 | | } |
| | 13504 | |
|
| | 13505 | | #endregion |
| | 13506 | |
|
| | 13507 | |
|
| | 13508 | | #region LinearMassFlow<T> / Speed<T> = Mass<T> |
| | 13509 | |
|
| | 13510 | | /// <summary>Divides LinearMassFlow by Speed resulting in Mass.</summary> |
| | 13511 | | /// <param name="a">The LinearMassFlow to be divided.</param> |
| | 13512 | | /// <param name="b">The Speed to divide by.</param> |
| | 13513 | | /// <returns>The Mass result of the division.</returns> |
| | 13514 | | public static Mass<T> Divide(LinearMassFlow<T> a, Speed<T> b) |
| | 13515 | | { |
| | 13516 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 13517 | | Time.Units TimeUnits2 = a._TimeUnits3 <= b._TimeUnits2 ? a._TimeUnits3 : b._TimeUnits2; |
| | 13518 | |
|
| | 13519 | | T A = a[a._MassUnits1, LengthUnits1, TimeUnits2]; |
| | 13520 | | T B = b[LengthUnits1, TimeUnits2]; |
| | 13521 | | T C = Statics.Division(A, B); |
| | 13522 | |
|
| | 13523 | | return new Mass<T>(C |
| | 13524 | | , a._MassUnits1 |
| | 13525 | | ); |
| | 13526 | | } |
| | 13527 | |
|
| | 13528 | | /// <summary>Divides LinearMassFlow by Speed resulting in Mass.</summary> |
| | 13529 | | /// <param name="a">The LinearMassFlow to be divided.</param> |
| | 13530 | | /// <param name="b">The Speed to divide by.</param> |
| | 13531 | | /// <returns>The Mass result of the division.</returns> |
| | 13532 | | public static Mass<T> operator /(LinearMassFlow<T> a, Speed<T> b) |
| | 13533 | | { |
| | 13534 | | return Divide(a, b); |
| | 13535 | | } |
| | 13536 | |
|
| | 13537 | | /// <summary>Divides LinearMassFlow by Speed resulting in Mass.</summary> |
| | 13538 | | /// <param name="b">The Speed to divide by.</param> |
| | 13539 | | /// <returns>The Mass result of the division.</returns> |
| | 13540 | | public Mass<T> Divide(Speed<T> b) |
| | 13541 | | { |
| | 13542 | | return this / b; |
| | 13543 | | } |
| | 13544 | |
|
| | 13545 | | #endregion |
| | 13546 | |
|
| | 13547 | |
|
| | 13548 | | #region LinearMassFlow<T> / Time<T> = Force<T> |
| | 13549 | |
|
| | 13550 | | /// <summary>Divides LinearMassFlow by Time resulting in Force.</summary> |
| | 13551 | | /// <param name="a">The LinearMassFlow to be divided.</param> |
| | 13552 | | /// <param name="b">The Time to divide by.</param> |
| | 13553 | | /// <returns>The Force result of the division.</returns> |
| | 13554 | | public static Force<T> Divide(LinearMassFlow<T> a, Time<T> b) |
| | 13555 | | { |
| | 13556 | |
|
| | 13557 | | T A = a[a._MassUnits1, a._LengthUnits2, a._TimeUnits3]; |
| | 13558 | | T B = b[b._TimeUnits1]; |
| | 13559 | | T C = Statics.Division(A, B); |
| | 13560 | |
|
| | 13561 | | return new Force<T>(C |
| | 13562 | | , a._MassUnits1 |
| | 13563 | | , a._LengthUnits2 |
| | 13564 | | , a._TimeUnits3 |
| | 13565 | | , b._TimeUnits1 |
| | 13566 | | ); |
| | 13567 | | } |
| | 13568 | |
|
| | 13569 | | /// <summary>Divides LinearMassFlow by Time resulting in Force.</summary> |
| | 13570 | | /// <param name="a">The LinearMassFlow to be divided.</param> |
| | 13571 | | /// <param name="b">The Time to divide by.</param> |
| | 13572 | | /// <returns>The Force result of the division.</returns> |
| | 13573 | | public static Force<T> operator /(LinearMassFlow<T> a, Time<T> b) |
| | 13574 | | { |
| | 13575 | | return Divide(a, b); |
| | 13576 | | } |
| | 13577 | |
|
| | 13578 | | /// <summary>Divides LinearMassFlow by Time resulting in Force.</summary> |
| | 13579 | | /// <param name="b">The Time to divide by.</param> |
| | 13580 | | /// <returns>The Force result of the division.</returns> |
| | 13581 | | public Force<T> Divide(Time<T> b) |
| | 13582 | | { |
| | 13583 | | return this / b; |
| | 13584 | | } |
| | 13585 | |
|
| | 13586 | | #endregion |
| | 13587 | |
|
| | 13588 | |
|
| | 13589 | | #region LinearMassFlow<T> / VolumeRate<T> = AreaDensity<T> |
| | 13590 | |
|
| | 13591 | | /// <summary>Divides LinearMassFlow by VolumeRate resulting in AreaDensity.</summary> |
| | 13592 | | /// <param name="a">The LinearMassFlow to be divided.</param> |
| | 13593 | | /// <param name="b">The VolumeRate to divide by.</param> |
| | 13594 | | /// <returns>The AreaDensity result of the division.</returns> |
| | 13595 | | public static AreaDensity<T> Divide(LinearMassFlow<T> a, VolumeRate<T> b) |
| | 13596 | | { |
| | 13597 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 13598 | | Time.Units TimeUnits2 = a._TimeUnits3 <= b._TimeUnits4 ? a._TimeUnits3 : b._TimeUnits4; |
| | 13599 | |
|
| | 13600 | | T A = a[a._MassUnits1, LengthUnits1, TimeUnits2]; |
| | 13601 | | T B = b[LengthUnits1, b._LengthUnits2, b._LengthUnits3, TimeUnits2]; |
| | 13602 | | T C = Statics.Division(A, B); |
| | 13603 | |
|
| | 13604 | | return new AreaDensity<T>(C |
| | 13605 | | , a._MassUnits1 |
| | 13606 | | , b._LengthUnits2 |
| | 13607 | | , b._LengthUnits3 |
| | 13608 | | ); |
| | 13609 | | } |
| | 13610 | |
|
| | 13611 | | /// <summary>Divides LinearMassFlow by VolumeRate resulting in AreaDensity.</summary> |
| | 13612 | | /// <param name="a">The LinearMassFlow to be divided.</param> |
| | 13613 | | /// <param name="b">The VolumeRate to divide by.</param> |
| | 13614 | | /// <returns>The AreaDensity result of the division.</returns> |
| | 13615 | | public static AreaDensity<T> operator /(LinearMassFlow<T> a, VolumeRate<T> b) |
| | 13616 | | { |
| | 13617 | | return Divide(a, b); |
| | 13618 | | } |
| | 13619 | |
|
| | 13620 | | /// <summary>Divides LinearMassFlow by VolumeRate resulting in AreaDensity.</summary> |
| | 13621 | | /// <param name="b">The VolumeRate to divide by.</param> |
| | 13622 | | /// <returns>The AreaDensity result of the division.</returns> |
| | 13623 | | public AreaDensity<T> Divide(VolumeRate<T> b) |
| | 13624 | | { |
| | 13625 | | return this / b; |
| | 13626 | | } |
| | 13627 | |
|
| | 13628 | | #endregion |
| | 13629 | |
|
| | 13630 | | #endregion |
| | 13631 | |
|
| | 13632 | | #region LessThan |
| | 13633 | |
|
| | 13634 | | /// <summary>Determines if an LinearMassFlow measurement is less than another LinearMassFlow measurement.</summary> |
| | 13635 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 13636 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 13637 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 13638 | | public static bool LessThan(LinearMassFlow<T> a, LinearMassFlow<T> b) |
| | 13639 | | { |
| | 13640 | | return LogicBase(a, b, Statics.LessThan); |
| | 13641 | | } |
| | 13642 | |
|
| | 13643 | | /// <summary>Determines if an LinearMassFlow measurement is less than another LinearMassFlow measurement.</summary> |
| | 13644 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 13645 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 13646 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 13647 | | public static bool operator <(LinearMassFlow<T> a, LinearMassFlow<T> b) |
| | 13648 | | { |
| | 13649 | | return LessThan(a, b); |
| | 13650 | | } |
| | 13651 | |
|
| | 13652 | | /// <summary>Determines if an LinearMassFlow measurement is less than another LinearMassFlow measurement.</summary> |
| | 13653 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 13654 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 13655 | | public bool LessThan(LinearMassFlow<T> b) |
| | 13656 | | { |
| | 13657 | | return this < b; |
| | 13658 | | } |
| | 13659 | |
|
| | 13660 | | #endregion |
| | 13661 | |
|
| | 13662 | | #region GreaterThan |
| | 13663 | |
|
| | 13664 | | /// <summary>Determines if an LinearMassFlow measurement is greater than another LinearMassFlow measurement.</summar |
| | 13665 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 13666 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 13667 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 13668 | | public static bool GreaterThan(LinearMassFlow<T> a, LinearMassFlow<T> b) |
| | 13669 | | { |
| | 13670 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 13671 | | } |
| | 13672 | |
|
| | 13673 | | /// <summary>Determines if an LinearMassFlow measurement is greater than another LinearMassFlow measurement.</summar |
| | 13674 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 13675 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 13676 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 13677 | | public static bool operator >(LinearMassFlow<T> a, LinearMassFlow<T> b) |
| | 13678 | | { |
| | 13679 | | return GreaterThan(a, b); |
| | 13680 | | } |
| | 13681 | |
|
| | 13682 | | /// <summary>Determines if an LinearMassFlow measurement is greater than another LinearMassFlow measurement.</summar |
| | 13683 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 13684 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 13685 | | public bool GreaterThan(LinearMassFlow<T> b) |
| | 13686 | | { |
| | 13687 | | return this > b; |
| | 13688 | | } |
| | 13689 | |
|
| | 13690 | | #endregion |
| | 13691 | |
|
| | 13692 | | #region LessThanOrEqual |
| | 13693 | |
|
| | 13694 | | /// <summary>Determines if an LinearMassFlow measurement is less than or equal to another LinearMassFlow measurement |
| | 13695 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 13696 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 13697 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 13698 | | public static bool LessThanOrEqual(LinearMassFlow<T> a, LinearMassFlow<T> b) |
| | 13699 | | { |
| | 13700 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 13701 | | } |
| | 13702 | |
|
| | 13703 | | /// <summary>Determines if an LinearMassFlow measurement is less than or equal to another LinearMassFlow measurement |
| | 13704 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 13705 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 13706 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 13707 | | public static bool operator <=(LinearMassFlow<T> a, LinearMassFlow<T> b) |
| | 13708 | | { |
| | 13709 | | return LessThanOrEqual(a, b); |
| | 13710 | | } |
| | 13711 | |
|
| | 13712 | | /// <summary>Determines if an LinearMassFlow measurement is less than or equal to another LinearMassFlow measurement |
| | 13713 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 13714 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 13715 | | public bool LessThanOrEqual(LinearMassFlow<T> b) |
| | 13716 | | { |
| | 13717 | | return this <= b; |
| | 13718 | | } |
| | 13719 | |
|
| | 13720 | | #endregion |
| | 13721 | |
|
| | 13722 | | #region GreaterThanOrEqual |
| | 13723 | |
|
| | 13724 | | /// <summary>Determines if an LinearMassFlow measurement is greater than or equal to another LinearMassFlow measurem |
| | 13725 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 13726 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 13727 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 13728 | | public static bool GreaterThanOrEqual(LinearMassFlow<T> a, LinearMassFlow<T> b) |
| | 13729 | | { |
| | 13730 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 13731 | | } |
| | 13732 | |
|
| | 13733 | | /// <summary>Determines if an LinearMassFlow measurement is greater than or equal to another LinearMassFlow measurem |
| | 13734 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 13735 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 13736 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 13737 | | public static bool operator >=(LinearMassFlow<T> a, LinearMassFlow<T> b) |
| | 13738 | | { |
| | 13739 | | return GreaterThanOrEqual(a, b); |
| | 13740 | | } |
| | 13741 | |
|
| | 13742 | | /// <summary>Determines if an LinearMassFlow measurement is greater than or equal to another LinearMassFlow measurem |
| | 13743 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 13744 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 13745 | | public bool GreaterThanOrEqual(LinearMassFlow<T> b) |
| | 13746 | | { |
| | 13747 | | return this >= b; |
| | 13748 | | } |
| | 13749 | |
|
| | 13750 | | #endregion |
| | 13751 | |
|
| | 13752 | | #region Equal |
| | 13753 | |
|
| | 13754 | | /// <summary>Determines if an LinearMassFlow measurement is equal to another LinearMassFlow measurement.</summary> |
| | 13755 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 13756 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 13757 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 13758 | | public static bool Equal(LinearMassFlow<T> a, LinearMassFlow<T> b) |
| | 13759 | | { |
| | 13760 | | return LogicBase(a, b, Statics.Equate); |
| | 13761 | | } |
| | 13762 | |
|
| | 13763 | | /// <summary>Determines if an LinearMassFlow measurement is equal to another LinearMassFlow measurement.</summary> |
| | 13764 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 13765 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 13766 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 13767 | | public static bool operator ==(LinearMassFlow<T> a, LinearMassFlow<T> b) |
| | 13768 | | { |
| | 13769 | | return Equal(a, b); |
| | 13770 | | } |
| | 13771 | |
|
| | 13772 | | /// <summary>Determines if an LinearMassFlow measurement is equal to another LinearMassFlow measurement.</summary> |
| | 13773 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 13774 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 13775 | | public bool Equal(LinearMassFlow<T> b) |
| | 13776 | | { |
| | 13777 | | return this == b; |
| | 13778 | | } |
| | 13779 | |
|
| | 13780 | | #endregion |
| | 13781 | |
|
| | 13782 | | #region NotEqual |
| | 13783 | |
|
| | 13784 | | /// <summary>Determines if an LinearMassFlow measurement is not equal to another LinearMassFlow measurement.</summar |
| | 13785 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 13786 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 13787 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 13788 | | public static bool NotEqual(LinearMassFlow<T> a, LinearMassFlow<T> b) |
| | 13789 | | { |
| | 13790 | | return LogicBase(a, b, Statics.Inequate); |
| | 13791 | | } |
| | 13792 | |
|
| | 13793 | | /// <summary>Determines if an LinearMassFlow measurement is not equal to another LinearMassFlow measurement.</summar |
| | 13794 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 13795 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 13796 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 13797 | | public static bool operator !=(LinearMassFlow<T> a, LinearMassFlow<T> b) |
| | 13798 | | { |
| | 13799 | | return NotEqual(a, b); |
| | 13800 | | } |
| | 13801 | |
|
| | 13802 | | /// <summary>Determines if an LinearMassFlow measurement is not equal to another LinearMassFlow measurement.</summar |
| | 13803 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 13804 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 13805 | | public bool NotEqual(LinearMassFlow<T> b) |
| | 13806 | | { |
| | 13807 | | return this != b; |
| | 13808 | | } |
| | 13809 | |
|
| | 13810 | | #endregion |
| | 13811 | |
|
| | 13812 | | #endregion |
| | 13813 | |
|
| | 13814 | | #region Overrides |
| | 13815 | |
|
| | 13816 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 13817 | | /// <param name="obj">The object to check for equality with.</param> |
| | 13818 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 13819 | | public override bool Equals(object obj) |
| | 13820 | | { |
| | 13821 | | if (obj is LinearMassFlow<T>) |
| | 13822 | | { |
| | 13823 | | return this == (LinearMassFlow<T>)obj; |
| | 13824 | | } |
| | 13825 | | return false; |
| | 13826 | | } |
| | 13827 | |
|
| | 13828 | | /// <summary>Converts the LinearMassFlow measurement to a string represenation.</summary> |
| | 13829 | | /// <returns>The string representation of the measurement.</returns> |
| | 13830 | | public override string ToString() |
| | 13831 | | { |
| | 13832 | | return _measurement + " " + |
| | 13833 | | _MassUnits1 + "*" + _LengthUnits2 |
| | 13834 | | + "/" + |
| | 13835 | | _TimeUnits3 |
| | 13836 | | ; |
| | 13837 | | } |
| | 13838 | |
|
| | 13839 | | /// <summary>Base hashing function for LinearMassFlow measurements.</summary> |
| | 13840 | | /// <returns>Computed hash code for this instance.</returns> |
| | 13841 | | public override int GetHashCode() => Hash(_measurement); |
| | 13842 | |
|
| | 13843 | | #endregion |
| | 13844 | | } |
| | 13845 | |
|
| | 13846 | | #endregion |
| | 13847 | |
|
| | 13848 | | #region Mass |
| | 13849 | |
|
| | 13850 | | internal static partial class ParsingFunctions |
| | 13851 | | { |
| | 13852 | | [Measurement.Parseable("Mass")] |
| | 13853 | | public static object Mass<T>(T value, object[] units) |
| | 13854 | | { |
| | 13855 | | if (units.Length != 1) |
| | 13856 | | { |
| | 13857 | | throw new Exception("Bug in Towel. Invalid parameters to Mass Factory."); |
| | 13858 | | } |
| | 13859 | | if (!(units[0] is Mass.Units)) |
| | 13860 | | { |
| | 13861 | | throw new Exception("Bug in Towel. Invalid parameters to Mass Factory."); |
| | 13862 | | } |
| | 13863 | | return new Mass<T>(value |
| | 13864 | | , (Mass.Units)units[0] |
| | 13865 | | ); |
| | 13866 | | } |
| | 13867 | | } |
| | 13868 | |
|
| | 13869 | | /// <summary>Mass measurement with a value and the units.</summary> |
| | 13870 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 13871 | | public struct Mass<T> |
| | 13872 | | { |
| | 13873 | | internal static Func<T, T>[][] Table = UnitConversionTable.Build<Mass.Units, T>(); |
| | 13874 | | internal T _measurement; |
| | 13875 | | internal Mass.Units _MassUnits1; |
| | 13876 | |
|
| | 13877 | | #region Statics |
| | 13878 | |
|
| | 13879 | | /// <summary>Converts a Mass measurement from units to another.</summary> |
| | 13880 | | /// <param name="value">The value to convert the units of.</param> |
| | 13881 | | /// <param name="fromMassUnits1">The current units of the measurement.</param> |
| | 13882 | | /// <param name="toMassUnits1">The desired units of the measurement.</param> |
| | 13883 | | /// <returns>The Mass measurement converted into the desired units.</returns> |
| | 13884 | | public static T Convert(T value |
| | 13885 | | , Mass.Units fromMassUnits1 |
| | 13886 | | , Mass.Units toMassUnits1 |
| | 13887 | | ) |
| | 13888 | | { |
| | 13889 | | Mass<T> measurement = new Mass<T>(value |
| | 13890 | | , fromMassUnits1 |
| | 13891 | | ); |
| | 13892 | | return measurement[ |
| | 13893 | | toMassUnits1 |
| | 13894 | | ]; |
| | 13895 | | } |
| | 13896 | |
|
| | 13897 | | /// <summary>Converts a Mass measurement from units to another.</summary> |
| | 13898 | | /// <param name="value">The value to convert the units of.</param> |
| | 13899 | | /// <param name="from">The current units of the measurement.</param> |
| | 13900 | | /// <param name="to">The desired units of the measurement.</param> |
| | 13901 | | /// <returns>The Mass measurement converted into the desired units.</returns> |
| | 13902 | | public static T Convert(T value, |
| | 13903 | | MeasurementUnitsSyntaxTypes.MassUnits from, |
| | 13904 | | MeasurementUnitsSyntaxTypes.MassUnits to) |
| | 13905 | | { |
| | 13906 | | return Convert(value |
| | 13907 | | , from._MassUnits1 |
| | 13908 | | , to._MassUnits1 |
| | 13909 | | ); |
| | 13910 | | } |
| | 13911 | |
|
| | 13912 | | /// <summary>Parses a Mass measurement string.</summary> |
| | 13913 | | /// <param name="string">The string to be parsed.</param> |
| | 13914 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 13915 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 13916 | | public static (bool Success, Mass<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value)> tryParse |
| | 13917 | |
|
| | 13918 | | #endregion |
| | 13919 | |
|
| | 13920 | | #region Constructors |
| | 13921 | |
|
| | 13922 | | /// <summary>Constructs an Mass with the measurement value and units.</summary> |
| | 13923 | | /// <param name="measurement">The measurement value of the Mass.</param> |
| | 13924 | | /// <param name="units">The units of the Mass.</param> |
| | 13925 | | public Mass(T measurement, MeasurementUnitsSyntaxTypes.MassUnits units) : this(measurement |
| | 13926 | | , units._MassUnits1 |
| | 13927 | | ) { } |
| | 13928 | |
|
| | 13929 | |
|
| | 13930 | | /// <summary>Constructs an Mass with the measurement value and units.</summary> |
| | 13931 | | /// <param name="measurement">The measurement value of the Mass.</param> |
| | 13932 | | /// <param name="MassUnits1">The units of the Mass.</param> |
| | 13933 | | public Mass(T measurement |
| | 13934 | | , Mass.Units MassUnits1 |
| | 13935 | | ) |
| | 13936 | | { |
| | 13937 | | _measurement = measurement; |
| | 13938 | | _MassUnits1 = MassUnits1; |
| | 13939 | | } |
| | 13940 | |
|
| | 13941 | | #endregion |
| | 13942 | |
|
| | 13943 | | #region Properties |
| | 13944 | |
|
| | 13945 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 13946 | | public Mass.Units MassUnits1 |
| | 13947 | | { |
| | 13948 | | get { return _MassUnits1; } |
| | 13949 | | set |
| | 13950 | | { |
| | 13951 | | if (value != _MassUnits1) |
| | 13952 | | { |
| | 13953 | | _measurement = this[value]; |
| | 13954 | | _MassUnits1 = value; |
| | 13955 | | } |
| | 13956 | | } |
| | 13957 | | } |
| | 13958 | |
|
| | 13959 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 13960 | | /// <param name="units">The units to get the measurement in.</param> |
| | 13961 | | /// <returns>The measurement value in the specified units.</returns> |
| | 13962 | | public T this[MeasurementUnitsSyntaxTypes.MassUnits units] |
| | 13963 | | { |
| | 13964 | | get { return this[units._MassUnits1]; } |
| | 13965 | | } |
| | 13966 | |
|
| | 13967 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 13968 | | /// <param name="MassUnits1">The #1 component of this measurements units.</param> |
| | 13969 | | /// <returns>The measurement value in the specified units.</returns> |
| | 13970 | | public T this[Mass.Units MassUnits1] |
| | 13971 | | { |
| | 13972 | | get |
| | 13973 | | { |
| | 13974 | | T measurement = _measurement; |
| | 13975 | | if (MassUnits1 != _MassUnits1) |
| | 13976 | | { |
| | 13977 | | measurement = Mass<T>.Table[(int)_MassUnits1][(int)MassUnits1](measurement); |
| | 13978 | | //if (MassUnits1 < _MassUnits1) |
| | 13979 | | //{ |
| | 13980 | | // measurement = Mass<T>.Table[(int)_MassUnits1][(int)MassUnits1](measurement); |
| | 13981 | | //} |
| | 13982 | | //else |
| | 13983 | | //{ |
| | 13984 | | // measurement = Mass<T>.Table[(int)MassUnits1][(int)_MassUnits1](measurement); |
| | 13985 | | //} |
| | 13986 | | } |
| | 13987 | | return measurement; |
| | 13988 | | } |
| | 13989 | | } |
| | 13990 | |
|
| | 13991 | | #endregion |
| | 13992 | |
|
| | 13993 | | #region Casting Operators |
| | 13994 | |
|
| | 13995 | | /// <summary>Converts a ValueTuple to a Mass measurement.</summary> |
| | 13996 | | /// <param name="valueTuple">The ValueTuple to converted into a Mass measurement.</param> |
| | 13997 | | public static implicit operator Mass<T>((T, MeasurementUnitsSyntaxTypes.MassUnits) valueTuple) |
| | 13998 | | { |
| | 13999 | | return new Mass<T>(valueTuple.Item1, valueTuple.Item2); |
| | 14000 | | } |
| | 14001 | |
|
| | 14002 | | #endregion |
| | 14003 | |
|
| | 14004 | | #region Mathematics |
| | 14005 | |
|
| | 14006 | | #region Bases |
| | 14007 | |
|
| | 14008 | | internal static Mass<T> MathBase(Mass<T> a, T b, Func<T, T, T> func) |
| | 14009 | | { |
| | 14010 | | return new Mass<T>(func(a._measurement, b) |
| | 14011 | | , a._MassUnits1 |
| | 14012 | | ); |
| | 14013 | | } |
| | 14014 | |
|
| | 14015 | | internal static Mass<T> MathBase(Mass<T> a, Mass<T> b, Func<T, T, T> func) |
| | 14016 | | { |
| | 14017 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 14018 | | T A = a[MassUnits1]; |
| | 14019 | | T B = b[MassUnits1]; |
| | 14020 | | T C = func(A, B); |
| | 14021 | | return new Mass<T>(C, MassUnits1); |
| | 14022 | | } |
| | 14023 | |
|
| | 14024 | | internal static bool LogicBase(Mass<T> a, Mass<T> b, Func<T, T, bool> func) |
| | 14025 | | { |
| | 14026 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 14027 | | T A = a[MassUnits1]; |
| | 14028 | | T B = b[MassUnits1]; |
| | 14029 | | return func(A, B); |
| | 14030 | | } |
| | 14031 | |
|
| | 14032 | | #endregion |
| | 14033 | |
|
| | 14034 | | #region Add |
| | 14035 | |
|
| | 14036 | | /// <summary>Adds two Mass measurements.</summary> |
| | 14037 | | /// <param name="a">The first operand of the addition.</param> |
| | 14038 | | /// <param name="b">The second operand of the addition.</param> |
| | 14039 | | /// <returns>The result of the addition operation.</returns> |
| | 14040 | | public static Mass<T> Add(Mass<T> a, Mass<T> b) |
| | 14041 | | { |
| | 14042 | | return MathBase(a, b, Statics.Addition); |
| | 14043 | | } |
| | 14044 | |
|
| | 14045 | | /// <summary>Adds two Mass measurements.</summary> |
| | 14046 | | /// <param name="a">The first operand of the addition.</param> |
| | 14047 | | /// <param name="b">The second operand of the addition.</param> |
| | 14048 | | /// <returns>The result of the addition operation.</returns> |
| | 14049 | | public static Mass<T> operator +(Mass<T> a, Mass<T> b) |
| | 14050 | | { |
| | 14051 | | return Add(a, b); |
| | 14052 | | } |
| | 14053 | |
|
| | 14054 | | /// <summary>Adds two Mass measurements.</summary> |
| | 14055 | | /// <param name="b">The second operand of the addition.</param> |
| | 14056 | | /// <returns>The result of the addition operation.</returns> |
| | 14057 | | public Mass<T> Add(Mass<T> b) |
| | 14058 | | { |
| | 14059 | | return this + b; |
| | 14060 | | } |
| | 14061 | |
|
| | 14062 | | #endregion |
| | 14063 | |
|
| | 14064 | | #region Subtract |
| | 14065 | |
|
| | 14066 | | /// <summary>Subtracts two Mass measurements.</summary> |
| | 14067 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 14068 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 14069 | | /// <returns>The result of the subtraction.</returns> |
| | 14070 | | public static Mass<T> Subtract(Mass<T> a, Mass<T> b) |
| | 14071 | | { |
| | 14072 | | return MathBase(a, b, Statics.Subtraction); |
| | 14073 | | } |
| | 14074 | |
|
| | 14075 | | /// <summary>Subtracts two Mass measurements.</summary> |
| | 14076 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 14077 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 14078 | | /// <returns>The result of the subtraction.</returns> |
| | 14079 | | public static Mass<T> operator -(Mass<T> a, Mass<T> b) |
| | 14080 | | { |
| | 14081 | | return Subtract(a, b); |
| | 14082 | | } |
| | 14083 | |
|
| | 14084 | | /// <summary>Subtracts two Mass measurements.</summary> |
| | 14085 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 14086 | | /// <returns>The result of the subtraction.</returns> |
| | 14087 | | public Mass<T> Subtract(Mass<T> b) |
| | 14088 | | { |
| | 14089 | | return this - b; |
| | 14090 | | } |
| | 14091 | |
|
| | 14092 | | #endregion |
| | 14093 | |
|
| | 14094 | | #region Multiply |
| | 14095 | |
|
| | 14096 | | /// <summary>Multiplies an Mass by a scalar numeric value.</summary> |
| | 14097 | | /// <param name="a">The Mass measurement to multiply.</param> |
| | 14098 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 14099 | | /// <returns>The result of the multiplication.</returns> |
| | 14100 | | public static Mass<T> Multiply(Mass<T> a, T b) |
| | 14101 | | { |
| | 14102 | | return MathBase(a, b, Statics.Multiplication); |
| | 14103 | | } |
| | 14104 | |
|
| | 14105 | | /// <summary>Multiplies an Mass by a scalar numeric value.</summary> |
| | 14106 | | /// <param name="a">The Mass measurement to multiply.</param> |
| | 14107 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 14108 | | /// <returns>The result of the multiplication.</returns> |
| | 14109 | | public static Mass<T> Multiply(T b, Mass<T> a) |
| | 14110 | | { |
| | 14111 | | return Multiply(a, b); |
| | 14112 | | } |
| | 14113 | |
|
| | 14114 | | /// <summary>Multiplies an Mass by a scalar numeric value.</summary> |
| | 14115 | | /// <param name="a">The Mass measurement to multiply.</param> |
| | 14116 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 14117 | | /// <returns>The result of the multiplication.</returns> |
| | 14118 | | public static Mass<T> operator *(Mass<T> a, T b) |
| | 14119 | | { |
| | 14120 | | return Multiply(a, b); |
| | 14121 | | } |
| | 14122 | |
|
| | 14123 | | /// <summary>Multiplies an Mass by a scalar numeric value.</summary> |
| | 14124 | | /// <param name="a">The Mass measurement to multiply.</param> |
| | 14125 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 14126 | | /// <returns>The result of the multiplication.</returns> |
| | 14127 | | public static Mass<T> operator *(T b, Mass<T> a) |
| | 14128 | | { |
| | 14129 | | return Multiply(b, a); |
| | 14130 | | } |
| | 14131 | |
|
| | 14132 | | /// <summary>Multiplies an Mass by a scalar numeric value.</summary> |
| | 14133 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 14134 | | /// <returns>The result of the multiplication.</returns> |
| | 14135 | | public Mass<T> Add(T b) |
| | 14136 | | { |
| | 14137 | | return this * b; |
| | 14138 | | } |
| | 14139 | |
|
| | 14140 | | #region Mass<T> * Acceleration<T> = Force<T> |
| | 14141 | |
|
| | 14142 | | /// <summary>Mulitplies Mass by Acceleration resulting in Force.</summary> |
| | 14143 | | /// <param name="a">The Mass to be multiplied.</param> |
| | 14144 | | /// <param name="b">The Acceleration to multiply by.</param> |
| | 14145 | | /// <returns>The Force result of the multiplication.</returns> |
| | 14146 | | public static Force<T> Multiply(Mass<T> a, Acceleration<T> b) |
| | 14147 | | { |
| | 14148 | |
|
| | 14149 | | T A = a[a._MassUnits1]; |
| | 14150 | | T B = b[b._LengthUnits1, b._TimeUnits2, b._TimeUnits3]; |
| | 14151 | | T C = Statics.Multiplication(A, B); |
| | 14152 | |
|
| | 14153 | | return new Force<T>(C |
| | 14154 | | , a._MassUnits1 |
| | 14155 | | , b._LengthUnits1 |
| | 14156 | | , b._TimeUnits2 |
| | 14157 | | , b._TimeUnits3 |
| | 14158 | | ); |
| | 14159 | | } |
| | 14160 | |
|
| | 14161 | | /// <summary>Mulitplies Mass by Acceleration resulting in Force.</summary> |
| | 14162 | | /// <param name="a">The Mass to be multiplied.</param> |
| | 14163 | | /// <param name="b">The Acceleration to multiply by.</param> |
| | 14164 | | /// <returns>The Force result of the multiplication.</returns> |
| | 14165 | | public static Force<T> operator *(Mass<T> a, Acceleration<T> b) |
| | 14166 | | { |
| | 14167 | | return Multiply(a, b); |
| | 14168 | | } |
| | 14169 | |
|
| | 14170 | | /// <summary>Mulitplies Mass by Acceleration resulting in Force.</summary> |
| | 14171 | | /// <param name="b">The Acceleration to multiply by.</param> |
| | 14172 | | /// <returns>The Force result of the multiplication.</returns> |
| | 14173 | | public Force<T> Multiply(Acceleration<T> b) |
| | 14174 | | { |
| | 14175 | | return this * b; |
| | 14176 | | } |
| | 14177 | |
|
| | 14178 | | #endregion |
| | 14179 | |
|
| | 14180 | | #region Mass<T> * Length<T> = LinearMass<T> |
| | 14181 | |
|
| | 14182 | | /// <summary>Mulitplies Mass by Length resulting in LinearMass.</summary> |
| | 14183 | | /// <param name="a">The Mass to be multiplied.</param> |
| | 14184 | | /// <param name="b">The Length to multiply by.</param> |
| | 14185 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 14186 | | public static LinearMass<T> Multiply(Mass<T> a, Length<T> b) |
| | 14187 | | { |
| | 14188 | |
|
| | 14189 | | T A = a[a._MassUnits1]; |
| | 14190 | | T B = b[b._LengthUnits1]; |
| | 14191 | | T C = Statics.Multiplication(A, B); |
| | 14192 | |
|
| | 14193 | | return new LinearMass<T>(C |
| | 14194 | | , a._MassUnits1 |
| | 14195 | | , b._LengthUnits1 |
| | 14196 | | ); |
| | 14197 | | } |
| | 14198 | |
|
| | 14199 | | /// <summary>Mulitplies Mass by Length resulting in LinearMass.</summary> |
| | 14200 | | /// <param name="a">The Mass to be multiplied.</param> |
| | 14201 | | /// <param name="b">The Length to multiply by.</param> |
| | 14202 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 14203 | | public static LinearMass<T> operator *(Mass<T> a, Length<T> b) |
| | 14204 | | { |
| | 14205 | | return Multiply(a, b); |
| | 14206 | | } |
| | 14207 | |
|
| | 14208 | | /// <summary>Mulitplies Mass by Length resulting in LinearMass.</summary> |
| | 14209 | | /// <param name="b">The Length to multiply by.</param> |
| | 14210 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 14211 | | public LinearMass<T> Multiply(Length<T> b) |
| | 14212 | | { |
| | 14213 | | return this * b; |
| | 14214 | | } |
| | 14215 | |
|
| | 14216 | | #endregion |
| | 14217 | |
|
| | 14218 | | #region Mass<T> * Speed<T> = LinearMassFlow<T> |
| | 14219 | |
|
| | 14220 | | /// <summary>Mulitplies Mass by Speed resulting in LinearMassFlow.</summary> |
| | 14221 | | /// <param name="a">The Mass to be multiplied.</param> |
| | 14222 | | /// <param name="b">The Speed to multiply by.</param> |
| | 14223 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 14224 | | public static LinearMassFlow<T> Multiply(Mass<T> a, Speed<T> b) |
| | 14225 | | { |
| | 14226 | |
|
| | 14227 | | T A = a[a._MassUnits1]; |
| | 14228 | | T B = b[b._LengthUnits1, b._TimeUnits2]; |
| | 14229 | | T C = Statics.Multiplication(A, B); |
| | 14230 | |
|
| | 14231 | | return new LinearMassFlow<T>(C |
| | 14232 | | , a._MassUnits1 |
| | 14233 | | , b._LengthUnits1 |
| | 14234 | | , b._TimeUnits2 |
| | 14235 | | ); |
| | 14236 | | } |
| | 14237 | |
|
| | 14238 | | /// <summary>Mulitplies Mass by Speed resulting in LinearMassFlow.</summary> |
| | 14239 | | /// <param name="a">The Mass to be multiplied.</param> |
| | 14240 | | /// <param name="b">The Speed to multiply by.</param> |
| | 14241 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 14242 | | public static LinearMassFlow<T> operator *(Mass<T> a, Speed<T> b) |
| | 14243 | | { |
| | 14244 | | return Multiply(a, b); |
| | 14245 | | } |
| | 14246 | |
|
| | 14247 | | /// <summary>Mulitplies Mass by Speed resulting in LinearMassFlow.</summary> |
| | 14248 | | /// <param name="b">The Speed to multiply by.</param> |
| | 14249 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 14250 | | public LinearMassFlow<T> Multiply(Speed<T> b) |
| | 14251 | | { |
| | 14252 | | return this * b; |
| | 14253 | | } |
| | 14254 | |
|
| | 14255 | | #endregion |
| | 14256 | |
|
| | 14257 | | #endregion |
| | 14258 | |
|
| | 14259 | | #region Divide |
| | 14260 | |
|
| | 14261 | | /// <summary>Divides an Mass measurement by another Mass measurement resulting in a scalar numeric value.</summary> |
| | 14262 | | /// <param name="a">The first operand of the division operation.</param> |
| | 14263 | | /// <param name="b">The second operand of the division operation.</param> |
| | 14264 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 14265 | | public static T Divide(Mass<T> a, Mass<T> b) |
| | 14266 | | { |
| | 14267 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 14268 | | T A = a[MassUnits1]; |
| | 14269 | | T B = b[MassUnits1]; |
| | 14270 | | return Statics.Division(A, B); |
| | 14271 | | } |
| | 14272 | |
|
| | 14273 | | /// <summary>Divides this Mass measurement by a numaric scalar value.</summary> |
| | 14274 | | /// <param name="a">The Mass measurement to divide.</param> |
| | 14275 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 14276 | | /// <returns>The result of the division.</returns> |
| | 14277 | | public static Mass<T> Divide(Mass<T> a, T b) |
| | 14278 | | { |
| | 14279 | | return MathBase(a, b, Statics.Division); |
| | 14280 | | } |
| | 14281 | |
|
| | 14282 | | /// <summary>Divides this Mass measurement by a numaric scalar value.</summary> |
| | 14283 | | /// <param name="a">The Mass measurement to divide.</param> |
| | 14284 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 14285 | | /// <returns>The result of the division.</returns> |
| | 14286 | | public static Mass<T> operator /(Mass<T> a, T b) |
| | 14287 | | { |
| | 14288 | | return Divide(a, b); |
| | 14289 | | } |
| | 14290 | |
|
| | 14291 | | /// <summary>Divides this Mass measurement by a numaric scalar value.</summary> |
| | 14292 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 14293 | | /// <returns>The result of the division.</returns> |
| | 14294 | | public Mass<T> Divide(T b) |
| | 14295 | | { |
| | 14296 | | return this / b; |
| | 14297 | | } |
| | 14298 | |
|
| | 14299 | | /// <summary>Divides an Mass measurement by another Mass measurement resulting in a scalar numeric value.</summary> |
| | 14300 | | /// <param name="a">The first operand of the division operation.</param> |
| | 14301 | | /// <param name="b">The second operand of the division operation.</param> |
| | 14302 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 14303 | | public static T operator /(Mass<T> a, Mass<T> b) |
| | 14304 | | { |
| | 14305 | | return Divide(a, b); |
| | 14306 | | } |
| | 14307 | |
|
| | 14308 | | /// <summary>Divides an Mass measurement by another Mass measurement resulting in a scalar numeric value.</summary> |
| | 14309 | | /// <param name="b">The second operand of the division operation.</param> |
| | 14310 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 14311 | | public T Divide(Mass<T> b) |
| | 14312 | | { |
| | 14313 | | return this / b; |
| | 14314 | | } |
| | 14315 | |
|
| | 14316 | |
|
| | 14317 | | #region Mass<T> / Area<T> = AreaDensity<T> |
| | 14318 | |
|
| | 14319 | | /// <summary>Divides Mass by Area resulting in AreaDensity.</summary> |
| | 14320 | | /// <param name="a">The Mass to be divided.</param> |
| | 14321 | | /// <param name="b">The Area to divide by.</param> |
| | 14322 | | /// <returns>The AreaDensity result of the division.</returns> |
| | 14323 | | public static AreaDensity<T> Divide(Mass<T> a, Area<T> b) |
| | 14324 | | { |
| | 14325 | |
|
| | 14326 | | T A = a[a._MassUnits1]; |
| | 14327 | | T B = b[b._LengthUnits1, b._LengthUnits2]; |
| | 14328 | | T C = Statics.Division(A, B); |
| | 14329 | |
|
| | 14330 | | return new AreaDensity<T>(C |
| | 14331 | | , a._MassUnits1 |
| | 14332 | | , b._LengthUnits1 |
| | 14333 | | , b._LengthUnits2 |
| | 14334 | | ); |
| | 14335 | | } |
| | 14336 | |
|
| | 14337 | | /// <summary>Divides Mass by Area resulting in AreaDensity.</summary> |
| | 14338 | | /// <param name="a">The Mass to be divided.</param> |
| | 14339 | | /// <param name="b">The Area to divide by.</param> |
| | 14340 | | /// <returns>The AreaDensity result of the division.</returns> |
| | 14341 | | public static AreaDensity<T> operator /(Mass<T> a, Area<T> b) |
| | 14342 | | { |
| | 14343 | | return Divide(a, b); |
| | 14344 | | } |
| | 14345 | |
|
| | 14346 | | /// <summary>Divides Mass by Area resulting in AreaDensity.</summary> |
| | 14347 | | /// <param name="b">The Area to divide by.</param> |
| | 14348 | | /// <returns>The AreaDensity result of the division.</returns> |
| | 14349 | | public AreaDensity<T> Divide(Area<T> b) |
| | 14350 | | { |
| | 14351 | | return this / b; |
| | 14352 | | } |
| | 14353 | |
|
| | 14354 | | #endregion |
| | 14355 | |
|
| | 14356 | |
|
| | 14357 | | #region Mass<T> / AreaDensity<T> = Area<T> |
| | 14358 | |
|
| | 14359 | | /// <summary>Divides Mass by AreaDensity resulting in Area.</summary> |
| | 14360 | | /// <param name="a">The Mass to be divided.</param> |
| | 14361 | | /// <param name="b">The AreaDensity to divide by.</param> |
| | 14362 | | /// <returns>The Area result of the division.</returns> |
| | 14363 | | public static Area<T> Divide(Mass<T> a, AreaDensity<T> b) |
| | 14364 | | { |
| | 14365 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 14366 | |
|
| | 14367 | | T A = a[MassUnits1]; |
| | 14368 | | T B = b[MassUnits1, b._LengthUnits2, b._LengthUnits3]; |
| | 14369 | | T C = Statics.Division(A, B); |
| | 14370 | |
|
| | 14371 | | return new Area<T>(C |
| | 14372 | | , b._LengthUnits2 |
| | 14373 | | , b._LengthUnits3 |
| | 14374 | | ); |
| | 14375 | | } |
| | 14376 | |
|
| | 14377 | | /// <summary>Divides Mass by AreaDensity resulting in Area.</summary> |
| | 14378 | | /// <param name="a">The Mass to be divided.</param> |
| | 14379 | | /// <param name="b">The AreaDensity to divide by.</param> |
| | 14380 | | /// <returns>The Area result of the division.</returns> |
| | 14381 | | public static Area<T> operator /(Mass<T> a, AreaDensity<T> b) |
| | 14382 | | { |
| | 14383 | | return Divide(a, b); |
| | 14384 | | } |
| | 14385 | |
|
| | 14386 | | /// <summary>Divides Mass by AreaDensity resulting in Area.</summary> |
| | 14387 | | /// <param name="b">The AreaDensity to divide by.</param> |
| | 14388 | | /// <returns>The Area result of the division.</returns> |
| | 14389 | | public Area<T> Divide(AreaDensity<T> b) |
| | 14390 | | { |
| | 14391 | | return this / b; |
| | 14392 | | } |
| | 14393 | |
|
| | 14394 | | #endregion |
| | 14395 | |
|
| | 14396 | |
|
| | 14397 | | #region Mass<T> / Density<T> = Volume<T> |
| | 14398 | |
|
| | 14399 | | /// <summary>Divides Mass by Density resulting in Volume.</summary> |
| | 14400 | | /// <param name="a">The Mass to be divided.</param> |
| | 14401 | | /// <param name="b">The Density to divide by.</param> |
| | 14402 | | /// <returns>The Volume result of the division.</returns> |
| | 14403 | | public static Volume<T> Divide(Mass<T> a, Density<T> b) |
| | 14404 | | { |
| | 14405 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 14406 | |
|
| | 14407 | | T A = a[MassUnits1]; |
| | 14408 | | T B = b[MassUnits1, b._LengthUnits2, b._LengthUnits3, b._LengthUnits4]; |
| | 14409 | | T C = Statics.Division(A, B); |
| | 14410 | |
|
| | 14411 | | return new Volume<T>(C |
| | 14412 | | , b._LengthUnits2 |
| | 14413 | | , b._LengthUnits3 |
| | 14414 | | , b._LengthUnits4 |
| | 14415 | | ); |
| | 14416 | | } |
| | 14417 | |
|
| | 14418 | | /// <summary>Divides Mass by Density resulting in Volume.</summary> |
| | 14419 | | /// <param name="a">The Mass to be divided.</param> |
| | 14420 | | /// <param name="b">The Density to divide by.</param> |
| | 14421 | | /// <returns>The Volume result of the division.</returns> |
| | 14422 | | public static Volume<T> operator /(Mass<T> a, Density<T> b) |
| | 14423 | | { |
| | 14424 | | return Divide(a, b); |
| | 14425 | | } |
| | 14426 | |
|
| | 14427 | | /// <summary>Divides Mass by Density resulting in Volume.</summary> |
| | 14428 | | /// <param name="b">The Density to divide by.</param> |
| | 14429 | | /// <returns>The Volume result of the division.</returns> |
| | 14430 | | public Volume<T> Divide(Density<T> b) |
| | 14431 | | { |
| | 14432 | | return this / b; |
| | 14433 | | } |
| | 14434 | |
|
| | 14435 | | #endregion |
| | 14436 | |
|
| | 14437 | |
|
| | 14438 | | #region Mass<T> / Length<T> = LinearDensity<T> |
| | 14439 | |
|
| | 14440 | | /// <summary>Divides Mass by Length resulting in LinearDensity.</summary> |
| | 14441 | | /// <param name="a">The Mass to be divided.</param> |
| | 14442 | | /// <param name="b">The Length to divide by.</param> |
| | 14443 | | /// <returns>The LinearDensity result of the division.</returns> |
| | 14444 | | public static LinearDensity<T> Divide(Mass<T> a, Length<T> b) |
| | 14445 | | { |
| | 14446 | |
|
| | 14447 | | T A = a[a._MassUnits1]; |
| | 14448 | | T B = b[b._LengthUnits1]; |
| | 14449 | | T C = Statics.Division(A, B); |
| | 14450 | |
|
| | 14451 | | return new LinearDensity<T>(C |
| | 14452 | | , a._MassUnits1 |
| | 14453 | | , b._LengthUnits1 |
| | 14454 | | ); |
| | 14455 | | } |
| | 14456 | |
|
| | 14457 | | /// <summary>Divides Mass by Length resulting in LinearDensity.</summary> |
| | 14458 | | /// <param name="a">The Mass to be divided.</param> |
| | 14459 | | /// <param name="b">The Length to divide by.</param> |
| | 14460 | | /// <returns>The LinearDensity result of the division.</returns> |
| | 14461 | | public static LinearDensity<T> operator /(Mass<T> a, Length<T> b) |
| | 14462 | | { |
| | 14463 | | return Divide(a, b); |
| | 14464 | | } |
| | 14465 | |
|
| | 14466 | | /// <summary>Divides Mass by Length resulting in LinearDensity.</summary> |
| | 14467 | | /// <param name="b">The Length to divide by.</param> |
| | 14468 | | /// <returns>The LinearDensity result of the division.</returns> |
| | 14469 | | public LinearDensity<T> Divide(Length<T> b) |
| | 14470 | | { |
| | 14471 | | return this / b; |
| | 14472 | | } |
| | 14473 | |
|
| | 14474 | | #endregion |
| | 14475 | |
|
| | 14476 | |
|
| | 14477 | | #region Mass<T> / LinearDensity<T> = Length<T> |
| | 14478 | |
|
| | 14479 | | /// <summary>Divides Mass by LinearDensity resulting in Length.</summary> |
| | 14480 | | /// <param name="a">The Mass to be divided.</param> |
| | 14481 | | /// <param name="b">The LinearDensity to divide by.</param> |
| | 14482 | | /// <returns>The Length result of the division.</returns> |
| | 14483 | | public static Length<T> Divide(Mass<T> a, LinearDensity<T> b) |
| | 14484 | | { |
| | 14485 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 14486 | |
|
| | 14487 | | T A = a[MassUnits1]; |
| | 14488 | | T B = b[MassUnits1, b._LengthUnits2]; |
| | 14489 | | T C = Statics.Division(A, B); |
| | 14490 | |
|
| | 14491 | | return new Length<T>(C |
| | 14492 | | , b._LengthUnits2 |
| | 14493 | | ); |
| | 14494 | | } |
| | 14495 | |
|
| | 14496 | | /// <summary>Divides Mass by LinearDensity resulting in Length.</summary> |
| | 14497 | | /// <param name="a">The Mass to be divided.</param> |
| | 14498 | | /// <param name="b">The LinearDensity to divide by.</param> |
| | 14499 | | /// <returns>The Length result of the division.</returns> |
| | 14500 | | public static Length<T> operator /(Mass<T> a, LinearDensity<T> b) |
| | 14501 | | { |
| | 14502 | | return Divide(a, b); |
| | 14503 | | } |
| | 14504 | |
|
| | 14505 | | /// <summary>Divides Mass by LinearDensity resulting in Length.</summary> |
| | 14506 | | /// <param name="b">The LinearDensity to divide by.</param> |
| | 14507 | | /// <returns>The Length result of the division.</returns> |
| | 14508 | | public Length<T> Divide(LinearDensity<T> b) |
| | 14509 | | { |
| | 14510 | | return this / b; |
| | 14511 | | } |
| | 14512 | |
|
| | 14513 | | #endregion |
| | 14514 | |
|
| | 14515 | |
|
| | 14516 | | #region Mass<T> / MassRate<T> = Time<T> |
| | 14517 | |
|
| | 14518 | | /// <summary>Divides Mass by MassRate resulting in Time.</summary> |
| | 14519 | | /// <param name="a">The Mass to be divided.</param> |
| | 14520 | | /// <param name="b">The MassRate to divide by.</param> |
| | 14521 | | /// <returns>The Time result of the division.</returns> |
| | 14522 | | public static Time<T> Divide(Mass<T> a, MassRate<T> b) |
| | 14523 | | { |
| | 14524 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 14525 | |
|
| | 14526 | | T A = a[MassUnits1]; |
| | 14527 | | T B = b[MassUnits1, b._TimeUnits2]; |
| | 14528 | | T C = Statics.Division(A, B); |
| | 14529 | |
|
| | 14530 | | return new Time<T>(C |
| | 14531 | | , b._TimeUnits2 |
| | 14532 | | ); |
| | 14533 | | } |
| | 14534 | |
|
| | 14535 | | /// <summary>Divides Mass by MassRate resulting in Time.</summary> |
| | 14536 | | /// <param name="a">The Mass to be divided.</param> |
| | 14537 | | /// <param name="b">The MassRate to divide by.</param> |
| | 14538 | | /// <returns>The Time result of the division.</returns> |
| | 14539 | | public static Time<T> operator /(Mass<T> a, MassRate<T> b) |
| | 14540 | | { |
| | 14541 | | return Divide(a, b); |
| | 14542 | | } |
| | 14543 | |
|
| | 14544 | | /// <summary>Divides Mass by MassRate resulting in Time.</summary> |
| | 14545 | | /// <param name="b">The MassRate to divide by.</param> |
| | 14546 | | /// <returns>The Time result of the division.</returns> |
| | 14547 | | public Time<T> Divide(MassRate<T> b) |
| | 14548 | | { |
| | 14549 | | return this / b; |
| | 14550 | | } |
| | 14551 | |
|
| | 14552 | | #endregion |
| | 14553 | |
|
| | 14554 | |
|
| | 14555 | | #region Mass<T> / Time<T> = MassRate<T> |
| | 14556 | |
|
| | 14557 | | /// <summary>Divides Mass by Time resulting in MassRate.</summary> |
| | 14558 | | /// <param name="a">The Mass to be divided.</param> |
| | 14559 | | /// <param name="b">The Time to divide by.</param> |
| | 14560 | | /// <returns>The MassRate result of the division.</returns> |
| | 14561 | | public static MassRate<T> Divide(Mass<T> a, Time<T> b) |
| | 14562 | | { |
| | 14563 | |
|
| | 14564 | | T A = a[a._MassUnits1]; |
| | 14565 | | T B = b[b._TimeUnits1]; |
| | 14566 | | T C = Statics.Division(A, B); |
| | 14567 | |
|
| | 14568 | | return new MassRate<T>(C |
| | 14569 | | , a._MassUnits1 |
| | 14570 | | , b._TimeUnits1 |
| | 14571 | | ); |
| | 14572 | | } |
| | 14573 | |
|
| | 14574 | | /// <summary>Divides Mass by Time resulting in MassRate.</summary> |
| | 14575 | | /// <param name="a">The Mass to be divided.</param> |
| | 14576 | | /// <param name="b">The Time to divide by.</param> |
| | 14577 | | /// <returns>The MassRate result of the division.</returns> |
| | 14578 | | public static MassRate<T> operator /(Mass<T> a, Time<T> b) |
| | 14579 | | { |
| | 14580 | | return Divide(a, b); |
| | 14581 | | } |
| | 14582 | |
|
| | 14583 | | /// <summary>Divides Mass by Time resulting in MassRate.</summary> |
| | 14584 | | /// <param name="b">The Time to divide by.</param> |
| | 14585 | | /// <returns>The MassRate result of the division.</returns> |
| | 14586 | | public MassRate<T> Divide(Time<T> b) |
| | 14587 | | { |
| | 14588 | | return this / b; |
| | 14589 | | } |
| | 14590 | |
|
| | 14591 | | #endregion |
| | 14592 | |
|
| | 14593 | |
|
| | 14594 | | #region Mass<T> / Volume<T> = Density<T> |
| | 14595 | |
|
| | 14596 | | /// <summary>Divides Mass by Volume resulting in Density.</summary> |
| | 14597 | | /// <param name="a">The Mass to be divided.</param> |
| | 14598 | | /// <param name="b">The Volume to divide by.</param> |
| | 14599 | | /// <returns>The Density result of the division.</returns> |
| | 14600 | | public static Density<T> Divide(Mass<T> a, Volume<T> b) |
| | 14601 | | { |
| | 14602 | |
|
| | 14603 | | T A = a[a._MassUnits1]; |
| | 14604 | | T B = b[b._LengthUnits1, b._LengthUnits2, b._LengthUnits3]; |
| | 14605 | | T C = Statics.Division(A, B); |
| | 14606 | |
|
| | 14607 | | return new Density<T>(C |
| | 14608 | | , a._MassUnits1 |
| | 14609 | | , b._LengthUnits1 |
| | 14610 | | , b._LengthUnits2 |
| | 14611 | | , b._LengthUnits3 |
| | 14612 | | ); |
| | 14613 | | } |
| | 14614 | |
|
| | 14615 | | /// <summary>Divides Mass by Volume resulting in Density.</summary> |
| | 14616 | | /// <param name="a">The Mass to be divided.</param> |
| | 14617 | | /// <param name="b">The Volume to divide by.</param> |
| | 14618 | | /// <returns>The Density result of the division.</returns> |
| | 14619 | | public static Density<T> operator /(Mass<T> a, Volume<T> b) |
| | 14620 | | { |
| | 14621 | | return Divide(a, b); |
| | 14622 | | } |
| | 14623 | |
|
| | 14624 | | /// <summary>Divides Mass by Volume resulting in Density.</summary> |
| | 14625 | | /// <param name="b">The Volume to divide by.</param> |
| | 14626 | | /// <returns>The Density result of the division.</returns> |
| | 14627 | | public Density<T> Divide(Volume<T> b) |
| | 14628 | | { |
| | 14629 | | return this / b; |
| | 14630 | | } |
| | 14631 | |
|
| | 14632 | | #endregion |
| | 14633 | |
|
| | 14634 | | #endregion |
| | 14635 | |
|
| | 14636 | | #region LessThan |
| | 14637 | |
|
| | 14638 | | /// <summary>Determines if an Mass measurement is less than another Mass measurement.</summary> |
| | 14639 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 14640 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 14641 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 14642 | | public static bool LessThan(Mass<T> a, Mass<T> b) |
| | 14643 | | { |
| | 14644 | | return LogicBase(a, b, Statics.LessThan); |
| | 14645 | | } |
| | 14646 | |
|
| | 14647 | | /// <summary>Determines if an Mass measurement is less than another Mass measurement.</summary> |
| | 14648 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 14649 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 14650 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 14651 | | public static bool operator <(Mass<T> a, Mass<T> b) |
| | 14652 | | { |
| | 14653 | | return LessThan(a, b); |
| | 14654 | | } |
| | 14655 | |
|
| | 14656 | | /// <summary>Determines if an Mass measurement is less than another Mass measurement.</summary> |
| | 14657 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 14658 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 14659 | | public bool LessThan(Mass<T> b) |
| | 14660 | | { |
| | 14661 | | return this < b; |
| | 14662 | | } |
| | 14663 | |
|
| | 14664 | | #endregion |
| | 14665 | |
|
| | 14666 | | #region GreaterThan |
| | 14667 | |
|
| | 14668 | | /// <summary>Determines if an Mass measurement is greater than another Mass measurement.</summary> |
| | 14669 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 14670 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 14671 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 14672 | | public static bool GreaterThan(Mass<T> a, Mass<T> b) |
| | 14673 | | { |
| | 14674 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 14675 | | } |
| | 14676 | |
|
| | 14677 | | /// <summary>Determines if an Mass measurement is greater than another Mass measurement.</summary> |
| | 14678 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 14679 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 14680 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 14681 | | public static bool operator >(Mass<T> a, Mass<T> b) |
| | 14682 | | { |
| | 14683 | | return GreaterThan(a, b); |
| | 14684 | | } |
| | 14685 | |
|
| | 14686 | | /// <summary>Determines if an Mass measurement is greater than another Mass measurement.</summary> |
| | 14687 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 14688 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 14689 | | public bool GreaterThan(Mass<T> b) |
| | 14690 | | { |
| | 14691 | | return this > b; |
| | 14692 | | } |
| | 14693 | |
|
| | 14694 | | #endregion |
| | 14695 | |
|
| | 14696 | | #region LessThanOrEqual |
| | 14697 | |
|
| | 14698 | | /// <summary>Determines if an Mass measurement is less than or equal to another Mass measurement.</summary> |
| | 14699 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 14700 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 14701 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 14702 | | public static bool LessThanOrEqual(Mass<T> a, Mass<T> b) |
| | 14703 | | { |
| | 14704 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 14705 | | } |
| | 14706 | |
|
| | 14707 | | /// <summary>Determines if an Mass measurement is less than or equal to another Mass measurement.</summary> |
| | 14708 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 14709 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 14710 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 14711 | | public static bool operator <=(Mass<T> a, Mass<T> b) |
| | 14712 | | { |
| | 14713 | | return LessThanOrEqual(a, b); |
| | 14714 | | } |
| | 14715 | |
|
| | 14716 | | /// <summary>Determines if an Mass measurement is less than or equal to another Mass measurement.</summary> |
| | 14717 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 14718 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 14719 | | public bool LessThanOrEqual(Mass<T> b) |
| | 14720 | | { |
| | 14721 | | return this <= b; |
| | 14722 | | } |
| | 14723 | |
|
| | 14724 | | #endregion |
| | 14725 | |
|
| | 14726 | | #region GreaterThanOrEqual |
| | 14727 | |
|
| | 14728 | | /// <summary>Determines if an Mass measurement is greater than or equal to another Mass measurement.</summary> |
| | 14729 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 14730 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 14731 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 14732 | | public static bool GreaterThanOrEqual(Mass<T> a, Mass<T> b) |
| | 14733 | | { |
| | 14734 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 14735 | | } |
| | 14736 | |
|
| | 14737 | | /// <summary>Determines if an Mass measurement is greater than or equal to another Mass measurement.</summary> |
| | 14738 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 14739 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 14740 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 14741 | | public static bool operator >=(Mass<T> a, Mass<T> b) |
| | 14742 | | { |
| | 14743 | | return GreaterThanOrEqual(a, b); |
| | 14744 | | } |
| | 14745 | |
|
| | 14746 | | /// <summary>Determines if an Mass measurement is greater than or equal to another Mass measurement.</summary> |
| | 14747 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 14748 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 14749 | | public bool GreaterThanOrEqual(Mass<T> b) |
| | 14750 | | { |
| | 14751 | | return this >= b; |
| | 14752 | | } |
| | 14753 | |
|
| | 14754 | | #endregion |
| | 14755 | |
|
| | 14756 | | #region Equal |
| | 14757 | |
|
| | 14758 | | /// <summary>Determines if an Mass measurement is equal to another Mass measurement.</summary> |
| | 14759 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 14760 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 14761 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 14762 | | public static bool Equal(Mass<T> a, Mass<T> b) |
| | 14763 | | { |
| | 14764 | | return LogicBase(a, b, Statics.Equate); |
| | 14765 | | } |
| | 14766 | |
|
| | 14767 | | /// <summary>Determines if an Mass measurement is equal to another Mass measurement.</summary> |
| | 14768 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 14769 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 14770 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 14771 | | public static bool operator ==(Mass<T> a, Mass<T> b) |
| | 14772 | | { |
| | 14773 | | return Equal(a, b); |
| | 14774 | | } |
| | 14775 | |
|
| | 14776 | | /// <summary>Determines if an Mass measurement is equal to another Mass measurement.</summary> |
| | 14777 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 14778 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 14779 | | public bool Equal(Mass<T> b) |
| | 14780 | | { |
| | 14781 | | return this == b; |
| | 14782 | | } |
| | 14783 | |
|
| | 14784 | | #endregion |
| | 14785 | |
|
| | 14786 | | #region NotEqual |
| | 14787 | |
|
| | 14788 | | /// <summary>Determines if an Mass measurement is not equal to another Mass measurement.</summary> |
| | 14789 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 14790 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 14791 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 14792 | | public static bool NotEqual(Mass<T> a, Mass<T> b) |
| | 14793 | | { |
| | 14794 | | return LogicBase(a, b, Statics.Inequate); |
| | 14795 | | } |
| | 14796 | |
|
| | 14797 | | /// <summary>Determines if an Mass measurement is not equal to another Mass measurement.</summary> |
| | 14798 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 14799 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 14800 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 14801 | | public static bool operator !=(Mass<T> a, Mass<T> b) |
| | 14802 | | { |
| | 14803 | | return NotEqual(a, b); |
| | 14804 | | } |
| | 14805 | |
|
| | 14806 | | /// <summary>Determines if an Mass measurement is not equal to another Mass measurement.</summary> |
| | 14807 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 14808 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 14809 | | public bool NotEqual(Mass<T> b) |
| | 14810 | | { |
| | 14811 | | return this != b; |
| | 14812 | | } |
| | 14813 | |
|
| | 14814 | | #endregion |
| | 14815 | |
|
| | 14816 | | #endregion |
| | 14817 | |
|
| | 14818 | | #region Overrides |
| | 14819 | |
|
| | 14820 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 14821 | | /// <param name="obj">The object to check for equality with.</param> |
| | 14822 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 14823 | | public override bool Equals(object obj) |
| | 14824 | | { |
| | 14825 | | if (obj is Mass<T>) |
| | 14826 | | { |
| | 14827 | | return this == (Mass<T>)obj; |
| | 14828 | | } |
| | 14829 | | return false; |
| | 14830 | | } |
| | 14831 | |
|
| | 14832 | | /// <summary>Converts the Mass measurement to a string represenation.</summary> |
| | 14833 | | /// <returns>The string representation of the measurement.</returns> |
| | 14834 | | public override string ToString() |
| | 14835 | | { |
| | 14836 | | return _measurement + " " + |
| | 14837 | | _MassUnits1 |
| | 14838 | |
|
| | 14839 | | ; |
| | 14840 | | } |
| | 14841 | |
|
| | 14842 | | /// <summary>Base hashing function for Mass measurements.</summary> |
| | 14843 | | /// <returns>Computed hash code for this instance.</returns> |
| | 14844 | | public override int GetHashCode() => Hash(_measurement); |
| | 14845 | |
|
| | 14846 | | #endregion |
| | 14847 | | } |
| | 14848 | |
|
| | 14849 | | #endregion |
| | 14850 | |
|
| | 14851 | | #region MassRate |
| | 14852 | |
|
| | 14853 | | internal static partial class ParsingFunctions |
| | 14854 | | { |
| | 14855 | | [Measurement.Parseable("Mass/Time")] |
| | 14856 | | public static object MassRate<T>(T value, object[] units) |
| | 14857 | | { |
| | 14858 | | if (units.Length != 2) |
| | 14859 | | { |
| | 14860 | | throw new Exception("Bug in Towel. Invalid parameters to MassRate Factory."); |
| | 14861 | | } |
| | 14862 | | if (!(units[0] is Mass.Units)) |
| | 14863 | | { |
| | 14864 | | throw new Exception("Bug in Towel. Invalid parameters to MassRate Factory."); |
| | 14865 | | } |
| | 14866 | | if (!(units[1] is Time.Units)) |
| | 14867 | | { |
| | 14868 | | throw new Exception("Bug in Towel. Invalid parameters to MassRate Factory."); |
| | 14869 | | } |
| | 14870 | | return new MassRate<T>(value |
| | 14871 | | , (Mass.Units)units[0] |
| | 14872 | | , (Time.Units)units[1] |
| | 14873 | | ); |
| | 14874 | | } |
| | 14875 | | } |
| | 14876 | |
|
| | 14877 | | /// <summary>MassRate measurement with a value and the units.</summary> |
| | 14878 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 14879 | | public struct MassRate<T> |
| | 14880 | | { |
| | 14881 | | internal T _measurement; |
| | 14882 | | internal Mass.Units _MassUnits1; |
| | 14883 | | internal Time.Units _TimeUnits2; |
| | 14884 | |
|
| | 14885 | | #region Statics |
| | 14886 | |
|
| | 14887 | | /// <summary>Converts a MassRate measurement from units to another.</summary> |
| | 14888 | | /// <param name="value">The value to convert the units of.</param> |
| | 14889 | | /// <param name="fromMassUnits1">The current units of the measurement.</param> |
| | 14890 | | /// <param name="fromTimeUnits2">The current units of the measurement.</param> |
| | 14891 | | /// <param name="toMassUnits1">The desired units of the measurement.</param> |
| | 14892 | | /// <param name="toTimeUnits2">The desired units of the measurement.</param> |
| | 14893 | | /// <returns>The MassRate measurement converted into the desired units.</returns> |
| | 14894 | | public static T Convert(T value |
| | 14895 | | , Mass.Units fromMassUnits1 |
| | 14896 | | , Time.Units fromTimeUnits2 |
| | 14897 | | , Mass.Units toMassUnits1 |
| | 14898 | | , Time.Units toTimeUnits2 |
| | 14899 | | ) |
| | 14900 | | { |
| | 14901 | | MassRate<T> measurement = new MassRate<T>(value |
| | 14902 | | , fromMassUnits1 |
| | 14903 | | , fromTimeUnits2 |
| | 14904 | | ); |
| | 14905 | | return measurement[ |
| | 14906 | | toMassUnits1 |
| | 14907 | | , toTimeUnits2 |
| | 14908 | | ]; |
| | 14909 | | } |
| | 14910 | |
|
| | 14911 | | /// <summary>Converts a MassRate measurement from units to another.</summary> |
| | 14912 | | /// <param name="value">The value to convert the units of.</param> |
| | 14913 | | /// <param name="from">The current units of the measurement.</param> |
| | 14914 | | /// <param name="to">The desired units of the measurement.</param> |
| | 14915 | | /// <returns>The MassRate measurement converted into the desired units.</returns> |
| | 14916 | | public static T Convert(T value, |
| | 14917 | | MeasurementUnitsSyntaxTypes.MassRateBaseUnits from, |
| | 14918 | | MeasurementUnitsSyntaxTypes.MassRateBaseUnits to) |
| | 14919 | | { |
| | 14920 | | return Convert(value |
| | 14921 | | , from._MassUnits1 |
| | 14922 | | , from._TimeUnits2 |
| | 14923 | | , to._MassUnits1 |
| | 14924 | | , to._TimeUnits2 |
| | 14925 | | ); |
| | 14926 | | } |
| | 14927 | |
|
| | 14928 | | /// <summary>Parses a MassRate measurement string.</summary> |
| | 14929 | | /// <param name="string">The string to be parsed.</param> |
| | 14930 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 14931 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 14932 | | public static (bool Success, MassRate<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value)> tryP |
| | 14933 | |
|
| | 14934 | | #endregion |
| | 14935 | |
|
| | 14936 | | #region Constructors |
| | 14937 | |
|
| | 14938 | | /// <summary>Constructs an MassRate with the measurement value and units.</summary> |
| | 14939 | | /// <param name="measurement">The measurement value of the MassRate.</param> |
| | 14940 | | /// <param name="units">The units of the MassRate.</param> |
| | 14941 | | public MassRate(T measurement, MeasurementUnitsSyntaxTypes.MassRateBaseUnits units) : this(measurement |
| | 14942 | | , units._MassUnits1 |
| | 14943 | | , units._TimeUnits2 |
| | 14944 | | ) { } |
| | 14945 | |
|
| | 14946 | |
|
| | 14947 | | /// <summary>Constructs an MassRate with the measurement value and units.</summary> |
| | 14948 | | /// <param name="measurement">The measurement value of the MassRate.</param> |
| | 14949 | | /// <param name="MassUnits1">The units of the MassRate.</param> |
| | 14950 | | /// <param name="TimeUnits2">The units of the MassRate.</param> |
| | 14951 | | public MassRate(T measurement |
| | 14952 | | , Mass.Units MassUnits1 |
| | 14953 | | , Time.Units TimeUnits2 |
| | 14954 | | ) |
| | 14955 | | { |
| | 14956 | | _measurement = measurement; |
| | 14957 | | _MassUnits1 = MassUnits1; |
| | 14958 | | _TimeUnits2 = TimeUnits2; |
| | 14959 | | } |
| | 14960 | |
|
| | 14961 | | #endregion |
| | 14962 | |
|
| | 14963 | | #region Properties |
| | 14964 | |
|
| | 14965 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 14966 | | public Mass.Units MassUnits1 |
| | 14967 | | { |
| | 14968 | | get { return _MassUnits1; } |
| | 14969 | | set |
| | 14970 | | { |
| | 14971 | | if (value != _MassUnits1) |
| | 14972 | | { |
| | 14973 | | _measurement = this[value, _TimeUnits2]; |
| | 14974 | | _MassUnits1 = value; |
| | 14975 | | } |
| | 14976 | | } |
| | 14977 | | } |
| | 14978 | |
|
| | 14979 | | /// <summary>The #2 component of this measurements units.</summary> |
| | 14980 | | public Time.Units TimeUnits2 |
| | 14981 | | { |
| | 14982 | | get { return _TimeUnits2; } |
| | 14983 | | set |
| | 14984 | | { |
| | 14985 | | if (value != _TimeUnits2) |
| | 14986 | | { |
| | 14987 | | _measurement = this[_MassUnits1, value]; |
| | 14988 | | _TimeUnits2 = value; |
| | 14989 | | } |
| | 14990 | | } |
| | 14991 | | } |
| | 14992 | |
|
| | 14993 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 14994 | | /// <param name="units">The units to get the measurement in.</param> |
| | 14995 | | /// <returns>The measurement value in the specified units.</returns> |
| | 14996 | | public T this[MeasurementUnitsSyntaxTypes.MassRateBaseUnits units] |
| | 14997 | | { |
| | 14998 | | get { return this[units._MassUnits1, units._TimeUnits2]; } |
| | 14999 | | } |
| | 15000 | |
|
| | 15001 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 15002 | | /// <param name="MassUnits1">The #1 component of this measurements units.</param> |
| | 15003 | | /// <param name="TimeUnits2">The #2 component of this measurements units.</param> |
| | 15004 | | /// <returns>The measurement value in the specified units.</returns> |
| | 15005 | | public T this[Mass.Units MassUnits1, Time.Units TimeUnits2] |
| | 15006 | | { |
| | 15007 | | get |
| | 15008 | | { |
| | 15009 | | T measurement = _measurement; |
| | 15010 | | if (MassUnits1 != _MassUnits1) |
| | 15011 | | { |
| | 15012 | | measurement = Mass<T>.Table[(int)_MassUnits1][(int)MassUnits1](measurement); |
| | 15013 | | //if (MassUnits1 < _MassUnits1) |
| | 15014 | | //{ |
| | 15015 | | // measurement = Mass<T>.Table[(int)_MassUnits1][(int)MassUnits1](measurement); |
| | 15016 | | //} |
| | 15017 | | //else |
| | 15018 | | //{ |
| | 15019 | | // measurement = Mass<T>.Table[(int)MassUnits1][(int)_MassUnits1](measurement); |
| | 15020 | | //} |
| | 15021 | | } |
| | 15022 | | if (TimeUnits2 != _TimeUnits2) |
| | 15023 | | { |
| | 15024 | | measurement = Time<T>.Table[(int)TimeUnits2][(int)_TimeUnits2](measurement); |
| | 15025 | | //if (TimeUnits2 > _TimeUnits2) |
| | 15026 | | //{ |
| | 15027 | | // measurement = Time<T>.Table[(int)_TimeUnits2][(int)TimeUnits2](measurement); |
| | 15028 | | //} |
| | 15029 | | //else |
| | 15030 | | //{ |
| | 15031 | | // measurement = Time<T>.Table[(int)TimeUnits2][(int)_TimeUnits2](measurement); |
| | 15032 | | //} |
| | 15033 | | } |
| | 15034 | | return measurement; |
| | 15035 | | } |
| | 15036 | | } |
| | 15037 | |
|
| | 15038 | | #endregion |
| | 15039 | |
|
| | 15040 | | #region Casting Operators |
| | 15041 | |
|
| | 15042 | | /// <summary>Converts a ValueTuple to a MassRate measurement.</summary> |
| | 15043 | | /// <param name="valueTuple">The ValueTuple to converted into a MassRate measurement.</param> |
| | 15044 | | public static implicit operator MassRate<T>((T, MeasurementUnitsSyntaxTypes.MassRateBaseUnits) valueTuple) |
| | 15045 | | { |
| | 15046 | | return new MassRate<T>(valueTuple.Item1, valueTuple.Item2); |
| | 15047 | | } |
| | 15048 | |
|
| | 15049 | | #endregion |
| | 15050 | |
|
| | 15051 | | #region Mathematics |
| | 15052 | |
|
| | 15053 | | #region Bases |
| | 15054 | |
|
| | 15055 | | internal static MassRate<T> MathBase(MassRate<T> a, T b, Func<T, T, T> func) |
| | 15056 | | { |
| | 15057 | | return new MassRate<T>(func(a._measurement, b) |
| | 15058 | | , a._MassUnits1 |
| | 15059 | | , a._TimeUnits2 |
| | 15060 | | ); |
| | 15061 | | } |
| | 15062 | |
|
| | 15063 | | internal static MassRate<T> MathBase(MassRate<T> a, MassRate<T> b, Func<T, T, T> func) |
| | 15064 | | { |
| | 15065 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 15066 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 15067 | | T A = a[MassUnits1, TimeUnits2]; |
| | 15068 | | T B = b[MassUnits1, TimeUnits2]; |
| | 15069 | | T C = func(A, B); |
| | 15070 | | return new MassRate<T>(C, MassUnits1, TimeUnits2); |
| | 15071 | | } |
| | 15072 | |
|
| | 15073 | | internal static bool LogicBase(MassRate<T> a, MassRate<T> b, Func<T, T, bool> func) |
| | 15074 | | { |
| | 15075 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 15076 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 15077 | | T A = a[MassUnits1, TimeUnits2]; |
| | 15078 | | T B = b[MassUnits1, TimeUnits2]; |
| | 15079 | | return func(A, B); |
| | 15080 | | } |
| | 15081 | |
|
| | 15082 | | #endregion |
| | 15083 | |
|
| | 15084 | | #region Add |
| | 15085 | |
|
| | 15086 | | /// <summary>Adds two MassRate measurements.</summary> |
| | 15087 | | /// <param name="a">The first operand of the addition.</param> |
| | 15088 | | /// <param name="b">The second operand of the addition.</param> |
| | 15089 | | /// <returns>The result of the addition operation.</returns> |
| | 15090 | | public static MassRate<T> Add(MassRate<T> a, MassRate<T> b) |
| | 15091 | | { |
| | 15092 | | return MathBase(a, b, Statics.Addition); |
| | 15093 | | } |
| | 15094 | |
|
| | 15095 | | /// <summary>Adds two MassRate measurements.</summary> |
| | 15096 | | /// <param name="a">The first operand of the addition.</param> |
| | 15097 | | /// <param name="b">The second operand of the addition.</param> |
| | 15098 | | /// <returns>The result of the addition operation.</returns> |
| | 15099 | | public static MassRate<T> operator +(MassRate<T> a, MassRate<T> b) |
| | 15100 | | { |
| | 15101 | | return Add(a, b); |
| | 15102 | | } |
| | 15103 | |
|
| | 15104 | | /// <summary>Adds two MassRate measurements.</summary> |
| | 15105 | | /// <param name="b">The second operand of the addition.</param> |
| | 15106 | | /// <returns>The result of the addition operation.</returns> |
| | 15107 | | public MassRate<T> Add(MassRate<T> b) |
| | 15108 | | { |
| | 15109 | | return this + b; |
| | 15110 | | } |
| | 15111 | |
|
| | 15112 | | #endregion |
| | 15113 | |
|
| | 15114 | | #region Subtract |
| | 15115 | |
|
| | 15116 | | /// <summary>Subtracts two MassRate measurements.</summary> |
| | 15117 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 15118 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 15119 | | /// <returns>The result of the subtraction.</returns> |
| | 15120 | | public static MassRate<T> Subtract(MassRate<T> a, MassRate<T> b) |
| | 15121 | | { |
| | 15122 | | return MathBase(a, b, Statics.Subtraction); |
| | 15123 | | } |
| | 15124 | |
|
| | 15125 | | /// <summary>Subtracts two MassRate measurements.</summary> |
| | 15126 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 15127 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 15128 | | /// <returns>The result of the subtraction.</returns> |
| | 15129 | | public static MassRate<T> operator -(MassRate<T> a, MassRate<T> b) |
| | 15130 | | { |
| | 15131 | | return Subtract(a, b); |
| | 15132 | | } |
| | 15133 | |
|
| | 15134 | | /// <summary>Subtracts two MassRate measurements.</summary> |
| | 15135 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 15136 | | /// <returns>The result of the subtraction.</returns> |
| | 15137 | | public MassRate<T> Subtract(MassRate<T> b) |
| | 15138 | | { |
| | 15139 | | return this - b; |
| | 15140 | | } |
| | 15141 | |
|
| | 15142 | | #endregion |
| | 15143 | |
|
| | 15144 | | #region Multiply |
| | 15145 | |
|
| | 15146 | | /// <summary>Multiplies an MassRate by a scalar numeric value.</summary> |
| | 15147 | | /// <param name="a">The MassRate measurement to multiply.</param> |
| | 15148 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 15149 | | /// <returns>The result of the multiplication.</returns> |
| | 15150 | | public static MassRate<T> Multiply(MassRate<T> a, T b) |
| | 15151 | | { |
| | 15152 | | return MathBase(a, b, Statics.Multiplication); |
| | 15153 | | } |
| | 15154 | |
|
| | 15155 | | /// <summary>Multiplies an MassRate by a scalar numeric value.</summary> |
| | 15156 | | /// <param name="a">The MassRate measurement to multiply.</param> |
| | 15157 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 15158 | | /// <returns>The result of the multiplication.</returns> |
| | 15159 | | public static MassRate<T> Multiply(T b, MassRate<T> a) |
| | 15160 | | { |
| | 15161 | | return Multiply(a, b); |
| | 15162 | | } |
| | 15163 | |
|
| | 15164 | | /// <summary>Multiplies an MassRate by a scalar numeric value.</summary> |
| | 15165 | | /// <param name="a">The MassRate measurement to multiply.</param> |
| | 15166 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 15167 | | /// <returns>The result of the multiplication.</returns> |
| | 15168 | | public static MassRate<T> operator *(MassRate<T> a, T b) |
| | 15169 | | { |
| | 15170 | | return Multiply(a, b); |
| | 15171 | | } |
| | 15172 | |
|
| | 15173 | | /// <summary>Multiplies an MassRate by a scalar numeric value.</summary> |
| | 15174 | | /// <param name="a">The MassRate measurement to multiply.</param> |
| | 15175 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 15176 | | /// <returns>The result of the multiplication.</returns> |
| | 15177 | | public static MassRate<T> operator *(T b, MassRate<T> a) |
| | 15178 | | { |
| | 15179 | | return Multiply(b, a); |
| | 15180 | | } |
| | 15181 | |
|
| | 15182 | | /// <summary>Multiplies an MassRate by a scalar numeric value.</summary> |
| | 15183 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 15184 | | /// <returns>The result of the multiplication.</returns> |
| | 15185 | | public MassRate<T> Add(T b) |
| | 15186 | | { |
| | 15187 | | return this * b; |
| | 15188 | | } |
| | 15189 | |
|
| | 15190 | | #region MassRate<T> * Length<T> = LinearMassFlow<T> |
| | 15191 | |
|
| | 15192 | | /// <summary>Mulitplies MassRate by Length resulting in LinearMassFlow.</summary> |
| | 15193 | | /// <param name="a">The MassRate to be multiplied.</param> |
| | 15194 | | /// <param name="b">The Length to multiply by.</param> |
| | 15195 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 15196 | | public static LinearMassFlow<T> Multiply(MassRate<T> a, Length<T> b) |
| | 15197 | | { |
| | 15198 | |
|
| | 15199 | | T A = a[a._MassUnits1, a._TimeUnits2]; |
| | 15200 | | T B = b[b._LengthUnits1]; |
| | 15201 | | T C = Statics.Multiplication(A, B); |
| | 15202 | |
|
| | 15203 | | return new LinearMassFlow<T>(C |
| | 15204 | | , a._MassUnits1 |
| | 15205 | | , b._LengthUnits1 |
| | 15206 | | , a._TimeUnits2 |
| | 15207 | | ); |
| | 15208 | | } |
| | 15209 | |
|
| | 15210 | | /// <summary>Mulitplies MassRate by Length resulting in LinearMassFlow.</summary> |
| | 15211 | | /// <param name="a">The MassRate to be multiplied.</param> |
| | 15212 | | /// <param name="b">The Length to multiply by.</param> |
| | 15213 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 15214 | | public static LinearMassFlow<T> operator *(MassRate<T> a, Length<T> b) |
| | 15215 | | { |
| | 15216 | | return Multiply(a, b); |
| | 15217 | | } |
| | 15218 | |
|
| | 15219 | | /// <summary>Mulitplies MassRate by Length resulting in LinearMassFlow.</summary> |
| | 15220 | | /// <param name="b">The Length to multiply by.</param> |
| | 15221 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 15222 | | public LinearMassFlow<T> Multiply(Length<T> b) |
| | 15223 | | { |
| | 15224 | | return this * b; |
| | 15225 | | } |
| | 15226 | |
|
| | 15227 | | #endregion |
| | 15228 | |
|
| | 15229 | | #region MassRate<T> * Speed<T> = Force<T> |
| | 15230 | |
|
| | 15231 | | /// <summary>Mulitplies MassRate by Speed resulting in Force.</summary> |
| | 15232 | | /// <param name="a">The MassRate to be multiplied.</param> |
| | 15233 | | /// <param name="b">The Speed to multiply by.</param> |
| | 15234 | | /// <returns>The Force result of the multiplication.</returns> |
| | 15235 | | public static Force<T> Multiply(MassRate<T> a, Speed<T> b) |
| | 15236 | | { |
| | 15237 | |
|
| | 15238 | | T A = a[a._MassUnits1, a._TimeUnits2]; |
| | 15239 | | T B = b[b._LengthUnits1, b._TimeUnits2]; |
| | 15240 | | T C = Statics.Multiplication(A, B); |
| | 15241 | |
|
| | 15242 | | return new Force<T>(C |
| | 15243 | | , a._MassUnits1 |
| | 15244 | | , b._LengthUnits1 |
| | 15245 | | , a._TimeUnits2 |
| | 15246 | | , b._TimeUnits2 |
| | 15247 | | ); |
| | 15248 | | } |
| | 15249 | |
|
| | 15250 | | /// <summary>Mulitplies MassRate by Speed resulting in Force.</summary> |
| | 15251 | | /// <param name="a">The MassRate to be multiplied.</param> |
| | 15252 | | /// <param name="b">The Speed to multiply by.</param> |
| | 15253 | | /// <returns>The Force result of the multiplication.</returns> |
| | 15254 | | public static Force<T> operator *(MassRate<T> a, Speed<T> b) |
| | 15255 | | { |
| | 15256 | | return Multiply(a, b); |
| | 15257 | | } |
| | 15258 | |
|
| | 15259 | | /// <summary>Mulitplies MassRate by Speed resulting in Force.</summary> |
| | 15260 | | /// <param name="b">The Speed to multiply by.</param> |
| | 15261 | | /// <returns>The Force result of the multiplication.</returns> |
| | 15262 | | public Force<T> Multiply(Speed<T> b) |
| | 15263 | | { |
| | 15264 | | return this * b; |
| | 15265 | | } |
| | 15266 | |
|
| | 15267 | | #endregion |
| | 15268 | |
|
| | 15269 | | #region MassRate<T> * Time<T> = Mass<T> |
| | 15270 | |
|
| | 15271 | | /// <summary>Mulitplies MassRate by Time resulting in Mass.</summary> |
| | 15272 | | /// <param name="a">The MassRate to be multiplied.</param> |
| | 15273 | | /// <param name="b">The Time to multiply by.</param> |
| | 15274 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 15275 | | public static Mass<T> Multiply(MassRate<T> a, Time<T> b) |
| | 15276 | | { |
| | 15277 | | Time.Units TimeUnits1 = a._TimeUnits2 <= b._TimeUnits1 ? a._TimeUnits2 : b._TimeUnits1; |
| | 15278 | |
|
| | 15279 | | T A = a[a._MassUnits1, TimeUnits1]; |
| | 15280 | | T B = b[TimeUnits1]; |
| | 15281 | | T C = Statics.Multiplication(A, B); |
| | 15282 | |
|
| | 15283 | | return new Mass<T>(C |
| | 15284 | | , a._MassUnits1 |
| | 15285 | | ); |
| | 15286 | | } |
| | 15287 | |
|
| | 15288 | | /// <summary>Mulitplies MassRate by Time resulting in Mass.</summary> |
| | 15289 | | /// <param name="a">The MassRate to be multiplied.</param> |
| | 15290 | | /// <param name="b">The Time to multiply by.</param> |
| | 15291 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 15292 | | public static Mass<T> operator *(MassRate<T> a, Time<T> b) |
| | 15293 | | { |
| | 15294 | | return Multiply(a, b); |
| | 15295 | | } |
| | 15296 | |
|
| | 15297 | | /// <summary>Mulitplies MassRate by Time resulting in Mass.</summary> |
| | 15298 | | /// <param name="b">The Time to multiply by.</param> |
| | 15299 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 15300 | | public Mass<T> Multiply(Time<T> b) |
| | 15301 | | { |
| | 15302 | | return this * b; |
| | 15303 | | } |
| | 15304 | |
|
| | 15305 | | #endregion |
| | 15306 | |
|
| | 15307 | | #endregion |
| | 15308 | |
|
| | 15309 | | #region Divide |
| | 15310 | |
|
| | 15311 | | /// <summary>Divides an MassRate measurement by another MassRate measurement resulting in a scalar numeric value.</s |
| | 15312 | | /// <param name="a">The first operand of the division operation.</param> |
| | 15313 | | /// <param name="b">The second operand of the division operation.</param> |
| | 15314 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 15315 | | public static T Divide(MassRate<T> a, MassRate<T> b) |
| | 15316 | | { |
| | 15317 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 15318 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 15319 | | T A = a[MassUnits1, TimeUnits2]; |
| | 15320 | | T B = b[MassUnits1, TimeUnits2]; |
| | 15321 | | return Statics.Division(A, B); |
| | 15322 | | } |
| | 15323 | |
|
| | 15324 | | /// <summary>Divides this MassRate measurement by a numaric scalar value.</summary> |
| | 15325 | | /// <param name="a">The MassRate measurement to divide.</param> |
| | 15326 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 15327 | | /// <returns>The result of the division.</returns> |
| | 15328 | | public static MassRate<T> Divide(MassRate<T> a, T b) |
| | 15329 | | { |
| | 15330 | | return MathBase(a, b, Statics.Division); |
| | 15331 | | } |
| | 15332 | |
|
| | 15333 | | /// <summary>Divides this MassRate measurement by a numaric scalar value.</summary> |
| | 15334 | | /// <param name="a">The MassRate measurement to divide.</param> |
| | 15335 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 15336 | | /// <returns>The result of the division.</returns> |
| | 15337 | | public static MassRate<T> operator /(MassRate<T> a, T b) |
| | 15338 | | { |
| | 15339 | | return Divide(a, b); |
| | 15340 | | } |
| | 15341 | |
|
| | 15342 | | /// <summary>Divides this MassRate measurement by a numaric scalar value.</summary> |
| | 15343 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 15344 | | /// <returns>The result of the division.</returns> |
| | 15345 | | public MassRate<T> Divide(T b) |
| | 15346 | | { |
| | 15347 | | return this / b; |
| | 15348 | | } |
| | 15349 | |
|
| | 15350 | | /// <summary>Divides an MassRate measurement by another MassRate measurement resulting in a scalar numeric value.</s |
| | 15351 | | /// <param name="a">The first operand of the division operation.</param> |
| | 15352 | | /// <param name="b">The second operand of the division operation.</param> |
| | 15353 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 15354 | | public static T operator /(MassRate<T> a, MassRate<T> b) |
| | 15355 | | { |
| | 15356 | | return Divide(a, b); |
| | 15357 | | } |
| | 15358 | |
|
| | 15359 | | /// <summary>Divides an MassRate measurement by another MassRate measurement resulting in a scalar numeric value.</s |
| | 15360 | | /// <param name="b">The second operand of the division operation.</param> |
| | 15361 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 15362 | | public T Divide(MassRate<T> b) |
| | 15363 | | { |
| | 15364 | | return this / b; |
| | 15365 | | } |
| | 15366 | |
|
| | 15367 | |
|
| | 15368 | | #region MassRate<T> / Density<T> = VolumeRate<T> |
| | 15369 | |
|
| | 15370 | | /// <summary>Divides MassRate by Density resulting in VolumeRate.</summary> |
| | 15371 | | /// <param name="a">The MassRate to be divided.</param> |
| | 15372 | | /// <param name="b">The Density to divide by.</param> |
| | 15373 | | /// <returns>The VolumeRate result of the division.</returns> |
| | 15374 | | public static VolumeRate<T> Divide(MassRate<T> a, Density<T> b) |
| | 15375 | | { |
| | 15376 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 15377 | |
|
| | 15378 | | T A = a[MassUnits1, a._TimeUnits2]; |
| | 15379 | | T B = b[MassUnits1, b._LengthUnits2, b._LengthUnits3, b._LengthUnits4]; |
| | 15380 | | T C = Statics.Division(A, B); |
| | 15381 | |
|
| | 15382 | | return new VolumeRate<T>(C |
| | 15383 | | , b._LengthUnits2 |
| | 15384 | | , b._LengthUnits3 |
| | 15385 | | , b._LengthUnits4 |
| | 15386 | | , a._TimeUnits2 |
| | 15387 | | ); |
| | 15388 | | } |
| | 15389 | |
|
| | 15390 | | /// <summary>Divides MassRate by Density resulting in VolumeRate.</summary> |
| | 15391 | | /// <param name="a">The MassRate to be divided.</param> |
| | 15392 | | /// <param name="b">The Density to divide by.</param> |
| | 15393 | | /// <returns>The VolumeRate result of the division.</returns> |
| | 15394 | | public static VolumeRate<T> operator /(MassRate<T> a, Density<T> b) |
| | 15395 | | { |
| | 15396 | | return Divide(a, b); |
| | 15397 | | } |
| | 15398 | |
|
| | 15399 | | /// <summary>Divides MassRate by Density resulting in VolumeRate.</summary> |
| | 15400 | | /// <param name="b">The Density to divide by.</param> |
| | 15401 | | /// <returns>The VolumeRate result of the division.</returns> |
| | 15402 | | public VolumeRate<T> Divide(Density<T> b) |
| | 15403 | | { |
| | 15404 | | return this / b; |
| | 15405 | | } |
| | 15406 | |
|
| | 15407 | | #endregion |
| | 15408 | |
|
| | 15409 | |
|
| | 15410 | | #region MassRate<T> / LinearDensity<T> = Speed<T> |
| | 15411 | |
|
| | 15412 | | /// <summary>Divides MassRate by LinearDensity resulting in Speed.</summary> |
| | 15413 | | /// <param name="a">The MassRate to be divided.</param> |
| | 15414 | | /// <param name="b">The LinearDensity to divide by.</param> |
| | 15415 | | /// <returns>The Speed result of the division.</returns> |
| | 15416 | | public static Speed<T> Divide(MassRate<T> a, LinearDensity<T> b) |
| | 15417 | | { |
| | 15418 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 15419 | |
|
| | 15420 | | T A = a[MassUnits1, a._TimeUnits2]; |
| | 15421 | | T B = b[MassUnits1, b._LengthUnits2]; |
| | 15422 | | T C = Statics.Division(A, B); |
| | 15423 | |
|
| | 15424 | | return new Speed<T>(C |
| | 15425 | | , b._LengthUnits2 |
| | 15426 | | , a._TimeUnits2 |
| | 15427 | | ); |
| | 15428 | | } |
| | 15429 | |
|
| | 15430 | | /// <summary>Divides MassRate by LinearDensity resulting in Speed.</summary> |
| | 15431 | | /// <param name="a">The MassRate to be divided.</param> |
| | 15432 | | /// <param name="b">The LinearDensity to divide by.</param> |
| | 15433 | | /// <returns>The Speed result of the division.</returns> |
| | 15434 | | public static Speed<T> operator /(MassRate<T> a, LinearDensity<T> b) |
| | 15435 | | { |
| | 15436 | | return Divide(a, b); |
| | 15437 | | } |
| | 15438 | |
|
| | 15439 | | /// <summary>Divides MassRate by LinearDensity resulting in Speed.</summary> |
| | 15440 | | /// <param name="b">The LinearDensity to divide by.</param> |
| | 15441 | | /// <returns>The Speed result of the division.</returns> |
| | 15442 | | public Speed<T> Divide(LinearDensity<T> b) |
| | 15443 | | { |
| | 15444 | | return this / b; |
| | 15445 | | } |
| | 15446 | |
|
| | 15447 | | #endregion |
| | 15448 | |
|
| | 15449 | |
|
| | 15450 | | #region MassRate<T> / Speed<T> = LinearDensity<T> |
| | 15451 | |
|
| | 15452 | | /// <summary>Divides MassRate by Speed resulting in LinearDensity.</summary> |
| | 15453 | | /// <param name="a">The MassRate to be divided.</param> |
| | 15454 | | /// <param name="b">The Speed to divide by.</param> |
| | 15455 | | /// <returns>The LinearDensity result of the division.</returns> |
| | 15456 | | public static LinearDensity<T> Divide(MassRate<T> a, Speed<T> b) |
| | 15457 | | { |
| | 15458 | | Time.Units TimeUnits1 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 15459 | |
|
| | 15460 | | T A = a[a._MassUnits1, TimeUnits1]; |
| | 15461 | | T B = b[b._LengthUnits1, TimeUnits1]; |
| | 15462 | | T C = Statics.Division(A, B); |
| | 15463 | |
|
| | 15464 | | return new LinearDensity<T>(C |
| | 15465 | | , a._MassUnits1 |
| | 15466 | | , b._LengthUnits1 |
| | 15467 | | ); |
| | 15468 | | } |
| | 15469 | |
|
| | 15470 | | /// <summary>Divides MassRate by Speed resulting in LinearDensity.</summary> |
| | 15471 | | /// <param name="a">The MassRate to be divided.</param> |
| | 15472 | | /// <param name="b">The Speed to divide by.</param> |
| | 15473 | | /// <returns>The LinearDensity result of the division.</returns> |
| | 15474 | | public static LinearDensity<T> operator /(MassRate<T> a, Speed<T> b) |
| | 15475 | | { |
| | 15476 | | return Divide(a, b); |
| | 15477 | | } |
| | 15478 | |
|
| | 15479 | | /// <summary>Divides MassRate by Speed resulting in LinearDensity.</summary> |
| | 15480 | | /// <param name="b">The Speed to divide by.</param> |
| | 15481 | | /// <returns>The LinearDensity result of the division.</returns> |
| | 15482 | | public LinearDensity<T> Divide(Speed<T> b) |
| | 15483 | | { |
| | 15484 | | return this / b; |
| | 15485 | | } |
| | 15486 | |
|
| | 15487 | | #endregion |
| | 15488 | |
|
| | 15489 | |
|
| | 15490 | | #region MassRate<T> / VolumeRate<T> = Density<T> |
| | 15491 | |
|
| | 15492 | | /// <summary>Divides MassRate by VolumeRate resulting in Density.</summary> |
| | 15493 | | /// <param name="a">The MassRate to be divided.</param> |
| | 15494 | | /// <param name="b">The VolumeRate to divide by.</param> |
| | 15495 | | /// <returns>The Density result of the division.</returns> |
| | 15496 | | public static Density<T> Divide(MassRate<T> a, VolumeRate<T> b) |
| | 15497 | | { |
| | 15498 | | Time.Units TimeUnits1 = a._TimeUnits2 <= b._TimeUnits4 ? a._TimeUnits2 : b._TimeUnits4; |
| | 15499 | |
|
| | 15500 | | T A = a[a._MassUnits1, TimeUnits1]; |
| | 15501 | | T B = b[b._LengthUnits1, b._LengthUnits2, b._LengthUnits3, TimeUnits1]; |
| | 15502 | | T C = Statics.Division(A, B); |
| | 15503 | |
|
| | 15504 | | return new Density<T>(C |
| | 15505 | | , a._MassUnits1 |
| | 15506 | | , b._LengthUnits1 |
| | 15507 | | , b._LengthUnits2 |
| | 15508 | | , b._LengthUnits3 |
| | 15509 | | ); |
| | 15510 | | } |
| | 15511 | |
|
| | 15512 | | /// <summary>Divides MassRate by VolumeRate resulting in Density.</summary> |
| | 15513 | | /// <param name="a">The MassRate to be divided.</param> |
| | 15514 | | /// <param name="b">The VolumeRate to divide by.</param> |
| | 15515 | | /// <returns>The Density result of the division.</returns> |
| | 15516 | | public static Density<T> operator /(MassRate<T> a, VolumeRate<T> b) |
| | 15517 | | { |
| | 15518 | | return Divide(a, b); |
| | 15519 | | } |
| | 15520 | |
|
| | 15521 | | /// <summary>Divides MassRate by VolumeRate resulting in Density.</summary> |
| | 15522 | | /// <param name="b">The VolumeRate to divide by.</param> |
| | 15523 | | /// <returns>The Density result of the division.</returns> |
| | 15524 | | public Density<T> Divide(VolumeRate<T> b) |
| | 15525 | | { |
| | 15526 | | return this / b; |
| | 15527 | | } |
| | 15528 | |
|
| | 15529 | | #endregion |
| | 15530 | |
|
| | 15531 | | #endregion |
| | 15532 | |
|
| | 15533 | | #region LessThan |
| | 15534 | |
|
| | 15535 | | /// <summary>Determines if an MassRate measurement is less than another MassRate measurement.</summary> |
| | 15536 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 15537 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 15538 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 15539 | | public static bool LessThan(MassRate<T> a, MassRate<T> b) |
| | 15540 | | { |
| | 15541 | | return LogicBase(a, b, Statics.LessThan); |
| | 15542 | | } |
| | 15543 | |
|
| | 15544 | | /// <summary>Determines if an MassRate measurement is less than another MassRate measurement.</summary> |
| | 15545 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 15546 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 15547 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 15548 | | public static bool operator <(MassRate<T> a, MassRate<T> b) |
| | 15549 | | { |
| | 15550 | | return LessThan(a, b); |
| | 15551 | | } |
| | 15552 | |
|
| | 15553 | | /// <summary>Determines if an MassRate measurement is less than another MassRate measurement.</summary> |
| | 15554 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 15555 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 15556 | | public bool LessThan(MassRate<T> b) |
| | 15557 | | { |
| | 15558 | | return this < b; |
| | 15559 | | } |
| | 15560 | |
|
| | 15561 | | #endregion |
| | 15562 | |
|
| | 15563 | | #region GreaterThan |
| | 15564 | |
|
| | 15565 | | /// <summary>Determines if an MassRate measurement is greater than another MassRate measurement.</summary> |
| | 15566 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 15567 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 15568 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 15569 | | public static bool GreaterThan(MassRate<T> a, MassRate<T> b) |
| | 15570 | | { |
| | 15571 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 15572 | | } |
| | 15573 | |
|
| | 15574 | | /// <summary>Determines if an MassRate measurement is greater than another MassRate measurement.</summary> |
| | 15575 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 15576 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 15577 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 15578 | | public static bool operator >(MassRate<T> a, MassRate<T> b) |
| | 15579 | | { |
| | 15580 | | return GreaterThan(a, b); |
| | 15581 | | } |
| | 15582 | |
|
| | 15583 | | /// <summary>Determines if an MassRate measurement is greater than another MassRate measurement.</summary> |
| | 15584 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 15585 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 15586 | | public bool GreaterThan(MassRate<T> b) |
| | 15587 | | { |
| | 15588 | | return this > b; |
| | 15589 | | } |
| | 15590 | |
|
| | 15591 | | #endregion |
| | 15592 | |
|
| | 15593 | | #region LessThanOrEqual |
| | 15594 | |
|
| | 15595 | | /// <summary>Determines if an MassRate measurement is less than or equal to another MassRate measurement.</summary> |
| | 15596 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 15597 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 15598 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 15599 | | public static bool LessThanOrEqual(MassRate<T> a, MassRate<T> b) |
| | 15600 | | { |
| | 15601 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 15602 | | } |
| | 15603 | |
|
| | 15604 | | /// <summary>Determines if an MassRate measurement is less than or equal to another MassRate measurement.</summary> |
| | 15605 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 15606 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 15607 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 15608 | | public static bool operator <=(MassRate<T> a, MassRate<T> b) |
| | 15609 | | { |
| | 15610 | | return LessThanOrEqual(a, b); |
| | 15611 | | } |
| | 15612 | |
|
| | 15613 | | /// <summary>Determines if an MassRate measurement is less than or equal to another MassRate measurement.</summary> |
| | 15614 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 15615 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 15616 | | public bool LessThanOrEqual(MassRate<T> b) |
| | 15617 | | { |
| | 15618 | | return this <= b; |
| | 15619 | | } |
| | 15620 | |
|
| | 15621 | | #endregion |
| | 15622 | |
|
| | 15623 | | #region GreaterThanOrEqual |
| | 15624 | |
|
| | 15625 | | /// <summary>Determines if an MassRate measurement is greater than or equal to another MassRate measurement.</summar |
| | 15626 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 15627 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 15628 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 15629 | | public static bool GreaterThanOrEqual(MassRate<T> a, MassRate<T> b) |
| | 15630 | | { |
| | 15631 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 15632 | | } |
| | 15633 | |
|
| | 15634 | | /// <summary>Determines if an MassRate measurement is greater than or equal to another MassRate measurement.</summar |
| | 15635 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 15636 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 15637 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 15638 | | public static bool operator >=(MassRate<T> a, MassRate<T> b) |
| | 15639 | | { |
| | 15640 | | return GreaterThanOrEqual(a, b); |
| | 15641 | | } |
| | 15642 | |
|
| | 15643 | | /// <summary>Determines if an MassRate measurement is greater than or equal to another MassRate measurement.</summar |
| | 15644 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 15645 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 15646 | | public bool GreaterThanOrEqual(MassRate<T> b) |
| | 15647 | | { |
| | 15648 | | return this >= b; |
| | 15649 | | } |
| | 15650 | |
|
| | 15651 | | #endregion |
| | 15652 | |
|
| | 15653 | | #region Equal |
| | 15654 | |
|
| | 15655 | | /// <summary>Determines if an MassRate measurement is equal to another MassRate measurement.</summary> |
| | 15656 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 15657 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 15658 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 15659 | | public static bool Equal(MassRate<T> a, MassRate<T> b) |
| | 15660 | | { |
| | 15661 | | return LogicBase(a, b, Statics.Equate); |
| | 15662 | | } |
| | 15663 | |
|
| | 15664 | | /// <summary>Determines if an MassRate measurement is equal to another MassRate measurement.</summary> |
| | 15665 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 15666 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 15667 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 15668 | | public static bool operator ==(MassRate<T> a, MassRate<T> b) |
| | 15669 | | { |
| | 15670 | | return Equal(a, b); |
| | 15671 | | } |
| | 15672 | |
|
| | 15673 | | /// <summary>Determines if an MassRate measurement is equal to another MassRate measurement.</summary> |
| | 15674 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 15675 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 15676 | | public bool Equal(MassRate<T> b) |
| | 15677 | | { |
| | 15678 | | return this == b; |
| | 15679 | | } |
| | 15680 | |
|
| | 15681 | | #endregion |
| | 15682 | |
|
| | 15683 | | #region NotEqual |
| | 15684 | |
|
| | 15685 | | /// <summary>Determines if an MassRate measurement is not equal to another MassRate measurement.</summary> |
| | 15686 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 15687 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 15688 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 15689 | | public static bool NotEqual(MassRate<T> a, MassRate<T> b) |
| | 15690 | | { |
| | 15691 | | return LogicBase(a, b, Statics.Inequate); |
| | 15692 | | } |
| | 15693 | |
|
| | 15694 | | /// <summary>Determines if an MassRate measurement is not equal to another MassRate measurement.</summary> |
| | 15695 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 15696 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 15697 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 15698 | | public static bool operator !=(MassRate<T> a, MassRate<T> b) |
| | 15699 | | { |
| | 15700 | | return NotEqual(a, b); |
| | 15701 | | } |
| | 15702 | |
|
| | 15703 | | /// <summary>Determines if an MassRate measurement is not equal to another MassRate measurement.</summary> |
| | 15704 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 15705 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 15706 | | public bool NotEqual(MassRate<T> b) |
| | 15707 | | { |
| | 15708 | | return this != b; |
| | 15709 | | } |
| | 15710 | |
|
| | 15711 | | #endregion |
| | 15712 | |
|
| | 15713 | | #endregion |
| | 15714 | |
|
| | 15715 | | #region Overrides |
| | 15716 | |
|
| | 15717 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 15718 | | /// <param name="obj">The object to check for equality with.</param> |
| | 15719 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 15720 | | public override bool Equals(object obj) |
| | 15721 | | { |
| | 15722 | | if (obj is MassRate<T>) |
| | 15723 | | { |
| | 15724 | | return this == (MassRate<T>)obj; |
| | 15725 | | } |
| | 15726 | | return false; |
| | 15727 | | } |
| | 15728 | |
|
| | 15729 | | /// <summary>Converts the MassRate measurement to a string represenation.</summary> |
| | 15730 | | /// <returns>The string representation of the measurement.</returns> |
| | 15731 | | public override string ToString() |
| | 15732 | | { |
| | 15733 | | return _measurement + " " + |
| | 15734 | | _MassUnits1 |
| | 15735 | | + "/" + |
| | 15736 | | _TimeUnits2 |
| | 15737 | | ; |
| | 15738 | | } |
| | 15739 | |
|
| | 15740 | | /// <summary>Base hashing function for MassRate measurements.</summary> |
| | 15741 | | /// <returns>Computed hash code for this instance.</returns> |
| | 15742 | | public override int GetHashCode() => Hash(_measurement); |
| | 15743 | |
|
| | 15744 | | #endregion |
| | 15745 | | } |
| | 15746 | |
|
| | 15747 | | #endregion |
| | 15748 | |
|
| | 15749 | | #region Power |
| | 15750 | |
|
| | 15751 | | internal static partial class ParsingFunctions |
| | 15752 | | { |
| | 15753 | | [Measurement.Parseable("Mass*Length*Length/Time/Time/Time")] |
| | 15754 | | public static object Power<T>(T value, object[] units) |
| | 15755 | | { |
| | 15756 | | if (units.Length != 6) |
| | 15757 | | { |
| | 15758 | | throw new Exception("Bug in Towel. Invalid parameters to Power Factory."); |
| | 15759 | | } |
| | 15760 | | if (!(units[0] is Mass.Units)) |
| | 15761 | | { |
| | 15762 | | throw new Exception("Bug in Towel. Invalid parameters to Power Factory."); |
| | 15763 | | } |
| | 15764 | | if (!(units[1] is Length.Units)) |
| | 15765 | | { |
| | 15766 | | throw new Exception("Bug in Towel. Invalid parameters to Power Factory."); |
| | 15767 | | } |
| | 15768 | | if (!(units[2] is Length.Units)) |
| | 15769 | | { |
| | 15770 | | throw new Exception("Bug in Towel. Invalid parameters to Power Factory."); |
| | 15771 | | } |
| | 15772 | | if (!(units[3] is Time.Units)) |
| | 15773 | | { |
| | 15774 | | throw new Exception("Bug in Towel. Invalid parameters to Power Factory."); |
| | 15775 | | } |
| | 15776 | | if (!(units[4] is Time.Units)) |
| | 15777 | | { |
| | 15778 | | throw new Exception("Bug in Towel. Invalid parameters to Power Factory."); |
| | 15779 | | } |
| | 15780 | | if (!(units[5] is Time.Units)) |
| | 15781 | | { |
| | 15782 | | throw new Exception("Bug in Towel. Invalid parameters to Power Factory."); |
| | 15783 | | } |
| | 15784 | | return new Power<T>(value |
| | 15785 | | , (Mass.Units)units[0] |
| | 15786 | | , (Length.Units)units[1] |
| | 15787 | | , (Length.Units)units[2] |
| | 15788 | | , (Time.Units)units[3] |
| | 15789 | | , (Time.Units)units[4] |
| | 15790 | | , (Time.Units)units[5] |
| | 15791 | | ); |
| | 15792 | | } |
| | 15793 | | } |
| | 15794 | |
|
| | 15795 | | /// <summary>Power measurement with a value and the units.</summary> |
| | 15796 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 15797 | | public struct Power<T> |
| | 15798 | | { |
| | 15799 | | internal T _measurement; |
| | 15800 | | internal Mass.Units _MassUnits1; |
| | 15801 | | internal Length.Units _LengthUnits2; |
| | 15802 | | internal Length.Units _LengthUnits3; |
| | 15803 | | internal Time.Units _TimeUnits4; |
| | 15804 | | internal Time.Units _TimeUnits5; |
| | 15805 | | internal Time.Units _TimeUnits6; |
| | 15806 | |
|
| | 15807 | | #region Statics |
| | 15808 | |
|
| | 15809 | | /// <summary>Converts a Power measurement from units to another.</summary> |
| | 15810 | | /// <param name="value">The value to convert the units of.</param> |
| | 15811 | | /// <param name="fromMassUnits1">The current units of the measurement.</param> |
| | 15812 | | /// <param name="fromLengthUnits2">The current units of the measurement.</param> |
| | 15813 | | /// <param name="fromLengthUnits3">The current units of the measurement.</param> |
| | 15814 | | /// <param name="fromTimeUnits4">The current units of the measurement.</param> |
| | 15815 | | /// <param name="fromTimeUnits5">The current units of the measurement.</param> |
| | 15816 | | /// <param name="fromTimeUnits6">The current units of the measurement.</param> |
| | 15817 | | /// <param name="toMassUnits1">The desired units of the measurement.</param> |
| | 15818 | | /// <param name="toLengthUnits2">The desired units of the measurement.</param> |
| | 15819 | | /// <param name="toLengthUnits3">The desired units of the measurement.</param> |
| | 15820 | | /// <param name="toTimeUnits4">The desired units of the measurement.</param> |
| | 15821 | | /// <param name="toTimeUnits5">The desired units of the measurement.</param> |
| | 15822 | | /// <param name="toTimeUnits6">The desired units of the measurement.</param> |
| | 15823 | | /// <returns>The Power measurement converted into the desired units.</returns> |
| | 15824 | | public static T Convert(T value |
| | 15825 | | , Mass.Units fromMassUnits1 |
| | 15826 | | , Length.Units fromLengthUnits2 |
| | 15827 | | , Length.Units fromLengthUnits3 |
| | 15828 | | , Time.Units fromTimeUnits4 |
| | 15829 | | , Time.Units fromTimeUnits5 |
| | 15830 | | , Time.Units fromTimeUnits6 |
| | 15831 | | , Mass.Units toMassUnits1 |
| | 15832 | | , Length.Units toLengthUnits2 |
| | 15833 | | , Length.Units toLengthUnits3 |
| | 15834 | | , Time.Units toTimeUnits4 |
| | 15835 | | , Time.Units toTimeUnits5 |
| | 15836 | | , Time.Units toTimeUnits6 |
| | 15837 | | ) |
| | 15838 | | { |
| | 15839 | | Power<T> measurement = new Power<T>(value |
| | 15840 | | , fromMassUnits1 |
| | 15841 | | , fromLengthUnits2 |
| | 15842 | | , fromLengthUnits3 |
| | 15843 | | , fromTimeUnits4 |
| | 15844 | | , fromTimeUnits5 |
| | 15845 | | , fromTimeUnits6 |
| | 15846 | | ); |
| | 15847 | | return measurement[ |
| | 15848 | | toMassUnits1 |
| | 15849 | | , toLengthUnits2 |
| | 15850 | | , toLengthUnits3 |
| | 15851 | | , toTimeUnits4 |
| | 15852 | | , toTimeUnits5 |
| | 15853 | | , toTimeUnits6 |
| | 15854 | | ]; |
| | 15855 | | } |
| | 15856 | |
|
| | 15857 | | /// <summary>Converts a Power measurement from units to another.</summary> |
| | 15858 | | /// <param name="value">The value to convert the units of.</param> |
| | 15859 | | /// <param name="from">The current units of the measurement.</param> |
| | 15860 | | /// <param name="to">The desired units of the measurement.</param> |
| | 15861 | | /// <returns>The Power measurement converted into the desired units.</returns> |
| | 15862 | | public static T Convert(T value, |
| | 15863 | | MeasurementUnitsSyntaxTypes.PowerBaseUnits from, |
| | 15864 | | MeasurementUnitsSyntaxTypes.PowerBaseUnits to) |
| | 15865 | | { |
| | 15866 | | return Convert(value |
| | 15867 | | , from._MassUnits1 |
| | 15868 | | , from._LengthUnits2 |
| | 15869 | | , from._LengthUnits3 |
| | 15870 | | , from._TimeUnits4 |
| | 15871 | | , from._TimeUnits5 |
| | 15872 | | , from._TimeUnits6 |
| | 15873 | | , to._MassUnits1 |
| | 15874 | | , to._LengthUnits2 |
| | 15875 | | , to._LengthUnits3 |
| | 15876 | | , to._TimeUnits4 |
| | 15877 | | , to._TimeUnits5 |
| | 15878 | | , to._TimeUnits6 |
| | 15879 | | ); |
| | 15880 | | } |
| | 15881 | |
|
| | 15882 | | /// <summary>Parses a Power measurement string.</summary> |
| | 15883 | | /// <param name="string">The string to be parsed.</param> |
| | 15884 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 15885 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 15886 | | public static (bool Success, Power<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value)> tryPars |
| | 15887 | |
|
| | 15888 | | #endregion |
| | 15889 | |
|
| | 15890 | | #region Constructors |
| | 15891 | |
|
| | 15892 | | /// <summary>Constructs an Power with the measurement value and units.</summary> |
| | 15893 | | /// <param name="measurement">The measurement value of the Power.</param> |
| | 15894 | | /// <param name="units">The units of the Power.</param> |
| | 15895 | | public Power(T measurement, MeasurementUnitsSyntaxTypes.PowerBaseUnits units) : this(measurement |
| | 15896 | | , units._MassUnits1 |
| | 15897 | | , units._LengthUnits2 |
| | 15898 | | , units._LengthUnits3 |
| | 15899 | | , units._TimeUnits4 |
| | 15900 | | , units._TimeUnits5 |
| | 15901 | | , units._TimeUnits6 |
| | 15902 | | ) { } |
| | 15903 | |
|
| | 15904 | |
|
| | 15905 | | /// <summary>Constructs an Power with the measurement value and units.</summary> |
| | 15906 | | /// <param name="measurement">The measurement value of the Power.</param> |
| | 15907 | | /// <param name="MassUnits1">The units of the Power.</param> |
| | 15908 | | /// <param name="LengthUnits2">The units of the Power.</param> |
| | 15909 | | /// <param name="LengthUnits3">The units of the Power.</param> |
| | 15910 | | /// <param name="TimeUnits4">The units of the Power.</param> |
| | 15911 | | /// <param name="TimeUnits5">The units of the Power.</param> |
| | 15912 | | /// <param name="TimeUnits6">The units of the Power.</param> |
| | 15913 | | public Power(T measurement |
| | 15914 | | , Mass.Units MassUnits1 |
| | 15915 | | , Length.Units LengthUnits2 |
| | 15916 | | , Length.Units LengthUnits3 |
| | 15917 | | , Time.Units TimeUnits4 |
| | 15918 | | , Time.Units TimeUnits5 |
| | 15919 | | , Time.Units TimeUnits6 |
| | 15920 | | ) |
| | 15921 | | { |
| | 15922 | | _measurement = measurement; |
| | 15923 | | _MassUnits1 = MassUnits1; |
| | 15924 | | _LengthUnits2 = LengthUnits2; |
| | 15925 | | _LengthUnits3 = LengthUnits3; |
| | 15926 | | _TimeUnits4 = TimeUnits4; |
| | 15927 | | _TimeUnits5 = TimeUnits5; |
| | 15928 | | _TimeUnits6 = TimeUnits6; |
| | 15929 | | } |
| | 15930 | |
|
| | 15931 | | #endregion |
| | 15932 | |
|
| | 15933 | | #region Properties |
| | 15934 | |
|
| | 15935 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 15936 | | public Mass.Units MassUnits1 |
| | 15937 | | { |
| | 15938 | | get { return _MassUnits1; } |
| | 15939 | | set |
| | 15940 | | { |
| | 15941 | | if (value != _MassUnits1) |
| | 15942 | | { |
| | 15943 | | _measurement = this[value, _LengthUnits2, _LengthUnits3, _TimeUnits4, _TimeUnits5, _TimeUnits6]; |
| | 15944 | | _MassUnits1 = value; |
| | 15945 | | } |
| | 15946 | | } |
| | 15947 | | } |
| | 15948 | |
|
| | 15949 | | /// <summary>The #2 component of this measurements units.</summary> |
| | 15950 | | public Length.Units LengthUnits2 |
| | 15951 | | { |
| | 15952 | | get { return _LengthUnits2; } |
| | 15953 | | set |
| | 15954 | | { |
| | 15955 | | if (value != _LengthUnits2) |
| | 15956 | | { |
| | 15957 | | _measurement = this[_MassUnits1, value, _LengthUnits3, _TimeUnits4, _TimeUnits5, _TimeUnits6]; |
| | 15958 | | _LengthUnits2 = value; |
| | 15959 | | } |
| | 15960 | | } |
| | 15961 | | } |
| | 15962 | |
|
| | 15963 | | /// <summary>The #3 component of this measurements units.</summary> |
| | 15964 | | public Length.Units LengthUnits3 |
| | 15965 | | { |
| | 15966 | | get { return _LengthUnits3; } |
| | 15967 | | set |
| | 15968 | | { |
| | 15969 | | if (value != _LengthUnits3) |
| | 15970 | | { |
| | 15971 | | _measurement = this[_MassUnits1, _LengthUnits2, value, _TimeUnits4, _TimeUnits5, _TimeUnits6]; |
| | 15972 | | _LengthUnits3 = value; |
| | 15973 | | } |
| | 15974 | | } |
| | 15975 | | } |
| | 15976 | |
|
| | 15977 | | /// <summary>The #4 component of this measurements units.</summary> |
| | 15978 | | public Time.Units TimeUnits4 |
| | 15979 | | { |
| | 15980 | | get { return _TimeUnits4; } |
| | 15981 | | set |
| | 15982 | | { |
| | 15983 | | if (value != _TimeUnits4) |
| | 15984 | | { |
| | 15985 | | _measurement = this[_MassUnits1, _LengthUnits2, _LengthUnits3, value, _TimeUnits5, _TimeUnits6]; |
| | 15986 | | _TimeUnits4 = value; |
| | 15987 | | } |
| | 15988 | | } |
| | 15989 | | } |
| | 15990 | |
|
| | 15991 | | /// <summary>The #5 component of this measurements units.</summary> |
| | 15992 | | public Time.Units TimeUnits5 |
| | 15993 | | { |
| | 15994 | | get { return _TimeUnits5; } |
| | 15995 | | set |
| | 15996 | | { |
| | 15997 | | if (value != _TimeUnits5) |
| | 15998 | | { |
| | 15999 | | _measurement = this[_MassUnits1, _LengthUnits2, _LengthUnits3, _TimeUnits4, value, _TimeUnits6]; |
| | 16000 | | _TimeUnits5 = value; |
| | 16001 | | } |
| | 16002 | | } |
| | 16003 | | } |
| | 16004 | |
|
| | 16005 | | /// <summary>The #6 component of this measurements units.</summary> |
| | 16006 | | public Time.Units TimeUnits6 |
| | 16007 | | { |
| | 16008 | | get { return _TimeUnits6; } |
| | 16009 | | set |
| | 16010 | | { |
| | 16011 | | if (value != _TimeUnits6) |
| | 16012 | | { |
| | 16013 | | _measurement = this[_MassUnits1, _LengthUnits2, _LengthUnits3, _TimeUnits4, _TimeUnits5, value]; |
| | 16014 | | _TimeUnits6 = value; |
| | 16015 | | } |
| | 16016 | | } |
| | 16017 | | } |
| | 16018 | |
|
| | 16019 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 16020 | | /// <param name="units">The units to get the measurement in.</param> |
| | 16021 | | /// <returns>The measurement value in the specified units.</returns> |
| | 16022 | | public T this[MeasurementUnitsSyntaxTypes.PowerBaseUnits units] |
| | 16023 | | { |
| | 16024 | | get { return this[units._MassUnits1, units._LengthUnits2, units._LengthUnits3, units._TimeUnits4, units._TimeUnits |
| | 16025 | | } |
| | 16026 | |
|
| | 16027 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 16028 | | /// <param name="MassUnits1">The #1 component of this measurements units.</param> |
| | 16029 | | /// <param name="LengthUnits2">The #2 component of this measurements units.</param> |
| | 16030 | | /// <param name="LengthUnits3">The #3 component of this measurements units.</param> |
| | 16031 | | /// <param name="TimeUnits4">The #4 component of this measurements units.</param> |
| | 16032 | | /// <param name="TimeUnits5">The #5 component of this measurements units.</param> |
| | 16033 | | /// <param name="TimeUnits6">The #6 component of this measurements units.</param> |
| | 16034 | | /// <returns>The measurement value in the specified units.</returns> |
| | 16035 | | public T this[Mass.Units MassUnits1, Length.Units LengthUnits2, Length.Units LengthUnits3, Time.Units TimeUnits4, Ti |
| | 16036 | | { |
| | 16037 | | get |
| | 16038 | | { |
| | 16039 | | T measurement = _measurement; |
| | 16040 | | if (MassUnits1 != _MassUnits1) |
| | 16041 | | { |
| | 16042 | | measurement = Mass<T>.Table[(int)_MassUnits1][(int)MassUnits1](measurement); |
| | 16043 | | //if (MassUnits1 < _MassUnits1) |
| | 16044 | | //{ |
| | 16045 | | // measurement = Mass<T>.Table[(int)_MassUnits1][(int)MassUnits1](measurement); |
| | 16046 | | //} |
| | 16047 | | //else |
| | 16048 | | //{ |
| | 16049 | | // measurement = Mass<T>.Table[(int)MassUnits1][(int)_MassUnits1](measurement); |
| | 16050 | | //} |
| | 16051 | | } |
| | 16052 | | if (LengthUnits2 != _LengthUnits2) |
| | 16053 | | { |
| | 16054 | | measurement = Length<T>.Table[(int)_LengthUnits2][(int)LengthUnits2](measurement); |
| | 16055 | | //if (LengthUnits2 < _LengthUnits2) |
| | 16056 | | //{ |
| | 16057 | | // measurement = Length<T>.Table[(int)_LengthUnits2][(int)LengthUnits2](measurement); |
| | 16058 | | //} |
| | 16059 | | //else |
| | 16060 | | //{ |
| | 16061 | | // measurement = Length<T>.Table[(int)LengthUnits2][(int)_LengthUnits2](measurement); |
| | 16062 | | //} |
| | 16063 | | } |
| | 16064 | | if (LengthUnits3 != _LengthUnits3) |
| | 16065 | | { |
| | 16066 | | measurement = Length<T>.Table[(int)_LengthUnits3][(int)LengthUnits3](measurement); |
| | 16067 | | //if (LengthUnits3 < _LengthUnits3) |
| | 16068 | | //{ |
| | 16069 | | // measurement = Length<T>.Table[(int)_LengthUnits3][(int)LengthUnits3](measurement); |
| | 16070 | | //} |
| | 16071 | | //else |
| | 16072 | | //{ |
| | 16073 | | // measurement = Length<T>.Table[(int)LengthUnits3][(int)_LengthUnits3](measurement); |
| | 16074 | | //} |
| | 16075 | | } |
| | 16076 | | if (TimeUnits4 != _TimeUnits4) |
| | 16077 | | { |
| | 16078 | | measurement = Time<T>.Table[(int)TimeUnits4][(int)_TimeUnits4](measurement); |
| | 16079 | | //if (TimeUnits4 > _TimeUnits4) |
| | 16080 | | //{ |
| | 16081 | | // measurement = Time<T>.Table[(int)_TimeUnits4][(int)TimeUnits4](measurement); |
| | 16082 | | //} |
| | 16083 | | //else |
| | 16084 | | //{ |
| | 16085 | | // measurement = Time<T>.Table[(int)TimeUnits4][(int)_TimeUnits4](measurement); |
| | 16086 | | //} |
| | 16087 | | } |
| | 16088 | | if (TimeUnits5 != _TimeUnits5) |
| | 16089 | | { |
| | 16090 | | measurement = Time<T>.Table[(int)TimeUnits5][(int)_TimeUnits5](measurement); |
| | 16091 | | //if (TimeUnits5 > _TimeUnits5) |
| | 16092 | | //{ |
| | 16093 | | // measurement = Time<T>.Table[(int)_TimeUnits5][(int)TimeUnits5](measurement); |
| | 16094 | | //} |
| | 16095 | | //else |
| | 16096 | | //{ |
| | 16097 | | // measurement = Time<T>.Table[(int)TimeUnits5][(int)_TimeUnits5](measurement); |
| | 16098 | | //} |
| | 16099 | | } |
| | 16100 | | if (TimeUnits6 != _TimeUnits6) |
| | 16101 | | { |
| | 16102 | | measurement = Time<T>.Table[(int)TimeUnits6][(int)_TimeUnits6](measurement); |
| | 16103 | | //if (TimeUnits6 > _TimeUnits6) |
| | 16104 | | //{ |
| | 16105 | | // measurement = Time<T>.Table[(int)_TimeUnits6][(int)TimeUnits6](measurement); |
| | 16106 | | //} |
| | 16107 | | //else |
| | 16108 | | //{ |
| | 16109 | | // measurement = Time<T>.Table[(int)TimeUnits6][(int)_TimeUnits6](measurement); |
| | 16110 | | //} |
| | 16111 | | } |
| | 16112 | | return measurement; |
| | 16113 | | } |
| | 16114 | | } |
| | 16115 | |
|
| | 16116 | | #endregion |
| | 16117 | |
|
| | 16118 | | #region Casting Operators |
| | 16119 | |
|
| | 16120 | | /// <summary>Converts a ValueTuple to a Power measurement.</summary> |
| | 16121 | | /// <param name="valueTuple">The ValueTuple to converted into a Power measurement.</param> |
| | 16122 | | public static implicit operator Power<T>((T, MeasurementUnitsSyntaxTypes.PowerBaseUnits) valueTuple) |
| | 16123 | | { |
| | 16124 | | return new Power<T>(valueTuple.Item1, valueTuple.Item2); |
| | 16125 | | } |
| | 16126 | |
|
| | 16127 | | #endregion |
| | 16128 | |
|
| | 16129 | | #region Mathematics |
| | 16130 | |
|
| | 16131 | | #region Bases |
| | 16132 | |
|
| | 16133 | | internal static Power<T> MathBase(Power<T> a, T b, Func<T, T, T> func) |
| | 16134 | | { |
| | 16135 | | return new Power<T>(func(a._measurement, b) |
| | 16136 | | , a._MassUnits1 |
| | 16137 | | , a._LengthUnits2 |
| | 16138 | | , a._LengthUnits3 |
| | 16139 | | , a._TimeUnits4 |
| | 16140 | | , a._TimeUnits5 |
| | 16141 | | , a._TimeUnits6 |
| | 16142 | | ); |
| | 16143 | | } |
| | 16144 | |
|
| | 16145 | | internal static Power<T> MathBase(Power<T> a, Power<T> b, Func<T, T, T> func) |
| | 16146 | | { |
| | 16147 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 16148 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 16149 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits3 ? a._LengthUnits3 : b._LengthUnits3; |
| | 16150 | | Time.Units TimeUnits4 = a._TimeUnits4 <= b._TimeUnits4 ? a._TimeUnits4 : b._TimeUnits4; |
| | 16151 | | Time.Units TimeUnits5 = a._TimeUnits5 <= b._TimeUnits5 ? a._TimeUnits5 : b._TimeUnits5; |
| | 16152 | | Time.Units TimeUnits6 = a._TimeUnits6 <= b._TimeUnits6 ? a._TimeUnits6 : b._TimeUnits6; |
| | 16153 | | T A = a[MassUnits1, LengthUnits2, LengthUnits3, TimeUnits4, TimeUnits5, TimeUnits6]; |
| | 16154 | | T B = b[MassUnits1, LengthUnits2, LengthUnits3, TimeUnits4, TimeUnits5, TimeUnits6]; |
| | 16155 | | T C = func(A, B); |
| | 16156 | | return new Power<T>(C, MassUnits1, LengthUnits2, LengthUnits3, TimeUnits4, TimeUnits5, TimeUnits6); |
| | 16157 | | } |
| | 16158 | |
|
| | 16159 | | internal static bool LogicBase(Power<T> a, Power<T> b, Func<T, T, bool> func) |
| | 16160 | | { |
| | 16161 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 16162 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 16163 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits3 ? a._LengthUnits3 : b._LengthUnits3; |
| | 16164 | | Time.Units TimeUnits4 = a._TimeUnits4 <= b._TimeUnits4 ? a._TimeUnits4 : b._TimeUnits4; |
| | 16165 | | Time.Units TimeUnits5 = a._TimeUnits5 <= b._TimeUnits5 ? a._TimeUnits5 : b._TimeUnits5; |
| | 16166 | | Time.Units TimeUnits6 = a._TimeUnits6 <= b._TimeUnits6 ? a._TimeUnits6 : b._TimeUnits6; |
| | 16167 | | T A = a[MassUnits1, LengthUnits2, LengthUnits3, TimeUnits4, TimeUnits5, TimeUnits6]; |
| | 16168 | | T B = b[MassUnits1, LengthUnits2, LengthUnits3, TimeUnits4, TimeUnits5, TimeUnits6]; |
| | 16169 | | return func(A, B); |
| | 16170 | | } |
| | 16171 | |
|
| | 16172 | | #endregion |
| | 16173 | |
|
| | 16174 | | #region Add |
| | 16175 | |
|
| | 16176 | | /// <summary>Adds two Power measurements.</summary> |
| | 16177 | | /// <param name="a">The first operand of the addition.</param> |
| | 16178 | | /// <param name="b">The second operand of the addition.</param> |
| | 16179 | | /// <returns>The result of the addition operation.</returns> |
| | 16180 | | public static Power<T> Add(Power<T> a, Power<T> b) |
| | 16181 | | { |
| | 16182 | | return MathBase(a, b, Statics.Addition); |
| | 16183 | | } |
| | 16184 | |
|
| | 16185 | | /// <summary>Adds two Power measurements.</summary> |
| | 16186 | | /// <param name="a">The first operand of the addition.</param> |
| | 16187 | | /// <param name="b">The second operand of the addition.</param> |
| | 16188 | | /// <returns>The result of the addition operation.</returns> |
| | 16189 | | public static Power<T> operator +(Power<T> a, Power<T> b) |
| | 16190 | | { |
| | 16191 | | return Add(a, b); |
| | 16192 | | } |
| | 16193 | |
|
| | 16194 | | /// <summary>Adds two Power measurements.</summary> |
| | 16195 | | /// <param name="b">The second operand of the addition.</param> |
| | 16196 | | /// <returns>The result of the addition operation.</returns> |
| | 16197 | | public Power<T> Add(Power<T> b) |
| | 16198 | | { |
| | 16199 | | return this + b; |
| | 16200 | | } |
| | 16201 | |
|
| | 16202 | | #endregion |
| | 16203 | |
|
| | 16204 | | #region Subtract |
| | 16205 | |
|
| | 16206 | | /// <summary>Subtracts two Power measurements.</summary> |
| | 16207 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 16208 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 16209 | | /// <returns>The result of the subtraction.</returns> |
| | 16210 | | public static Power<T> Subtract(Power<T> a, Power<T> b) |
| | 16211 | | { |
| | 16212 | | return MathBase(a, b, Statics.Subtraction); |
| | 16213 | | } |
| | 16214 | |
|
| | 16215 | | /// <summary>Subtracts two Power measurements.</summary> |
| | 16216 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 16217 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 16218 | | /// <returns>The result of the subtraction.</returns> |
| | 16219 | | public static Power<T> operator -(Power<T> a, Power<T> b) |
| | 16220 | | { |
| | 16221 | | return Subtract(a, b); |
| | 16222 | | } |
| | 16223 | |
|
| | 16224 | | /// <summary>Subtracts two Power measurements.</summary> |
| | 16225 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 16226 | | /// <returns>The result of the subtraction.</returns> |
| | 16227 | | public Power<T> Subtract(Power<T> b) |
| | 16228 | | { |
| | 16229 | | return this - b; |
| | 16230 | | } |
| | 16231 | |
|
| | 16232 | | #endregion |
| | 16233 | |
|
| | 16234 | | #region Multiply |
| | 16235 | |
|
| | 16236 | | /// <summary>Multiplies an Power by a scalar numeric value.</summary> |
| | 16237 | | /// <param name="a">The Power measurement to multiply.</param> |
| | 16238 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 16239 | | /// <returns>The result of the multiplication.</returns> |
| | 16240 | | public static Power<T> Multiply(Power<T> a, T b) |
| | 16241 | | { |
| | 16242 | | return MathBase(a, b, Statics.Multiplication); |
| | 16243 | | } |
| | 16244 | |
|
| | 16245 | | /// <summary>Multiplies an Power by a scalar numeric value.</summary> |
| | 16246 | | /// <param name="a">The Power measurement to multiply.</param> |
| | 16247 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 16248 | | /// <returns>The result of the multiplication.</returns> |
| | 16249 | | public static Power<T> Multiply(T b, Power<T> a) |
| | 16250 | | { |
| | 16251 | | return Multiply(a, b); |
| | 16252 | | } |
| | 16253 | |
|
| | 16254 | | /// <summary>Multiplies an Power by a scalar numeric value.</summary> |
| | 16255 | | /// <param name="a">The Power measurement to multiply.</param> |
| | 16256 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 16257 | | /// <returns>The result of the multiplication.</returns> |
| | 16258 | | public static Power<T> operator *(Power<T> a, T b) |
| | 16259 | | { |
| | 16260 | | return Multiply(a, b); |
| | 16261 | | } |
| | 16262 | |
|
| | 16263 | | /// <summary>Multiplies an Power by a scalar numeric value.</summary> |
| | 16264 | | /// <param name="a">The Power measurement to multiply.</param> |
| | 16265 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 16266 | | /// <returns>The result of the multiplication.</returns> |
| | 16267 | | public static Power<T> operator *(T b, Power<T> a) |
| | 16268 | | { |
| | 16269 | | return Multiply(b, a); |
| | 16270 | | } |
| | 16271 | |
|
| | 16272 | | /// <summary>Multiplies an Power by a scalar numeric value.</summary> |
| | 16273 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 16274 | | /// <returns>The result of the multiplication.</returns> |
| | 16275 | | public Power<T> Add(T b) |
| | 16276 | | { |
| | 16277 | | return this * b; |
| | 16278 | | } |
| | 16279 | |
|
| | 16280 | | #region Power<T> * Time<T> = Energy<T> |
| | 16281 | |
|
| | 16282 | | /// <summary>Mulitplies Power by Time resulting in Energy.</summary> |
| | 16283 | | /// <param name="a">The Power to be multiplied.</param> |
| | 16284 | | /// <param name="b">The Time to multiply by.</param> |
| | 16285 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 16286 | | public static Energy<T> Multiply(Power<T> a, Time<T> b) |
| | 16287 | | { |
| | 16288 | | Time.Units TimeUnits1 = a._TimeUnits4 <= b._TimeUnits1 ? a._TimeUnits4 : b._TimeUnits1; |
| | 16289 | |
|
| | 16290 | | T A = a[a._MassUnits1, a._LengthUnits2, a._LengthUnits3, TimeUnits1, a._TimeUnits5, a._TimeUnits6]; |
| | 16291 | | T B = b[TimeUnits1]; |
| | 16292 | | T C = Statics.Multiplication(A, B); |
| | 16293 | |
|
| | 16294 | | return new Energy<T>(C |
| | 16295 | | , a._MassUnits1 |
| | 16296 | | , a._LengthUnits2 |
| | 16297 | | , a._LengthUnits3 |
| | 16298 | | , a._TimeUnits5 |
| | 16299 | | , a._TimeUnits6 |
| | 16300 | | ); |
| | 16301 | | } |
| | 16302 | |
|
| | 16303 | | /// <summary>Mulitplies Power by Time resulting in Energy.</summary> |
| | 16304 | | /// <param name="a">The Power to be multiplied.</param> |
| | 16305 | | /// <param name="b">The Time to multiply by.</param> |
| | 16306 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 16307 | | public static Energy<T> operator *(Power<T> a, Time<T> b) |
| | 16308 | | { |
| | 16309 | | return Multiply(a, b); |
| | 16310 | | } |
| | 16311 | |
|
| | 16312 | | /// <summary>Mulitplies Power by Time resulting in Energy.</summary> |
| | 16313 | | /// <param name="b">The Time to multiply by.</param> |
| | 16314 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 16315 | | public Energy<T> Multiply(Time<T> b) |
| | 16316 | | { |
| | 16317 | | return this * b; |
| | 16318 | | } |
| | 16319 | |
|
| | 16320 | | #endregion |
| | 16321 | |
|
| | 16322 | | #endregion |
| | 16323 | |
|
| | 16324 | | #region Divide |
| | 16325 | |
|
| | 16326 | | /// <summary>Divides an Power measurement by another Power measurement resulting in a scalar numeric value.</summary |
| | 16327 | | /// <param name="a">The first operand of the division operation.</param> |
| | 16328 | | /// <param name="b">The second operand of the division operation.</param> |
| | 16329 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 16330 | | public static T Divide(Power<T> a, Power<T> b) |
| | 16331 | | { |
| | 16332 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 16333 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 16334 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits3 ? a._LengthUnits3 : b._LengthUnits3; |
| | 16335 | | Time.Units TimeUnits4 = a._TimeUnits4 <= b._TimeUnits4 ? a._TimeUnits4 : b._TimeUnits4; |
| | 16336 | | Time.Units TimeUnits5 = a._TimeUnits5 <= b._TimeUnits5 ? a._TimeUnits5 : b._TimeUnits5; |
| | 16337 | | Time.Units TimeUnits6 = a._TimeUnits6 <= b._TimeUnits6 ? a._TimeUnits6 : b._TimeUnits6; |
| | 16338 | | T A = a[MassUnits1, LengthUnits2, LengthUnits3, TimeUnits4, TimeUnits5, TimeUnits6]; |
| | 16339 | | T B = b[MassUnits1, LengthUnits2, LengthUnits3, TimeUnits4, TimeUnits5, TimeUnits6]; |
| | 16340 | | return Statics.Division(A, B); |
| | 16341 | | } |
| | 16342 | |
|
| | 16343 | | /// <summary>Divides this Power measurement by a numaric scalar value.</summary> |
| | 16344 | | /// <param name="a">The Power measurement to divide.</param> |
| | 16345 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 16346 | | /// <returns>The result of the division.</returns> |
| | 16347 | | public static Power<T> Divide(Power<T> a, T b) |
| | 16348 | | { |
| | 16349 | | return MathBase(a, b, Statics.Division); |
| | 16350 | | } |
| | 16351 | |
|
| | 16352 | | /// <summary>Divides this Power measurement by a numaric scalar value.</summary> |
| | 16353 | | /// <param name="a">The Power measurement to divide.</param> |
| | 16354 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 16355 | | /// <returns>The result of the division.</returns> |
| | 16356 | | public static Power<T> operator /(Power<T> a, T b) |
| | 16357 | | { |
| | 16358 | | return Divide(a, b); |
| | 16359 | | } |
| | 16360 | |
|
| | 16361 | | /// <summary>Divides this Power measurement by a numaric scalar value.</summary> |
| | 16362 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 16363 | | /// <returns>The result of the division.</returns> |
| | 16364 | | public Power<T> Divide(T b) |
| | 16365 | | { |
| | 16366 | | return this / b; |
| | 16367 | | } |
| | 16368 | |
|
| | 16369 | | /// <summary>Divides an Power measurement by another Power measurement resulting in a scalar numeric value.</summary |
| | 16370 | | /// <param name="a">The first operand of the division operation.</param> |
| | 16371 | | /// <param name="b">The second operand of the division operation.</param> |
| | 16372 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 16373 | | public static T operator /(Power<T> a, Power<T> b) |
| | 16374 | | { |
| | 16375 | | return Divide(a, b); |
| | 16376 | | } |
| | 16377 | |
|
| | 16378 | | /// <summary>Divides an Power measurement by another Power measurement resulting in a scalar numeric value.</summary |
| | 16379 | | /// <param name="b">The second operand of the division operation.</param> |
| | 16380 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 16381 | | public T Divide(Power<T> b) |
| | 16382 | | { |
| | 16383 | | return this / b; |
| | 16384 | | } |
| | 16385 | |
|
| | 16386 | |
|
| | 16387 | | #region Power<T> / Acceleration<T> = LinearMassFlow<T> |
| | 16388 | |
|
| | 16389 | | /// <summary>Divides Power by Acceleration resulting in LinearMassFlow.</summary> |
| | 16390 | | /// <param name="a">The Power to be divided.</param> |
| | 16391 | | /// <param name="b">The Acceleration to divide by.</param> |
| | 16392 | | /// <returns>The LinearMassFlow result of the division.</returns> |
| | 16393 | | public static LinearMassFlow<T> Divide(Power<T> a, Acceleration<T> b) |
| | 16394 | | { |
| | 16395 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 16396 | | Time.Units TimeUnits2 = a._TimeUnits4 <= b._TimeUnits2 ? a._TimeUnits4 : b._TimeUnits2; |
| | 16397 | | Time.Units TimeUnits3 = a._TimeUnits5 <= b._TimeUnits3 ? a._TimeUnits5 : b._TimeUnits3; |
| | 16398 | |
|
| | 16399 | | T A = a[a._MassUnits1, LengthUnits1, a._LengthUnits3, TimeUnits2, TimeUnits3, a._TimeUnits6]; |
| | 16400 | | T B = b[LengthUnits1, TimeUnits2, TimeUnits3]; |
| | 16401 | | T C = Statics.Division(A, B); |
| | 16402 | |
|
| | 16403 | | return new LinearMassFlow<T>(C |
| | 16404 | | , a._MassUnits1 |
| | 16405 | | , a._LengthUnits3 |
| | 16406 | | , a._TimeUnits6 |
| | 16407 | | ); |
| | 16408 | | } |
| | 16409 | |
|
| | 16410 | | /// <summary>Divides Power by Acceleration resulting in LinearMassFlow.</summary> |
| | 16411 | | /// <param name="a">The Power to be divided.</param> |
| | 16412 | | /// <param name="b">The Acceleration to divide by.</param> |
| | 16413 | | /// <returns>The LinearMassFlow result of the division.</returns> |
| | 16414 | | public static LinearMassFlow<T> operator /(Power<T> a, Acceleration<T> b) |
| | 16415 | | { |
| | 16416 | | return Divide(a, b); |
| | 16417 | | } |
| | 16418 | |
|
| | 16419 | | /// <summary>Divides Power by Acceleration resulting in LinearMassFlow.</summary> |
| | 16420 | | /// <param name="b">The Acceleration to divide by.</param> |
| | 16421 | | /// <returns>The LinearMassFlow result of the division.</returns> |
| | 16422 | | public LinearMassFlow<T> Divide(Acceleration<T> b) |
| | 16423 | | { |
| | 16424 | | return this / b; |
| | 16425 | | } |
| | 16426 | |
|
| | 16427 | | #endregion |
| | 16428 | |
|
| | 16429 | |
|
| | 16430 | | #region Power<T> / Force<T> = Speed<T> |
| | 16431 | |
|
| | 16432 | | /// <summary>Divides Power by Force resulting in Speed.</summary> |
| | 16433 | | /// <param name="a">The Power to be divided.</param> |
| | 16434 | | /// <param name="b">The Force to divide by.</param> |
| | 16435 | | /// <returns>The Speed result of the division.</returns> |
| | 16436 | | public static Speed<T> Divide(Power<T> a, Force<T> b) |
| | 16437 | | { |
| | 16438 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 16439 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 16440 | | Time.Units TimeUnits3 = a._TimeUnits4 <= b._TimeUnits3 ? a._TimeUnits4 : b._TimeUnits3; |
| | 16441 | | Time.Units TimeUnits4 = a._TimeUnits5 <= b._TimeUnits4 ? a._TimeUnits5 : b._TimeUnits4; |
| | 16442 | |
|
| | 16443 | | T A = a[MassUnits1, LengthUnits2, a._LengthUnits3, TimeUnits3, TimeUnits4, a._TimeUnits6]; |
| | 16444 | | T B = b[MassUnits1, LengthUnits2, TimeUnits3, TimeUnits4]; |
| | 16445 | | T C = Statics.Division(A, B); |
| | 16446 | |
|
| | 16447 | | return new Speed<T>(C |
| | 16448 | | , a._LengthUnits3 |
| | 16449 | | , a._TimeUnits6 |
| | 16450 | | ); |
| | 16451 | | } |
| | 16452 | |
|
| | 16453 | | /// <summary>Divides Power by Force resulting in Speed.</summary> |
| | 16454 | | /// <param name="a">The Power to be divided.</param> |
| | 16455 | | /// <param name="b">The Force to divide by.</param> |
| | 16456 | | /// <returns>The Speed result of the division.</returns> |
| | 16457 | | public static Speed<T> operator /(Power<T> a, Force<T> b) |
| | 16458 | | { |
| | 16459 | | return Divide(a, b); |
| | 16460 | | } |
| | 16461 | |
|
| | 16462 | | /// <summary>Divides Power by Force resulting in Speed.</summary> |
| | 16463 | | /// <param name="b">The Force to divide by.</param> |
| | 16464 | | /// <returns>The Speed result of the division.</returns> |
| | 16465 | | public Speed<T> Divide(Force<T> b) |
| | 16466 | | { |
| | 16467 | | return this / b; |
| | 16468 | | } |
| | 16469 | |
|
| | 16470 | | #endregion |
| | 16471 | |
|
| | 16472 | |
|
| | 16473 | | #region Power<T> / LinearMassFlow<T> = Acceleration<T> |
| | 16474 | |
|
| | 16475 | | /// <summary>Divides Power by LinearMassFlow resulting in Acceleration.</summary> |
| | 16476 | | /// <param name="a">The Power to be divided.</param> |
| | 16477 | | /// <param name="b">The LinearMassFlow to divide by.</param> |
| | 16478 | | /// <returns>The Acceleration result of the division.</returns> |
| | 16479 | | public static Acceleration<T> Divide(Power<T> a, LinearMassFlow<T> b) |
| | 16480 | | { |
| | 16481 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 16482 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 16483 | | Time.Units TimeUnits3 = a._TimeUnits4 <= b._TimeUnits3 ? a._TimeUnits4 : b._TimeUnits3; |
| | 16484 | |
|
| | 16485 | | T A = a[MassUnits1, LengthUnits2, a._LengthUnits3, TimeUnits3, a._TimeUnits5, a._TimeUnits6]; |
| | 16486 | | T B = b[MassUnits1, LengthUnits2, TimeUnits3]; |
| | 16487 | | T C = Statics.Division(A, B); |
| | 16488 | |
|
| | 16489 | | return new Acceleration<T>(C |
| | 16490 | | , a._LengthUnits3 |
| | 16491 | | , a._TimeUnits5 |
| | 16492 | | , a._TimeUnits6 |
| | 16493 | | ); |
| | 16494 | | } |
| | 16495 | |
|
| | 16496 | | /// <summary>Divides Power by LinearMassFlow resulting in Acceleration.</summary> |
| | 16497 | | /// <param name="a">The Power to be divided.</param> |
| | 16498 | | /// <param name="b">The LinearMassFlow to divide by.</param> |
| | 16499 | | /// <returns>The Acceleration result of the division.</returns> |
| | 16500 | | public static Acceleration<T> operator /(Power<T> a, LinearMassFlow<T> b) |
| | 16501 | | { |
| | 16502 | | return Divide(a, b); |
| | 16503 | | } |
| | 16504 | |
|
| | 16505 | | /// <summary>Divides Power by LinearMassFlow resulting in Acceleration.</summary> |
| | 16506 | | /// <param name="b">The LinearMassFlow to divide by.</param> |
| | 16507 | | /// <returns>The Acceleration result of the division.</returns> |
| | 16508 | | public Acceleration<T> Divide(LinearMassFlow<T> b) |
| | 16509 | | { |
| | 16510 | | return this / b; |
| | 16511 | | } |
| | 16512 | |
|
| | 16513 | | #endregion |
| | 16514 | |
|
| | 16515 | |
|
| | 16516 | | #region Power<T> / Pressure<T> = VolumeRate<T> |
| | 16517 | |
|
| | 16518 | | /// <summary>Divides Power by Pressure resulting in VolumeRate.</summary> |
| | 16519 | | /// <param name="a">The Power to be divided.</param> |
| | 16520 | | /// <param name="b">The Pressure to divide by.</param> |
| | 16521 | | /// <returns>The VolumeRate result of the division.</returns> |
| | 16522 | | public static VolumeRate<T> Divide(Power<T> a, Pressure<T> b) |
| | 16523 | | { |
| | 16524 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 16525 | | Time.Units TimeUnits2 = a._TimeUnits4 <= b._TimeUnits3 ? a._TimeUnits4 : b._TimeUnits3; |
| | 16526 | | Time.Units TimeUnits3 = a._TimeUnits5 <= b._TimeUnits4 ? a._TimeUnits5 : b._TimeUnits4; |
| | 16527 | |
|
| | 16528 | | T A = a[MassUnits1, a._LengthUnits2, a._LengthUnits3, TimeUnits2, TimeUnits3, a._TimeUnits6]; |
| | 16529 | | T B = b[MassUnits1, b._LengthUnits2, TimeUnits2, TimeUnits3]; |
| | 16530 | | T C = Statics.Division(A, B); |
| | 16531 | |
|
| | 16532 | | return new VolumeRate<T>(C |
| | 16533 | | , a._LengthUnits2 |
| | 16534 | | , a._LengthUnits3 |
| | 16535 | | , b._LengthUnits2 |
| | 16536 | | , a._TimeUnits6 |
| | 16537 | | ); |
| | 16538 | | } |
| | 16539 | |
|
| | 16540 | | /// <summary>Divides Power by Pressure resulting in VolumeRate.</summary> |
| | 16541 | | /// <param name="a">The Power to be divided.</param> |
| | 16542 | | /// <param name="b">The Pressure to divide by.</param> |
| | 16543 | | /// <returns>The VolumeRate result of the division.</returns> |
| | 16544 | | public static VolumeRate<T> operator /(Power<T> a, Pressure<T> b) |
| | 16545 | | { |
| | 16546 | | return Divide(a, b); |
| | 16547 | | } |
| | 16548 | |
|
| | 16549 | | /// <summary>Divides Power by Pressure resulting in VolumeRate.</summary> |
| | 16550 | | /// <param name="b">The Pressure to divide by.</param> |
| | 16551 | | /// <returns>The VolumeRate result of the division.</returns> |
| | 16552 | | public VolumeRate<T> Divide(Pressure<T> b) |
| | 16553 | | { |
| | 16554 | | return this / b; |
| | 16555 | | } |
| | 16556 | |
|
| | 16557 | | #endregion |
| | 16558 | |
|
| | 16559 | |
|
| | 16560 | | #region Power<T> / Speed<T> = Force<T> |
| | 16561 | |
|
| | 16562 | | /// <summary>Divides Power by Speed resulting in Force.</summary> |
| | 16563 | | /// <param name="a">The Power to be divided.</param> |
| | 16564 | | /// <param name="b">The Speed to divide by.</param> |
| | 16565 | | /// <returns>The Force result of the division.</returns> |
| | 16566 | | public static Force<T> Divide(Power<T> a, Speed<T> b) |
| | 16567 | | { |
| | 16568 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 16569 | | Time.Units TimeUnits2 = a._TimeUnits4 <= b._TimeUnits2 ? a._TimeUnits4 : b._TimeUnits2; |
| | 16570 | |
|
| | 16571 | | T A = a[a._MassUnits1, LengthUnits1, a._LengthUnits3, TimeUnits2, a._TimeUnits5, a._TimeUnits6]; |
| | 16572 | | T B = b[LengthUnits1, TimeUnits2]; |
| | 16573 | | T C = Statics.Division(A, B); |
| | 16574 | |
|
| | 16575 | | return new Force<T>(C |
| | 16576 | | , a._MassUnits1 |
| | 16577 | | , a._LengthUnits3 |
| | 16578 | | , a._TimeUnits5 |
| | 16579 | | , a._TimeUnits6 |
| | 16580 | | ); |
| | 16581 | | } |
| | 16582 | |
|
| | 16583 | | /// <summary>Divides Power by Speed resulting in Force.</summary> |
| | 16584 | | /// <param name="a">The Power to be divided.</param> |
| | 16585 | | /// <param name="b">The Speed to divide by.</param> |
| | 16586 | | /// <returns>The Force result of the division.</returns> |
| | 16587 | | public static Force<T> operator /(Power<T> a, Speed<T> b) |
| | 16588 | | { |
| | 16589 | | return Divide(a, b); |
| | 16590 | | } |
| | 16591 | |
|
| | 16592 | | /// <summary>Divides Power by Speed resulting in Force.</summary> |
| | 16593 | | /// <param name="b">The Speed to divide by.</param> |
| | 16594 | | /// <returns>The Force result of the division.</returns> |
| | 16595 | | public Force<T> Divide(Speed<T> b) |
| | 16596 | | { |
| | 16597 | | return this / b; |
| | 16598 | | } |
| | 16599 | |
|
| | 16600 | | #endregion |
| | 16601 | |
|
| | 16602 | |
|
| | 16603 | | #region Power<T> / VolumeRate<T> = Pressure<T> |
| | 16604 | |
|
| | 16605 | | /// <summary>Divides Power by VolumeRate resulting in Pressure.</summary> |
| | 16606 | | /// <param name="a">The Power to be divided.</param> |
| | 16607 | | /// <param name="b">The VolumeRate to divide by.</param> |
| | 16608 | | /// <returns>The Pressure result of the division.</returns> |
| | 16609 | | public static Pressure<T> Divide(Power<T> a, VolumeRate<T> b) |
| | 16610 | | { |
| | 16611 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 16612 | | Length.Units LengthUnits2 = a._LengthUnits3 <= b._LengthUnits2 ? a._LengthUnits3 : b._LengthUnits2; |
| | 16613 | | Time.Units TimeUnits3 = a._TimeUnits4 <= b._TimeUnits4 ? a._TimeUnits4 : b._TimeUnits4; |
| | 16614 | |
|
| | 16615 | | T A = a[a._MassUnits1, LengthUnits1, LengthUnits2, TimeUnits3, a._TimeUnits5, a._TimeUnits6]; |
| | 16616 | | T B = b[LengthUnits1, LengthUnits2, b._LengthUnits3, TimeUnits3]; |
| | 16617 | | T C = Statics.Division(A, B); |
| | 16618 | |
|
| | 16619 | | return new Pressure<T>(C |
| | 16620 | | , a._MassUnits1 |
| | 16621 | | , b._LengthUnits3 |
| | 16622 | | , a._TimeUnits5 |
| | 16623 | | , a._TimeUnits6 |
| | 16624 | | ); |
| | 16625 | | } |
| | 16626 | |
|
| | 16627 | | /// <summary>Divides Power by VolumeRate resulting in Pressure.</summary> |
| | 16628 | | /// <param name="a">The Power to be divided.</param> |
| | 16629 | | /// <param name="b">The VolumeRate to divide by.</param> |
| | 16630 | | /// <returns>The Pressure result of the division.</returns> |
| | 16631 | | public static Pressure<T> operator /(Power<T> a, VolumeRate<T> b) |
| | 16632 | | { |
| | 16633 | | return Divide(a, b); |
| | 16634 | | } |
| | 16635 | |
|
| | 16636 | | /// <summary>Divides Power by VolumeRate resulting in Pressure.</summary> |
| | 16637 | | /// <param name="b">The VolumeRate to divide by.</param> |
| | 16638 | | /// <returns>The Pressure result of the division.</returns> |
| | 16639 | | public Pressure<T> Divide(VolumeRate<T> b) |
| | 16640 | | { |
| | 16641 | | return this / b; |
| | 16642 | | } |
| | 16643 | |
|
| | 16644 | | #endregion |
| | 16645 | |
|
| | 16646 | | #endregion |
| | 16647 | |
|
| | 16648 | | #region LessThan |
| | 16649 | |
|
| | 16650 | | /// <summary>Determines if an Power measurement is less than another Power measurement.</summary> |
| | 16651 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 16652 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 16653 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 16654 | | public static bool LessThan(Power<T> a, Power<T> b) |
| | 16655 | | { |
| | 16656 | | return LogicBase(a, b, Statics.LessThan); |
| | 16657 | | } |
| | 16658 | |
|
| | 16659 | | /// <summary>Determines if an Power measurement is less than another Power measurement.</summary> |
| | 16660 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 16661 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 16662 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 16663 | | public static bool operator <(Power<T> a, Power<T> b) |
| | 16664 | | { |
| | 16665 | | return LessThan(a, b); |
| | 16666 | | } |
| | 16667 | |
|
| | 16668 | | /// <summary>Determines if an Power measurement is less than another Power measurement.</summary> |
| | 16669 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 16670 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 16671 | | public bool LessThan(Power<T> b) |
| | 16672 | | { |
| | 16673 | | return this < b; |
| | 16674 | | } |
| | 16675 | |
|
| | 16676 | | #endregion |
| | 16677 | |
|
| | 16678 | | #region GreaterThan |
| | 16679 | |
|
| | 16680 | | /// <summary>Determines if an Power measurement is greater than another Power measurement.</summary> |
| | 16681 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 16682 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 16683 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 16684 | | public static bool GreaterThan(Power<T> a, Power<T> b) |
| | 16685 | | { |
| | 16686 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 16687 | | } |
| | 16688 | |
|
| | 16689 | | /// <summary>Determines if an Power measurement is greater than another Power measurement.</summary> |
| | 16690 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 16691 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 16692 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 16693 | | public static bool operator >(Power<T> a, Power<T> b) |
| | 16694 | | { |
| | 16695 | | return GreaterThan(a, b); |
| | 16696 | | } |
| | 16697 | |
|
| | 16698 | | /// <summary>Determines if an Power measurement is greater than another Power measurement.</summary> |
| | 16699 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 16700 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 16701 | | public bool GreaterThan(Power<T> b) |
| | 16702 | | { |
| | 16703 | | return this > b; |
| | 16704 | | } |
| | 16705 | |
|
| | 16706 | | #endregion |
| | 16707 | |
|
| | 16708 | | #region LessThanOrEqual |
| | 16709 | |
|
| | 16710 | | /// <summary>Determines if an Power measurement is less than or equal to another Power measurement.</summary> |
| | 16711 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 16712 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 16713 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 16714 | | public static bool LessThanOrEqual(Power<T> a, Power<T> b) |
| | 16715 | | { |
| | 16716 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 16717 | | } |
| | 16718 | |
|
| | 16719 | | /// <summary>Determines if an Power measurement is less than or equal to another Power measurement.</summary> |
| | 16720 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 16721 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 16722 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 16723 | | public static bool operator <=(Power<T> a, Power<T> b) |
| | 16724 | | { |
| | 16725 | | return LessThanOrEqual(a, b); |
| | 16726 | | } |
| | 16727 | |
|
| | 16728 | | /// <summary>Determines if an Power measurement is less than or equal to another Power measurement.</summary> |
| | 16729 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 16730 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 16731 | | public bool LessThanOrEqual(Power<T> b) |
| | 16732 | | { |
| | 16733 | | return this <= b; |
| | 16734 | | } |
| | 16735 | |
|
| | 16736 | | #endregion |
| | 16737 | |
|
| | 16738 | | #region GreaterThanOrEqual |
| | 16739 | |
|
| | 16740 | | /// <summary>Determines if an Power measurement is greater than or equal to another Power measurement.</summary> |
| | 16741 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 16742 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 16743 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 16744 | | public static bool GreaterThanOrEqual(Power<T> a, Power<T> b) |
| | 16745 | | { |
| | 16746 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 16747 | | } |
| | 16748 | |
|
| | 16749 | | /// <summary>Determines if an Power measurement is greater than or equal to another Power measurement.</summary> |
| | 16750 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 16751 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 16752 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 16753 | | public static bool operator >=(Power<T> a, Power<T> b) |
| | 16754 | | { |
| | 16755 | | return GreaterThanOrEqual(a, b); |
| | 16756 | | } |
| | 16757 | |
|
| | 16758 | | /// <summary>Determines if an Power measurement is greater than or equal to another Power measurement.</summary> |
| | 16759 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 16760 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 16761 | | public bool GreaterThanOrEqual(Power<T> b) |
| | 16762 | | { |
| | 16763 | | return this >= b; |
| | 16764 | | } |
| | 16765 | |
|
| | 16766 | | #endregion |
| | 16767 | |
|
| | 16768 | | #region Equal |
| | 16769 | |
|
| | 16770 | | /// <summary>Determines if an Power measurement is equal to another Power measurement.</summary> |
| | 16771 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 16772 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 16773 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 16774 | | public static bool Equal(Power<T> a, Power<T> b) |
| | 16775 | | { |
| | 16776 | | return LogicBase(a, b, Statics.Equate); |
| | 16777 | | } |
| | 16778 | |
|
| | 16779 | | /// <summary>Determines if an Power measurement is equal to another Power measurement.</summary> |
| | 16780 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 16781 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 16782 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 16783 | | public static bool operator ==(Power<T> a, Power<T> b) |
| | 16784 | | { |
| | 16785 | | return Equal(a, b); |
| | 16786 | | } |
| | 16787 | |
|
| | 16788 | | /// <summary>Determines if an Power measurement is equal to another Power measurement.</summary> |
| | 16789 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 16790 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 16791 | | public bool Equal(Power<T> b) |
| | 16792 | | { |
| | 16793 | | return this == b; |
| | 16794 | | } |
| | 16795 | |
|
| | 16796 | | #endregion |
| | 16797 | |
|
| | 16798 | | #region NotEqual |
| | 16799 | |
|
| | 16800 | | /// <summary>Determines if an Power measurement is not equal to another Power measurement.</summary> |
| | 16801 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 16802 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 16803 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 16804 | | public static bool NotEqual(Power<T> a, Power<T> b) |
| | 16805 | | { |
| | 16806 | | return LogicBase(a, b, Statics.Inequate); |
| | 16807 | | } |
| | 16808 | |
|
| | 16809 | | /// <summary>Determines if an Power measurement is not equal to another Power measurement.</summary> |
| | 16810 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 16811 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 16812 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 16813 | | public static bool operator !=(Power<T> a, Power<T> b) |
| | 16814 | | { |
| | 16815 | | return NotEqual(a, b); |
| | 16816 | | } |
| | 16817 | |
|
| | 16818 | | /// <summary>Determines if an Power measurement is not equal to another Power measurement.</summary> |
| | 16819 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 16820 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 16821 | | public bool NotEqual(Power<T> b) |
| | 16822 | | { |
| | 16823 | | return this != b; |
| | 16824 | | } |
| | 16825 | |
|
| | 16826 | | #endregion |
| | 16827 | |
|
| | 16828 | | #endregion |
| | 16829 | |
|
| | 16830 | | #region Overrides |
| | 16831 | |
|
| | 16832 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 16833 | | /// <param name="obj">The object to check for equality with.</param> |
| | 16834 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 16835 | | public override bool Equals(object obj) |
| | 16836 | | { |
| | 16837 | | if (obj is Power<T>) |
| | 16838 | | { |
| | 16839 | | return this == (Power<T>)obj; |
| | 16840 | | } |
| | 16841 | | return false; |
| | 16842 | | } |
| | 16843 | |
|
| | 16844 | | /// <summary>Converts the Power measurement to a string represenation.</summary> |
| | 16845 | | /// <returns>The string representation of the measurement.</returns> |
| | 16846 | | public override string ToString() |
| | 16847 | | { |
| | 16848 | | return _measurement + " " + |
| | 16849 | | _MassUnits1 + "*" + _LengthUnits2 + "*" + _LengthUnits3 |
| | 16850 | | + "/" + |
| | 16851 | | _TimeUnits4 + "/" + _TimeUnits5 + "/" + _TimeUnits6 |
| | 16852 | | ; |
| | 16853 | | } |
| | 16854 | |
|
| | 16855 | | /// <summary>Base hashing function for Power measurements.</summary> |
| | 16856 | | /// <returns>Computed hash code for this instance.</returns> |
| | 16857 | | public override int GetHashCode() => Hash(_measurement); |
| | 16858 | |
|
| | 16859 | | #endregion |
| | 16860 | | } |
| | 16861 | |
|
| | 16862 | | #endregion |
| | 16863 | |
|
| | 16864 | | #region Pressure |
| | 16865 | |
|
| | 16866 | | internal static partial class ParsingFunctions |
| | 16867 | | { |
| | 16868 | | [Measurement.Parseable("Mass/Length/Time/Time")] |
| | 16869 | | public static object Pressure<T>(T value, object[] units) |
| | 16870 | | { |
| | 16871 | | if (units.Length != 4) |
| | 16872 | | { |
| | 16873 | | throw new Exception("Bug in Towel. Invalid parameters to Pressure Factory."); |
| | 16874 | | } |
| | 16875 | | if (!(units[0] is Mass.Units)) |
| | 16876 | | { |
| | 16877 | | throw new Exception("Bug in Towel. Invalid parameters to Pressure Factory."); |
| | 16878 | | } |
| | 16879 | | if (!(units[1] is Length.Units)) |
| | 16880 | | { |
| | 16881 | | throw new Exception("Bug in Towel. Invalid parameters to Pressure Factory."); |
| | 16882 | | } |
| | 16883 | | if (!(units[2] is Time.Units)) |
| | 16884 | | { |
| | 16885 | | throw new Exception("Bug in Towel. Invalid parameters to Pressure Factory."); |
| | 16886 | | } |
| | 16887 | | if (!(units[3] is Time.Units)) |
| | 16888 | | { |
| | 16889 | | throw new Exception("Bug in Towel. Invalid parameters to Pressure Factory."); |
| | 16890 | | } |
| | 16891 | | return new Pressure<T>(value |
| | 16892 | | , (Mass.Units)units[0] |
| | 16893 | | , (Length.Units)units[1] |
| | 16894 | | , (Time.Units)units[2] |
| | 16895 | | , (Time.Units)units[3] |
| | 16896 | | ); |
| | 16897 | | } |
| | 16898 | | } |
| | 16899 | |
|
| | 16900 | | /// <summary>Pressure measurement with a value and the units.</summary> |
| | 16901 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 16902 | | public struct Pressure<T> |
| | 16903 | | { |
| | 16904 | | internal T _measurement; |
| | 16905 | | internal Mass.Units _MassUnits1; |
| | 16906 | | internal Length.Units _LengthUnits2; |
| | 16907 | | internal Time.Units _TimeUnits3; |
| | 16908 | | internal Time.Units _TimeUnits4; |
| | 16909 | |
|
| | 16910 | | #region Statics |
| | 16911 | |
|
| | 16912 | | /// <summary>Converts a Pressure measurement from units to another.</summary> |
| | 16913 | | /// <param name="value">The value to convert the units of.</param> |
| | 16914 | | /// <param name="fromMassUnits1">The current units of the measurement.</param> |
| | 16915 | | /// <param name="fromLengthUnits2">The current units of the measurement.</param> |
| | 16916 | | /// <param name="fromTimeUnits3">The current units of the measurement.</param> |
| | 16917 | | /// <param name="fromTimeUnits4">The current units of the measurement.</param> |
| | 16918 | | /// <param name="toMassUnits1">The desired units of the measurement.</param> |
| | 16919 | | /// <param name="toLengthUnits2">The desired units of the measurement.</param> |
| | 16920 | | /// <param name="toTimeUnits3">The desired units of the measurement.</param> |
| | 16921 | | /// <param name="toTimeUnits4">The desired units of the measurement.</param> |
| | 16922 | | /// <returns>The Pressure measurement converted into the desired units.</returns> |
| | 16923 | | public static T Convert(T value |
| | 16924 | | , Mass.Units fromMassUnits1 |
| | 16925 | | , Length.Units fromLengthUnits2 |
| | 16926 | | , Time.Units fromTimeUnits3 |
| | 16927 | | , Time.Units fromTimeUnits4 |
| | 16928 | | , Mass.Units toMassUnits1 |
| | 16929 | | , Length.Units toLengthUnits2 |
| | 16930 | | , Time.Units toTimeUnits3 |
| | 16931 | | , Time.Units toTimeUnits4 |
| | 16932 | | ) |
| | 16933 | | { |
| | 16934 | | Pressure<T> measurement = new Pressure<T>(value |
| | 16935 | | , fromMassUnits1 |
| | 16936 | | , fromLengthUnits2 |
| | 16937 | | , fromTimeUnits3 |
| | 16938 | | , fromTimeUnits4 |
| | 16939 | | ); |
| | 16940 | | return measurement[ |
| | 16941 | | toMassUnits1 |
| | 16942 | | , toLengthUnits2 |
| | 16943 | | , toTimeUnits3 |
| | 16944 | | , toTimeUnits4 |
| | 16945 | | ]; |
| | 16946 | | } |
| | 16947 | |
|
| | 16948 | | /// <summary>Converts a Pressure measurement from units to another.</summary> |
| | 16949 | | /// <param name="value">The value to convert the units of.</param> |
| | 16950 | | /// <param name="from">The current units of the measurement.</param> |
| | 16951 | | /// <param name="to">The desired units of the measurement.</param> |
| | 16952 | | /// <returns>The Pressure measurement converted into the desired units.</returns> |
| | 16953 | | public static T Convert(T value, |
| | 16954 | | MeasurementUnitsSyntaxTypes.PressureBaseUnits from, |
| | 16955 | | MeasurementUnitsSyntaxTypes.PressureBaseUnits to) |
| | 16956 | | { |
| | 16957 | | return Convert(value |
| | 16958 | | , from._MassUnits1 |
| | 16959 | | , from._LengthUnits2 |
| | 16960 | | , from._TimeUnits3 |
| | 16961 | | , from._TimeUnits4 |
| | 16962 | | , to._MassUnits1 |
| | 16963 | | , to._LengthUnits2 |
| | 16964 | | , to._TimeUnits3 |
| | 16965 | | , to._TimeUnits4 |
| | 16966 | | ); |
| | 16967 | | } |
| | 16968 | |
|
| | 16969 | | /// <summary>Parses a Pressure measurement string.</summary> |
| | 16970 | | /// <param name="string">The string to be parsed.</param> |
| | 16971 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 16972 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 16973 | | public static (bool Success, Pressure<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value)> tryP |
| | 16974 | |
|
| | 16975 | | #endregion |
| | 16976 | |
|
| | 16977 | | #region Constructors |
| | 16978 | |
|
| | 16979 | | /// <summary>Constructs an Pressure with the measurement value and units.</summary> |
| | 16980 | | /// <param name="measurement">The measurement value of the Pressure.</param> |
| | 16981 | | /// <param name="units">The units of the Pressure.</param> |
| | 16982 | | public Pressure(T measurement, MeasurementUnitsSyntaxTypes.PressureBaseUnits units) : this(measurement |
| | 16983 | | , units._MassUnits1 |
| | 16984 | | , units._LengthUnits2 |
| | 16985 | | , units._TimeUnits3 |
| | 16986 | | , units._TimeUnits4 |
| | 16987 | | ) { } |
| | 16988 | |
|
| | 16989 | |
|
| | 16990 | | /// <summary>Constructs an Pressure with the measurement value and units.</summary> |
| | 16991 | | /// <param name="measurement">The measurement value of the Pressure.</param> |
| | 16992 | | /// <param name="MassUnits1">The units of the Pressure.</param> |
| | 16993 | | /// <param name="LengthUnits2">The units of the Pressure.</param> |
| | 16994 | | /// <param name="TimeUnits3">The units of the Pressure.</param> |
| | 16995 | | /// <param name="TimeUnits4">The units of the Pressure.</param> |
| | 16996 | | public Pressure(T measurement |
| | 16997 | | , Mass.Units MassUnits1 |
| | 16998 | | , Length.Units LengthUnits2 |
| | 16999 | | , Time.Units TimeUnits3 |
| | 17000 | | , Time.Units TimeUnits4 |
| | 17001 | | ) |
| | 17002 | | { |
| | 17003 | | _measurement = measurement; |
| | 17004 | | _MassUnits1 = MassUnits1; |
| | 17005 | | _LengthUnits2 = LengthUnits2; |
| | 17006 | | _TimeUnits3 = TimeUnits3; |
| | 17007 | | _TimeUnits4 = TimeUnits4; |
| | 17008 | | } |
| | 17009 | |
|
| | 17010 | | #endregion |
| | 17011 | |
|
| | 17012 | | #region Properties |
| | 17013 | |
|
| | 17014 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 17015 | | public Mass.Units MassUnits1 |
| | 17016 | | { |
| | 17017 | | get { return _MassUnits1; } |
| | 17018 | | set |
| | 17019 | | { |
| | 17020 | | if (value != _MassUnits1) |
| | 17021 | | { |
| | 17022 | | _measurement = this[value, _LengthUnits2, _TimeUnits3, _TimeUnits4]; |
| | 17023 | | _MassUnits1 = value; |
| | 17024 | | } |
| | 17025 | | } |
| | 17026 | | } |
| | 17027 | |
|
| | 17028 | | /// <summary>The #2 component of this measurements units.</summary> |
| | 17029 | | public Length.Units LengthUnits2 |
| | 17030 | | { |
| | 17031 | | get { return _LengthUnits2; } |
| | 17032 | | set |
| | 17033 | | { |
| | 17034 | | if (value != _LengthUnits2) |
| | 17035 | | { |
| | 17036 | | _measurement = this[_MassUnits1, value, _TimeUnits3, _TimeUnits4]; |
| | 17037 | | _LengthUnits2 = value; |
| | 17038 | | } |
| | 17039 | | } |
| | 17040 | | } |
| | 17041 | |
|
| | 17042 | | /// <summary>The #3 component of this measurements units.</summary> |
| | 17043 | | public Time.Units TimeUnits3 |
| | 17044 | | { |
| | 17045 | | get { return _TimeUnits3; } |
| | 17046 | | set |
| | 17047 | | { |
| | 17048 | | if (value != _TimeUnits3) |
| | 17049 | | { |
| | 17050 | | _measurement = this[_MassUnits1, _LengthUnits2, value, _TimeUnits4]; |
| | 17051 | | _TimeUnits3 = value; |
| | 17052 | | } |
| | 17053 | | } |
| | 17054 | | } |
| | 17055 | |
|
| | 17056 | | /// <summary>The #4 component of this measurements units.</summary> |
| | 17057 | | public Time.Units TimeUnits4 |
| | 17058 | | { |
| | 17059 | | get { return _TimeUnits4; } |
| | 17060 | | set |
| | 17061 | | { |
| | 17062 | | if (value != _TimeUnits4) |
| | 17063 | | { |
| | 17064 | | _measurement = this[_MassUnits1, _LengthUnits2, _TimeUnits3, value]; |
| | 17065 | | _TimeUnits4 = value; |
| | 17066 | | } |
| | 17067 | | } |
| | 17068 | | } |
| | 17069 | |
|
| | 17070 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 17071 | | /// <param name="units">The units to get the measurement in.</param> |
| | 17072 | | /// <returns>The measurement value in the specified units.</returns> |
| | 17073 | | public T this[MeasurementUnitsSyntaxTypes.PressureBaseUnits units] |
| | 17074 | | { |
| | 17075 | | get { return this[units._MassUnits1, units._LengthUnits2, units._TimeUnits3, units._TimeUnits4]; } |
| | 17076 | | } |
| | 17077 | |
|
| | 17078 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 17079 | | /// <param name="MassUnits1">The #1 component of this measurements units.</param> |
| | 17080 | | /// <param name="LengthUnits2">The #2 component of this measurements units.</param> |
| | 17081 | | /// <param name="TimeUnits3">The #3 component of this measurements units.</param> |
| | 17082 | | /// <param name="TimeUnits4">The #4 component of this measurements units.</param> |
| | 17083 | | /// <returns>The measurement value in the specified units.</returns> |
| | 17084 | | public T this[Mass.Units MassUnits1, Length.Units LengthUnits2, Time.Units TimeUnits3, Time.Units TimeUnits4] |
| | 17085 | | { |
| | 17086 | | get |
| | 17087 | | { |
| | 17088 | | T measurement = _measurement; |
| | 17089 | | if (MassUnits1 != _MassUnits1) |
| | 17090 | | { |
| | 17091 | | measurement = Mass<T>.Table[(int)_MassUnits1][(int)MassUnits1](measurement); |
| | 17092 | | //if (MassUnits1 < _MassUnits1) |
| | 17093 | | //{ |
| | 17094 | | // measurement = Mass<T>.Table[(int)_MassUnits1][(int)MassUnits1](measurement); |
| | 17095 | | //} |
| | 17096 | | //else |
| | 17097 | | //{ |
| | 17098 | | // measurement = Mass<T>.Table[(int)MassUnits1][(int)_MassUnits1](measurement); |
| | 17099 | | //} |
| | 17100 | | } |
| | 17101 | | if (LengthUnits2 != _LengthUnits2) |
| | 17102 | | { |
| | 17103 | | measurement = Length<T>.Table[(int)LengthUnits2][(int)_LengthUnits2](measurement); |
| | 17104 | | //if (LengthUnits2 > _LengthUnits2) |
| | 17105 | | //{ |
| | 17106 | | // measurement = Length<T>.Table[(int)_LengthUnits2][(int)LengthUnits2](measurement); |
| | 17107 | | //} |
| | 17108 | | //else |
| | 17109 | | //{ |
| | 17110 | | // measurement = Length<T>.Table[(int)LengthUnits2][(int)_LengthUnits2](measurement); |
| | 17111 | | //} |
| | 17112 | | } |
| | 17113 | | if (TimeUnits3 != _TimeUnits3) |
| | 17114 | | { |
| | 17115 | | measurement = Time<T>.Table[(int)TimeUnits3][(int)_TimeUnits3](measurement); |
| | 17116 | | //if (TimeUnits3 > _TimeUnits3) |
| | 17117 | | //{ |
| | 17118 | | // measurement = Time<T>.Table[(int)_TimeUnits3][(int)TimeUnits3](measurement); |
| | 17119 | | //} |
| | 17120 | | //else |
| | 17121 | | //{ |
| | 17122 | | // measurement = Time<T>.Table[(int)TimeUnits3][(int)_TimeUnits3](measurement); |
| | 17123 | | //} |
| | 17124 | | } |
| | 17125 | | if (TimeUnits4 != _TimeUnits4) |
| | 17126 | | { |
| | 17127 | | measurement = Time<T>.Table[(int)TimeUnits4][(int)_TimeUnits4](measurement); |
| | 17128 | | //if (TimeUnits4 > _TimeUnits4) |
| | 17129 | | //{ |
| | 17130 | | // measurement = Time<T>.Table[(int)_TimeUnits4][(int)TimeUnits4](measurement); |
| | 17131 | | //} |
| | 17132 | | //else |
| | 17133 | | //{ |
| | 17134 | | // measurement = Time<T>.Table[(int)TimeUnits4][(int)_TimeUnits4](measurement); |
| | 17135 | | //} |
| | 17136 | | } |
| | 17137 | | return measurement; |
| | 17138 | | } |
| | 17139 | | } |
| | 17140 | |
|
| | 17141 | | #endregion |
| | 17142 | |
|
| | 17143 | | #region Casting Operators |
| | 17144 | |
|
| | 17145 | | /// <summary>Converts a ValueTuple to a Pressure measurement.</summary> |
| | 17146 | | /// <param name="valueTuple">The ValueTuple to converted into a Pressure measurement.</param> |
| | 17147 | | public static implicit operator Pressure<T>((T, MeasurementUnitsSyntaxTypes.PressureBaseUnits) valueTuple) |
| | 17148 | | { |
| | 17149 | | return new Pressure<T>(valueTuple.Item1, valueTuple.Item2); |
| | 17150 | | } |
| | 17151 | |
|
| | 17152 | | #endregion |
| | 17153 | |
|
| | 17154 | | #region Mathematics |
| | 17155 | |
|
| | 17156 | | #region Bases |
| | 17157 | |
|
| | 17158 | | internal static Pressure<T> MathBase(Pressure<T> a, T b, Func<T, T, T> func) |
| | 17159 | | { |
| | 17160 | | return new Pressure<T>(func(a._measurement, b) |
| | 17161 | | , a._MassUnits1 |
| | 17162 | | , a._LengthUnits2 |
| | 17163 | | , a._TimeUnits3 |
| | 17164 | | , a._TimeUnits4 |
| | 17165 | | ); |
| | 17166 | | } |
| | 17167 | |
|
| | 17168 | | internal static Pressure<T> MathBase(Pressure<T> a, Pressure<T> b, Func<T, T, T> func) |
| | 17169 | | { |
| | 17170 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 17171 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 17172 | | Time.Units TimeUnits3 = a._TimeUnits3 <= b._TimeUnits3 ? a._TimeUnits3 : b._TimeUnits3; |
| | 17173 | | Time.Units TimeUnits4 = a._TimeUnits4 <= b._TimeUnits4 ? a._TimeUnits4 : b._TimeUnits4; |
| | 17174 | | T A = a[MassUnits1, LengthUnits2, TimeUnits3, TimeUnits4]; |
| | 17175 | | T B = b[MassUnits1, LengthUnits2, TimeUnits3, TimeUnits4]; |
| | 17176 | | T C = func(A, B); |
| | 17177 | | return new Pressure<T>(C, MassUnits1, LengthUnits2, TimeUnits3, TimeUnits4); |
| | 17178 | | } |
| | 17179 | |
|
| | 17180 | | internal static bool LogicBase(Pressure<T> a, Pressure<T> b, Func<T, T, bool> func) |
| | 17181 | | { |
| | 17182 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 17183 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 17184 | | Time.Units TimeUnits3 = a._TimeUnits3 <= b._TimeUnits3 ? a._TimeUnits3 : b._TimeUnits3; |
| | 17185 | | Time.Units TimeUnits4 = a._TimeUnits4 <= b._TimeUnits4 ? a._TimeUnits4 : b._TimeUnits4; |
| | 17186 | | T A = a[MassUnits1, LengthUnits2, TimeUnits3, TimeUnits4]; |
| | 17187 | | T B = b[MassUnits1, LengthUnits2, TimeUnits3, TimeUnits4]; |
| | 17188 | | return func(A, B); |
| | 17189 | | } |
| | 17190 | |
|
| | 17191 | | #endregion |
| | 17192 | |
|
| | 17193 | | #region Add |
| | 17194 | |
|
| | 17195 | | /// <summary>Adds two Pressure measurements.</summary> |
| | 17196 | | /// <param name="a">The first operand of the addition.</param> |
| | 17197 | | /// <param name="b">The second operand of the addition.</param> |
| | 17198 | | /// <returns>The result of the addition operation.</returns> |
| | 17199 | | public static Pressure<T> Add(Pressure<T> a, Pressure<T> b) |
| | 17200 | | { |
| | 17201 | | return MathBase(a, b, Statics.Addition); |
| | 17202 | | } |
| | 17203 | |
|
| | 17204 | | /// <summary>Adds two Pressure measurements.</summary> |
| | 17205 | | /// <param name="a">The first operand of the addition.</param> |
| | 17206 | | /// <param name="b">The second operand of the addition.</param> |
| | 17207 | | /// <returns>The result of the addition operation.</returns> |
| | 17208 | | public static Pressure<T> operator +(Pressure<T> a, Pressure<T> b) |
| | 17209 | | { |
| | 17210 | | return Add(a, b); |
| | 17211 | | } |
| | 17212 | |
|
| | 17213 | | /// <summary>Adds two Pressure measurements.</summary> |
| | 17214 | | /// <param name="b">The second operand of the addition.</param> |
| | 17215 | | /// <returns>The result of the addition operation.</returns> |
| | 17216 | | public Pressure<T> Add(Pressure<T> b) |
| | 17217 | | { |
| | 17218 | | return this + b; |
| | 17219 | | } |
| | 17220 | |
|
| | 17221 | | #endregion |
| | 17222 | |
|
| | 17223 | | #region Subtract |
| | 17224 | |
|
| | 17225 | | /// <summary>Subtracts two Pressure measurements.</summary> |
| | 17226 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 17227 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 17228 | | /// <returns>The result of the subtraction.</returns> |
| | 17229 | | public static Pressure<T> Subtract(Pressure<T> a, Pressure<T> b) |
| | 17230 | | { |
| | 17231 | | return MathBase(a, b, Statics.Subtraction); |
| | 17232 | | } |
| | 17233 | |
|
| | 17234 | | /// <summary>Subtracts two Pressure measurements.</summary> |
| | 17235 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 17236 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 17237 | | /// <returns>The result of the subtraction.</returns> |
| | 17238 | | public static Pressure<T> operator -(Pressure<T> a, Pressure<T> b) |
| | 17239 | | { |
| | 17240 | | return Subtract(a, b); |
| | 17241 | | } |
| | 17242 | |
|
| | 17243 | | /// <summary>Subtracts two Pressure measurements.</summary> |
| | 17244 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 17245 | | /// <returns>The result of the subtraction.</returns> |
| | 17246 | | public Pressure<T> Subtract(Pressure<T> b) |
| | 17247 | | { |
| | 17248 | | return this - b; |
| | 17249 | | } |
| | 17250 | |
|
| | 17251 | | #endregion |
| | 17252 | |
|
| | 17253 | | #region Multiply |
| | 17254 | |
|
| | 17255 | | /// <summary>Multiplies an Pressure by a scalar numeric value.</summary> |
| | 17256 | | /// <param name="a">The Pressure measurement to multiply.</param> |
| | 17257 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 17258 | | /// <returns>The result of the multiplication.</returns> |
| | 17259 | | public static Pressure<T> Multiply(Pressure<T> a, T b) |
| | 17260 | | { |
| | 17261 | | return MathBase(a, b, Statics.Multiplication); |
| | 17262 | | } |
| | 17263 | |
|
| | 17264 | | /// <summary>Multiplies an Pressure by a scalar numeric value.</summary> |
| | 17265 | | /// <param name="a">The Pressure measurement to multiply.</param> |
| | 17266 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 17267 | | /// <returns>The result of the multiplication.</returns> |
| | 17268 | | public static Pressure<T> Multiply(T b, Pressure<T> a) |
| | 17269 | | { |
| | 17270 | | return Multiply(a, b); |
| | 17271 | | } |
| | 17272 | |
|
| | 17273 | | /// <summary>Multiplies an Pressure by a scalar numeric value.</summary> |
| | 17274 | | /// <param name="a">The Pressure measurement to multiply.</param> |
| | 17275 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 17276 | | /// <returns>The result of the multiplication.</returns> |
| | 17277 | | public static Pressure<T> operator *(Pressure<T> a, T b) |
| | 17278 | | { |
| | 17279 | | return Multiply(a, b); |
| | 17280 | | } |
| | 17281 | |
|
| | 17282 | | /// <summary>Multiplies an Pressure by a scalar numeric value.</summary> |
| | 17283 | | /// <param name="a">The Pressure measurement to multiply.</param> |
| | 17284 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 17285 | | /// <returns>The result of the multiplication.</returns> |
| | 17286 | | public static Pressure<T> operator *(T b, Pressure<T> a) |
| | 17287 | | { |
| | 17288 | | return Multiply(b, a); |
| | 17289 | | } |
| | 17290 | |
|
| | 17291 | | /// <summary>Multiplies an Pressure by a scalar numeric value.</summary> |
| | 17292 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 17293 | | /// <returns>The result of the multiplication.</returns> |
| | 17294 | | public Pressure<T> Add(T b) |
| | 17295 | | { |
| | 17296 | | return this * b; |
| | 17297 | | } |
| | 17298 | |
|
| | 17299 | | #region Pressure<T> * Area<T> = Force<T> |
| | 17300 | |
|
| | 17301 | | /// <summary>Mulitplies Pressure by Area resulting in Force.</summary> |
| | 17302 | | /// <param name="a">The Pressure to be multiplied.</param> |
| | 17303 | | /// <param name="b">The Area to multiply by.</param> |
| | 17304 | | /// <returns>The Force result of the multiplication.</returns> |
| | 17305 | | public static Force<T> Multiply(Pressure<T> a, Area<T> b) |
| | 17306 | | { |
| | 17307 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 17308 | |
|
| | 17309 | | T A = a[a._MassUnits1, LengthUnits1, a._TimeUnits3, a._TimeUnits4]; |
| | 17310 | | T B = b[LengthUnits1, b._LengthUnits2]; |
| | 17311 | | T C = Statics.Multiplication(A, B); |
| | 17312 | |
|
| | 17313 | | return new Force<T>(C |
| | 17314 | | , a._MassUnits1 |
| | 17315 | | , b._LengthUnits2 |
| | 17316 | | , a._TimeUnits3 |
| | 17317 | | , a._TimeUnits4 |
| | 17318 | | ); |
| | 17319 | | } |
| | 17320 | |
|
| | 17321 | | /// <summary>Mulitplies Pressure by Area resulting in Force.</summary> |
| | 17322 | | /// <param name="a">The Pressure to be multiplied.</param> |
| | 17323 | | /// <param name="b">The Area to multiply by.</param> |
| | 17324 | | /// <returns>The Force result of the multiplication.</returns> |
| | 17325 | | public static Force<T> operator *(Pressure<T> a, Area<T> b) |
| | 17326 | | { |
| | 17327 | | return Multiply(a, b); |
| | 17328 | | } |
| | 17329 | |
|
| | 17330 | | /// <summary>Mulitplies Pressure by Area resulting in Force.</summary> |
| | 17331 | | /// <param name="b">The Area to multiply by.</param> |
| | 17332 | | /// <returns>The Force result of the multiplication.</returns> |
| | 17333 | | public Force<T> Multiply(Area<T> b) |
| | 17334 | | { |
| | 17335 | | return this * b; |
| | 17336 | | } |
| | 17337 | |
|
| | 17338 | | #endregion |
| | 17339 | |
|
| | 17340 | | #region Pressure<T> * TimeArea<T> = LinearDensity<T> |
| | 17341 | |
|
| | 17342 | | /// <summary>Mulitplies Pressure by TimeArea resulting in LinearDensity.</summary> |
| | 17343 | | /// <param name="a">The Pressure to be multiplied.</param> |
| | 17344 | | /// <param name="b">The TimeArea to multiply by.</param> |
| | 17345 | | /// <returns>The LinearDensity result of the multiplication.</returns> |
| | 17346 | | public static LinearDensity<T> Multiply(Pressure<T> a, TimeArea<T> b) |
| | 17347 | | { |
| | 17348 | | Time.Units TimeUnits1 = a._TimeUnits3 <= b._TimeUnits1 ? a._TimeUnits3 : b._TimeUnits1; |
| | 17349 | | Time.Units TimeUnits2 = a._TimeUnits4 <= b._TimeUnits2 ? a._TimeUnits4 : b._TimeUnits2; |
| | 17350 | |
|
| | 17351 | | T A = a[a._MassUnits1, a._LengthUnits2, TimeUnits1, TimeUnits2]; |
| | 17352 | | T B = b[TimeUnits1, TimeUnits2]; |
| | 17353 | | T C = Statics.Multiplication(A, B); |
| | 17354 | |
|
| | 17355 | | return new LinearDensity<T>(C |
| | 17356 | | , a._MassUnits1 |
| | 17357 | | , a._LengthUnits2 |
| | 17358 | | ); |
| | 17359 | | } |
| | 17360 | |
|
| | 17361 | | /// <summary>Mulitplies Pressure by TimeArea resulting in LinearDensity.</summary> |
| | 17362 | | /// <param name="a">The Pressure to be multiplied.</param> |
| | 17363 | | /// <param name="b">The TimeArea to multiply by.</param> |
| | 17364 | | /// <returns>The LinearDensity result of the multiplication.</returns> |
| | 17365 | | public static LinearDensity<T> operator *(Pressure<T> a, TimeArea<T> b) |
| | 17366 | | { |
| | 17367 | | return Multiply(a, b); |
| | 17368 | | } |
| | 17369 | |
|
| | 17370 | | /// <summary>Mulitplies Pressure by TimeArea resulting in LinearDensity.</summary> |
| | 17371 | | /// <param name="b">The TimeArea to multiply by.</param> |
| | 17372 | | /// <returns>The LinearDensity result of the multiplication.</returns> |
| | 17373 | | public LinearDensity<T> Multiply(TimeArea<T> b) |
| | 17374 | | { |
| | 17375 | | return this * b; |
| | 17376 | | } |
| | 17377 | |
|
| | 17378 | | #endregion |
| | 17379 | |
|
| | 17380 | | #region Pressure<T> * Volume<T> = Energy<T> |
| | 17381 | |
|
| | 17382 | | /// <summary>Mulitplies Pressure by Volume resulting in Energy.</summary> |
| | 17383 | | /// <param name="a">The Pressure to be multiplied.</param> |
| | 17384 | | /// <param name="b">The Volume to multiply by.</param> |
| | 17385 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 17386 | | public static Energy<T> Multiply(Pressure<T> a, Volume<T> b) |
| | 17387 | | { |
| | 17388 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 17389 | |
|
| | 17390 | | T A = a[a._MassUnits1, LengthUnits1, a._TimeUnits3, a._TimeUnits4]; |
| | 17391 | | T B = b[LengthUnits1, b._LengthUnits2, b._LengthUnits3]; |
| | 17392 | | T C = Statics.Multiplication(A, B); |
| | 17393 | |
|
| | 17394 | | return new Energy<T>(C |
| | 17395 | | , a._MassUnits1 |
| | 17396 | | , b._LengthUnits2 |
| | 17397 | | , b._LengthUnits3 |
| | 17398 | | , a._TimeUnits3 |
| | 17399 | | , a._TimeUnits4 |
| | 17400 | | ); |
| | 17401 | | } |
| | 17402 | |
|
| | 17403 | | /// <summary>Mulitplies Pressure by Volume resulting in Energy.</summary> |
| | 17404 | | /// <param name="a">The Pressure to be multiplied.</param> |
| | 17405 | | /// <param name="b">The Volume to multiply by.</param> |
| | 17406 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 17407 | | public static Energy<T> operator *(Pressure<T> a, Volume<T> b) |
| | 17408 | | { |
| | 17409 | | return Multiply(a, b); |
| | 17410 | | } |
| | 17411 | |
|
| | 17412 | | /// <summary>Mulitplies Pressure by Volume resulting in Energy.</summary> |
| | 17413 | | /// <param name="b">The Volume to multiply by.</param> |
| | 17414 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 17415 | | public Energy<T> Multiply(Volume<T> b) |
| | 17416 | | { |
| | 17417 | | return this * b; |
| | 17418 | | } |
| | 17419 | |
|
| | 17420 | | #endregion |
| | 17421 | |
|
| | 17422 | | #region Pressure<T> * VolumeRate<T> = Power<T> |
| | 17423 | |
|
| | 17424 | | /// <summary>Mulitplies Pressure by VolumeRate resulting in Power.</summary> |
| | 17425 | | /// <param name="a">The Pressure to be multiplied.</param> |
| | 17426 | | /// <param name="b">The VolumeRate to multiply by.</param> |
| | 17427 | | /// <returns>The Power result of the multiplication.</returns> |
| | 17428 | | public static Power<T> Multiply(Pressure<T> a, VolumeRate<T> b) |
| | 17429 | | { |
| | 17430 | | Length.Units LengthUnits1 = a._LengthUnits2 <= b._LengthUnits1 ? a._LengthUnits2 : b._LengthUnits1; |
| | 17431 | |
|
| | 17432 | | T A = a[a._MassUnits1, LengthUnits1, a._TimeUnits3, a._TimeUnits4]; |
| | 17433 | | T B = b[LengthUnits1, b._LengthUnits2, b._LengthUnits3, b._TimeUnits4]; |
| | 17434 | | T C = Statics.Multiplication(A, B); |
| | 17435 | |
|
| | 17436 | | return new Power<T>(C |
| | 17437 | | , a._MassUnits1 |
| | 17438 | | , b._LengthUnits2 |
| | 17439 | | , b._LengthUnits3 |
| | 17440 | | , a._TimeUnits3 |
| | 17441 | | , a._TimeUnits4 |
| | 17442 | | , b._TimeUnits4 |
| | 17443 | | ); |
| | 17444 | | } |
| | 17445 | |
|
| | 17446 | | /// <summary>Mulitplies Pressure by VolumeRate resulting in Power.</summary> |
| | 17447 | | /// <param name="a">The Pressure to be multiplied.</param> |
| | 17448 | | /// <param name="b">The VolumeRate to multiply by.</param> |
| | 17449 | | /// <returns>The Power result of the multiplication.</returns> |
| | 17450 | | public static Power<T> operator *(Pressure<T> a, VolumeRate<T> b) |
| | 17451 | | { |
| | 17452 | | return Multiply(a, b); |
| | 17453 | | } |
| | 17454 | |
|
| | 17455 | | /// <summary>Mulitplies Pressure by VolumeRate resulting in Power.</summary> |
| | 17456 | | /// <param name="b">The VolumeRate to multiply by.</param> |
| | 17457 | | /// <returns>The Power result of the multiplication.</returns> |
| | 17458 | | public Power<T> Multiply(VolumeRate<T> b) |
| | 17459 | | { |
| | 17460 | | return this * b; |
| | 17461 | | } |
| | 17462 | |
|
| | 17463 | | #endregion |
| | 17464 | |
|
| | 17465 | | #endregion |
| | 17466 | |
|
| | 17467 | | #region Divide |
| | 17468 | |
|
| | 17469 | | /// <summary>Divides an Pressure measurement by another Pressure measurement resulting in a scalar numeric value.</s |
| | 17470 | | /// <param name="a">The first operand of the division operation.</param> |
| | 17471 | | /// <param name="b">The second operand of the division operation.</param> |
| | 17472 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 17473 | | public static T Divide(Pressure<T> a, Pressure<T> b) |
| | 17474 | | { |
| | 17475 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 17476 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 17477 | | Time.Units TimeUnits3 = a._TimeUnits3 <= b._TimeUnits3 ? a._TimeUnits3 : b._TimeUnits3; |
| | 17478 | | Time.Units TimeUnits4 = a._TimeUnits4 <= b._TimeUnits4 ? a._TimeUnits4 : b._TimeUnits4; |
| | 17479 | | T A = a[MassUnits1, LengthUnits2, TimeUnits3, TimeUnits4]; |
| | 17480 | | T B = b[MassUnits1, LengthUnits2, TimeUnits3, TimeUnits4]; |
| | 17481 | | return Statics.Division(A, B); |
| | 17482 | | } |
| | 17483 | |
|
| | 17484 | | /// <summary>Divides this Pressure measurement by a numaric scalar value.</summary> |
| | 17485 | | /// <param name="a">The Pressure measurement to divide.</param> |
| | 17486 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 17487 | | /// <returns>The result of the division.</returns> |
| | 17488 | | public static Pressure<T> Divide(Pressure<T> a, T b) |
| | 17489 | | { |
| | 17490 | | return MathBase(a, b, Statics.Division); |
| | 17491 | | } |
| | 17492 | |
|
| | 17493 | | /// <summary>Divides this Pressure measurement by a numaric scalar value.</summary> |
| | 17494 | | /// <param name="a">The Pressure measurement to divide.</param> |
| | 17495 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 17496 | | /// <returns>The result of the division.</returns> |
| | 17497 | | public static Pressure<T> operator /(Pressure<T> a, T b) |
| | 17498 | | { |
| | 17499 | | return Divide(a, b); |
| | 17500 | | } |
| | 17501 | |
|
| | 17502 | | /// <summary>Divides this Pressure measurement by a numaric scalar value.</summary> |
| | 17503 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 17504 | | /// <returns>The result of the division.</returns> |
| | 17505 | | public Pressure<T> Divide(T b) |
| | 17506 | | { |
| | 17507 | | return this / b; |
| | 17508 | | } |
| | 17509 | |
|
| | 17510 | | /// <summary>Divides an Pressure measurement by another Pressure measurement resulting in a scalar numeric value.</s |
| | 17511 | | /// <param name="a">The first operand of the division operation.</param> |
| | 17512 | | /// <param name="b">The second operand of the division operation.</param> |
| | 17513 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 17514 | | public static T operator /(Pressure<T> a, Pressure<T> b) |
| | 17515 | | { |
| | 17516 | | return Divide(a, b); |
| | 17517 | | } |
| | 17518 | |
|
| | 17519 | | /// <summary>Divides an Pressure measurement by another Pressure measurement resulting in a scalar numeric value.</s |
| | 17520 | | /// <param name="b">The second operand of the division operation.</param> |
| | 17521 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 17522 | | public T Divide(Pressure<T> b) |
| | 17523 | | { |
| | 17524 | | return this / b; |
| | 17525 | | } |
| | 17526 | |
|
| | 17527 | |
|
| | 17528 | | #region Pressure<T> / Acceleration<T> = AreaDensity<T> |
| | 17529 | |
|
| | 17530 | | /// <summary>Divides Pressure by Acceleration resulting in AreaDensity.</summary> |
| | 17531 | | /// <param name="a">The Pressure to be divided.</param> |
| | 17532 | | /// <param name="b">The Acceleration to divide by.</param> |
| | 17533 | | /// <returns>The AreaDensity result of the division.</returns> |
| | 17534 | | public static AreaDensity<T> Divide(Pressure<T> a, Acceleration<T> b) |
| | 17535 | | { |
| | 17536 | | Time.Units TimeUnits1 = a._TimeUnits3 <= b._TimeUnits2 ? a._TimeUnits3 : b._TimeUnits2; |
| | 17537 | | Time.Units TimeUnits2 = a._TimeUnits4 <= b._TimeUnits3 ? a._TimeUnits4 : b._TimeUnits3; |
| | 17538 | |
|
| | 17539 | | T A = a[a._MassUnits1, a._LengthUnits2, TimeUnits1, TimeUnits2]; |
| | 17540 | | T B = b[b._LengthUnits1, TimeUnits1, TimeUnits2]; |
| | 17541 | | T C = Statics.Division(A, B); |
| | 17542 | |
|
| | 17543 | | return new AreaDensity<T>(C |
| | 17544 | | , a._MassUnits1 |
| | 17545 | | , a._LengthUnits2 |
| | 17546 | | , b._LengthUnits1 |
| | 17547 | | ); |
| | 17548 | | } |
| | 17549 | |
|
| | 17550 | | /// <summary>Divides Pressure by Acceleration resulting in AreaDensity.</summary> |
| | 17551 | | /// <param name="a">The Pressure to be divided.</param> |
| | 17552 | | /// <param name="b">The Acceleration to divide by.</param> |
| | 17553 | | /// <returns>The AreaDensity result of the division.</returns> |
| | 17554 | | public static AreaDensity<T> operator /(Pressure<T> a, Acceleration<T> b) |
| | 17555 | | { |
| | 17556 | | return Divide(a, b); |
| | 17557 | | } |
| | 17558 | |
|
| | 17559 | | /// <summary>Divides Pressure by Acceleration resulting in AreaDensity.</summary> |
| | 17560 | | /// <param name="b">The Acceleration to divide by.</param> |
| | 17561 | | /// <returns>The AreaDensity result of the division.</returns> |
| | 17562 | | public AreaDensity<T> Divide(Acceleration<T> b) |
| | 17563 | | { |
| | 17564 | | return this / b; |
| | 17565 | | } |
| | 17566 | |
|
| | 17567 | | #endregion |
| | 17568 | |
|
| | 17569 | |
|
| | 17570 | | #region Pressure<T> / AreaDensity<T> = Acceleration<T> |
| | 17571 | |
|
| | 17572 | | /// <summary>Divides Pressure by AreaDensity resulting in Acceleration.</summary> |
| | 17573 | | /// <param name="a">The Pressure to be divided.</param> |
| | 17574 | | /// <param name="b">The AreaDensity to divide by.</param> |
| | 17575 | | /// <returns>The Acceleration result of the division.</returns> |
| | 17576 | | public static Acceleration<T> Divide(Pressure<T> a, AreaDensity<T> b) |
| | 17577 | | { |
| | 17578 | | Mass.Units MassUnits1 = a._MassUnits1 <= b._MassUnits1 ? a._MassUnits1 : b._MassUnits1; |
| | 17579 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 17580 | |
|
| | 17581 | | T A = a[MassUnits1, LengthUnits2, a._TimeUnits3, a._TimeUnits4]; |
| | 17582 | | T B = b[MassUnits1, LengthUnits2, b._LengthUnits3]; |
| | 17583 | | T C = Statics.Division(A, B); |
| | 17584 | |
|
| | 17585 | | return new Acceleration<T>(C |
| | 17586 | | , b._LengthUnits3 |
| | 17587 | | , a._TimeUnits3 |
| | 17588 | | , a._TimeUnits4 |
| | 17589 | | ); |
| | 17590 | | } |
| | 17591 | |
|
| | 17592 | | /// <summary>Divides Pressure by AreaDensity resulting in Acceleration.</summary> |
| | 17593 | | /// <param name="a">The Pressure to be divided.</param> |
| | 17594 | | /// <param name="b">The AreaDensity to divide by.</param> |
| | 17595 | | /// <returns>The Acceleration result of the division.</returns> |
| | 17596 | | public static Acceleration<T> operator /(Pressure<T> a, AreaDensity<T> b) |
| | 17597 | | { |
| | 17598 | | return Divide(a, b); |
| | 17599 | | } |
| | 17600 | |
|
| | 17601 | | /// <summary>Divides Pressure by AreaDensity resulting in Acceleration.</summary> |
| | 17602 | | /// <param name="b">The AreaDensity to divide by.</param> |
| | 17603 | | /// <returns>The Acceleration result of the division.</returns> |
| | 17604 | | public Acceleration<T> Divide(AreaDensity<T> b) |
| | 17605 | | { |
| | 17606 | | return this / b; |
| | 17607 | | } |
| | 17608 | |
|
| | 17609 | | #endregion |
| | 17610 | |
|
| | 17611 | | #endregion |
| | 17612 | |
|
| | 17613 | | #region LessThan |
| | 17614 | |
|
| | 17615 | | /// <summary>Determines if an Pressure measurement is less than another Pressure measurement.</summary> |
| | 17616 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 17617 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 17618 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 17619 | | public static bool LessThan(Pressure<T> a, Pressure<T> b) |
| | 17620 | | { |
| | 17621 | | return LogicBase(a, b, Statics.LessThan); |
| | 17622 | | } |
| | 17623 | |
|
| | 17624 | | /// <summary>Determines if an Pressure measurement is less than another Pressure measurement.</summary> |
| | 17625 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 17626 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 17627 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 17628 | | public static bool operator <(Pressure<T> a, Pressure<T> b) |
| | 17629 | | { |
| | 17630 | | return LessThan(a, b); |
| | 17631 | | } |
| | 17632 | |
|
| | 17633 | | /// <summary>Determines if an Pressure measurement is less than another Pressure measurement.</summary> |
| | 17634 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 17635 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 17636 | | public bool LessThan(Pressure<T> b) |
| | 17637 | | { |
| | 17638 | | return this < b; |
| | 17639 | | } |
| | 17640 | |
|
| | 17641 | | #endregion |
| | 17642 | |
|
| | 17643 | | #region GreaterThan |
| | 17644 | |
|
| | 17645 | | /// <summary>Determines if an Pressure measurement is greater than another Pressure measurement.</summary> |
| | 17646 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 17647 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 17648 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 17649 | | public static bool GreaterThan(Pressure<T> a, Pressure<T> b) |
| | 17650 | | { |
| | 17651 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 17652 | | } |
| | 17653 | |
|
| | 17654 | | /// <summary>Determines if an Pressure measurement is greater than another Pressure measurement.</summary> |
| | 17655 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 17656 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 17657 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 17658 | | public static bool operator >(Pressure<T> a, Pressure<T> b) |
| | 17659 | | { |
| | 17660 | | return GreaterThan(a, b); |
| | 17661 | | } |
| | 17662 | |
|
| | 17663 | | /// <summary>Determines if an Pressure measurement is greater than another Pressure measurement.</summary> |
| | 17664 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 17665 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 17666 | | public bool GreaterThan(Pressure<T> b) |
| | 17667 | | { |
| | 17668 | | return this > b; |
| | 17669 | | } |
| | 17670 | |
|
| | 17671 | | #endregion |
| | 17672 | |
|
| | 17673 | | #region LessThanOrEqual |
| | 17674 | |
|
| | 17675 | | /// <summary>Determines if an Pressure measurement is less than or equal to another Pressure measurement.</summary> |
| | 17676 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 17677 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 17678 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 17679 | | public static bool LessThanOrEqual(Pressure<T> a, Pressure<T> b) |
| | 17680 | | { |
| | 17681 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 17682 | | } |
| | 17683 | |
|
| | 17684 | | /// <summary>Determines if an Pressure measurement is less than or equal to another Pressure measurement.</summary> |
| | 17685 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 17686 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 17687 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 17688 | | public static bool operator <=(Pressure<T> a, Pressure<T> b) |
| | 17689 | | { |
| | 17690 | | return LessThanOrEqual(a, b); |
| | 17691 | | } |
| | 17692 | |
|
| | 17693 | | /// <summary>Determines if an Pressure measurement is less than or equal to another Pressure measurement.</summary> |
| | 17694 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 17695 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 17696 | | public bool LessThanOrEqual(Pressure<T> b) |
| | 17697 | | { |
| | 17698 | | return this <= b; |
| | 17699 | | } |
| | 17700 | |
|
| | 17701 | | #endregion |
| | 17702 | |
|
| | 17703 | | #region GreaterThanOrEqual |
| | 17704 | |
|
| | 17705 | | /// <summary>Determines if an Pressure measurement is greater than or equal to another Pressure measurement.</summar |
| | 17706 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 17707 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 17708 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 17709 | | public static bool GreaterThanOrEqual(Pressure<T> a, Pressure<T> b) |
| | 17710 | | { |
| | 17711 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 17712 | | } |
| | 17713 | |
|
| | 17714 | | /// <summary>Determines if an Pressure measurement is greater than or equal to another Pressure measurement.</summar |
| | 17715 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 17716 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 17717 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 17718 | | public static bool operator >=(Pressure<T> a, Pressure<T> b) |
| | 17719 | | { |
| | 17720 | | return GreaterThanOrEqual(a, b); |
| | 17721 | | } |
| | 17722 | |
|
| | 17723 | | /// <summary>Determines if an Pressure measurement is greater than or equal to another Pressure measurement.</summar |
| | 17724 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 17725 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 17726 | | public bool GreaterThanOrEqual(Pressure<T> b) |
| | 17727 | | { |
| | 17728 | | return this >= b; |
| | 17729 | | } |
| | 17730 | |
|
| | 17731 | | #endregion |
| | 17732 | |
|
| | 17733 | | #region Equal |
| | 17734 | |
|
| | 17735 | | /// <summary>Determines if an Pressure measurement is equal to another Pressure measurement.</summary> |
| | 17736 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 17737 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 17738 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 17739 | | public static bool Equal(Pressure<T> a, Pressure<T> b) |
| | 17740 | | { |
| | 17741 | | return LogicBase(a, b, Statics.Equate); |
| | 17742 | | } |
| | 17743 | |
|
| | 17744 | | /// <summary>Determines if an Pressure measurement is equal to another Pressure measurement.</summary> |
| | 17745 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 17746 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 17747 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 17748 | | public static bool operator ==(Pressure<T> a, Pressure<T> b) |
| | 17749 | | { |
| | 17750 | | return Equal(a, b); |
| | 17751 | | } |
| | 17752 | |
|
| | 17753 | | /// <summary>Determines if an Pressure measurement is equal to another Pressure measurement.</summary> |
| | 17754 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 17755 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 17756 | | public bool Equal(Pressure<T> b) |
| | 17757 | | { |
| | 17758 | | return this == b; |
| | 17759 | | } |
| | 17760 | |
|
| | 17761 | | #endregion |
| | 17762 | |
|
| | 17763 | | #region NotEqual |
| | 17764 | |
|
| | 17765 | | /// <summary>Determines if an Pressure measurement is not equal to another Pressure measurement.</summary> |
| | 17766 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 17767 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 17768 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 17769 | | public static bool NotEqual(Pressure<T> a, Pressure<T> b) |
| | 17770 | | { |
| | 17771 | | return LogicBase(a, b, Statics.Inequate); |
| | 17772 | | } |
| | 17773 | |
|
| | 17774 | | /// <summary>Determines if an Pressure measurement is not equal to another Pressure measurement.</summary> |
| | 17775 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 17776 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 17777 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 17778 | | public static bool operator !=(Pressure<T> a, Pressure<T> b) |
| | 17779 | | { |
| | 17780 | | return NotEqual(a, b); |
| | 17781 | | } |
| | 17782 | |
|
| | 17783 | | /// <summary>Determines if an Pressure measurement is not equal to another Pressure measurement.</summary> |
| | 17784 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 17785 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 17786 | | public bool NotEqual(Pressure<T> b) |
| | 17787 | | { |
| | 17788 | | return this != b; |
| | 17789 | | } |
| | 17790 | |
|
| | 17791 | | #endregion |
| | 17792 | |
|
| | 17793 | | #endregion |
| | 17794 | |
|
| | 17795 | | #region Overrides |
| | 17796 | |
|
| | 17797 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 17798 | | /// <param name="obj">The object to check for equality with.</param> |
| | 17799 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 17800 | | public override bool Equals(object obj) |
| | 17801 | | { |
| | 17802 | | if (obj is Pressure<T>) |
| | 17803 | | { |
| | 17804 | | return this == (Pressure<T>)obj; |
| | 17805 | | } |
| | 17806 | | return false; |
| | 17807 | | } |
| | 17808 | |
|
| | 17809 | | /// <summary>Converts the Pressure measurement to a string represenation.</summary> |
| | 17810 | | /// <returns>The string representation of the measurement.</returns> |
| | 17811 | | public override string ToString() |
| | 17812 | | { |
| | 17813 | | return _measurement + " " + |
| | 17814 | | _MassUnits1 |
| | 17815 | | + "/" + |
| | 17816 | | _LengthUnits2 + "/" + _TimeUnits3 + "/" + _TimeUnits4 |
| | 17817 | | ; |
| | 17818 | | } |
| | 17819 | |
|
| | 17820 | | /// <summary>Base hashing function for Pressure measurements.</summary> |
| | 17821 | | /// <returns>Computed hash code for this instance.</returns> |
| | 17822 | | public override int GetHashCode() => Hash(_measurement); |
| | 17823 | |
|
| | 17824 | | #endregion |
| | 17825 | | } |
| | 17826 | |
|
| | 17827 | | #endregion |
| | 17828 | |
|
| | 17829 | | #region Speed |
| | 17830 | |
|
| | 17831 | | internal static partial class ParsingFunctions |
| | 17832 | | { |
| | 17833 | | [Measurement.Parseable("Length/Time")] |
| | 17834 | | public static object Speed<T>(T value, object[] units) |
| | 17835 | | { |
| | 17836 | | if (units.Length != 2) |
| | 17837 | | { |
| | 17838 | | throw new Exception("Bug in Towel. Invalid parameters to Speed Factory."); |
| | 17839 | | } |
| | 17840 | | if (!(units[0] is Length.Units)) |
| | 17841 | | { |
| | 17842 | | throw new Exception("Bug in Towel. Invalid parameters to Speed Factory."); |
| | 17843 | | } |
| | 17844 | | if (!(units[1] is Time.Units)) |
| | 17845 | | { |
| | 17846 | | throw new Exception("Bug in Towel. Invalid parameters to Speed Factory."); |
| | 17847 | | } |
| | 17848 | | return new Speed<T>(value |
| | 17849 | | , (Length.Units)units[0] |
| | 17850 | | , (Time.Units)units[1] |
| | 17851 | | ); |
| | 17852 | | } |
| | 17853 | | } |
| | 17854 | |
|
| | 17855 | | /// <summary>Speed measurement with a value and the units.</summary> |
| | 17856 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 17857 | | public struct Speed<T> |
| | 17858 | | { |
| | 17859 | | internal T _measurement; |
| | 17860 | | internal Length.Units _LengthUnits1; |
| | 17861 | | internal Time.Units _TimeUnits2; |
| | 17862 | |
|
| | 17863 | | #region Statics |
| | 17864 | |
|
| | 17865 | | /// <summary>Converts a Speed measurement from units to another.</summary> |
| | 17866 | | /// <param name="value">The value to convert the units of.</param> |
| | 17867 | | /// <param name="fromLengthUnits1">The current units of the measurement.</param> |
| | 17868 | | /// <param name="fromTimeUnits2">The current units of the measurement.</param> |
| | 17869 | | /// <param name="toLengthUnits1">The desired units of the measurement.</param> |
| | 17870 | | /// <param name="toTimeUnits2">The desired units of the measurement.</param> |
| | 17871 | | /// <returns>The Speed measurement converted into the desired units.</returns> |
| | 17872 | | public static T Convert(T value |
| | 17873 | | , Length.Units fromLengthUnits1 |
| | 17874 | | , Time.Units fromTimeUnits2 |
| | 17875 | | , Length.Units toLengthUnits1 |
| | 17876 | | , Time.Units toTimeUnits2 |
| | 17877 | | ) |
| | 17878 | | { |
| | 17879 | | Speed<T> measurement = new Speed<T>(value |
| | 17880 | | , fromLengthUnits1 |
| | 17881 | | , fromTimeUnits2 |
| | 17882 | | ); |
| | 17883 | | return measurement[ |
| | 17884 | | toLengthUnits1 |
| | 17885 | | , toTimeUnits2 |
| | 17886 | | ]; |
| | 17887 | | } |
| | 17888 | |
|
| | 17889 | | /// <summary>Converts a Speed measurement from units to another.</summary> |
| | 17890 | | /// <param name="value">The value to convert the units of.</param> |
| | 17891 | | /// <param name="from">The current units of the measurement.</param> |
| | 17892 | | /// <param name="to">The desired units of the measurement.</param> |
| | 17893 | | /// <returns>The Speed measurement converted into the desired units.</returns> |
| | 17894 | | public static T Convert(T value, |
| | 17895 | | MeasurementUnitsSyntaxTypes.SpeedBaseUnits from, |
| | 17896 | | MeasurementUnitsSyntaxTypes.SpeedBaseUnits to) |
| | 17897 | | { |
| | 17898 | | return Convert(value |
| | 17899 | | , from._LengthUnits1 |
| | 17900 | | , from._TimeUnits2 |
| | 17901 | | , to._LengthUnits1 |
| | 17902 | | , to._TimeUnits2 |
| | 17903 | | ); |
| | 17904 | | } |
| | 17905 | |
|
| | 17906 | | /// <summary>Parses a Speed measurement string.</summary> |
| | 17907 | | /// <param name="string">The string to be parsed.</param> |
| | 17908 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 17909 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 17910 | | public static (bool Success, Speed<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value)> tryPars |
| | 17911 | |
|
| | 17912 | | #endregion |
| | 17913 | |
|
| | 17914 | | #region Constructors |
| | 17915 | |
|
| | 17916 | | /// <summary>Constructs an Speed with the measurement value and units.</summary> |
| | 17917 | | /// <param name="measurement">The measurement value of the Speed.</param> |
| | 17918 | | /// <param name="units">The units of the Speed.</param> |
| | 17919 | | public Speed(T measurement, MeasurementUnitsSyntaxTypes.SpeedBaseUnits units) : this(measurement |
| | 17920 | | , units._LengthUnits1 |
| | 17921 | | , units._TimeUnits2 |
| | 17922 | | ) { } |
| | 17923 | |
|
| | 17924 | |
|
| | 17925 | | /// <summary>Constructs an Speed with the measurement value and units.</summary> |
| | 17926 | | /// <param name="measurement">The measurement value of the Speed.</param> |
| | 17927 | | /// <param name="LengthUnits1">The units of the Speed.</param> |
| | 17928 | | /// <param name="TimeUnits2">The units of the Speed.</param> |
| | 17929 | | public Speed(T measurement |
| | 17930 | | , Length.Units LengthUnits1 |
| | 17931 | | , Time.Units TimeUnits2 |
| | 17932 | | ) |
| | 17933 | | { |
| | 17934 | | _measurement = measurement; |
| | 17935 | | _LengthUnits1 = LengthUnits1; |
| | 17936 | | _TimeUnits2 = TimeUnits2; |
| | 17937 | | } |
| | 17938 | |
|
| | 17939 | | #endregion |
| | 17940 | |
|
| | 17941 | | #region Properties |
| | 17942 | |
|
| | 17943 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 17944 | | public Length.Units LengthUnits1 |
| | 17945 | | { |
| | 17946 | | get { return _LengthUnits1; } |
| | 17947 | | set |
| | 17948 | | { |
| | 17949 | | if (value != _LengthUnits1) |
| | 17950 | | { |
| | 17951 | | _measurement = this[value, _TimeUnits2]; |
| | 17952 | | _LengthUnits1 = value; |
| | 17953 | | } |
| | 17954 | | } |
| | 17955 | | } |
| | 17956 | |
|
| | 17957 | | /// <summary>The #2 component of this measurements units.</summary> |
| | 17958 | | public Time.Units TimeUnits2 |
| | 17959 | | { |
| | 17960 | | get { return _TimeUnits2; } |
| | 17961 | | set |
| | 17962 | | { |
| | 17963 | | if (value != _TimeUnits2) |
| | 17964 | | { |
| | 17965 | | _measurement = this[_LengthUnits1, value]; |
| | 17966 | | _TimeUnits2 = value; |
| | 17967 | | } |
| | 17968 | | } |
| | 17969 | | } |
| | 17970 | |
|
| | 17971 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 17972 | | /// <param name="units">The units to get the measurement in.</param> |
| | 17973 | | /// <returns>The measurement value in the specified units.</returns> |
| | 17974 | | public T this[MeasurementUnitsSyntaxTypes.SpeedBaseUnits units] |
| | 17975 | | { |
| | 17976 | | get { return this[units._LengthUnits1, units._TimeUnits2]; } |
| | 17977 | | } |
| | 17978 | |
|
| | 17979 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 17980 | | /// <param name="LengthUnits1">The #1 component of this measurements units.</param> |
| | 17981 | | /// <param name="TimeUnits2">The #2 component of this measurements units.</param> |
| | 17982 | | /// <returns>The measurement value in the specified units.</returns> |
| | 17983 | | public T this[Length.Units LengthUnits1, Time.Units TimeUnits2] |
| | 17984 | | { |
| | 17985 | | get |
| | 17986 | | { |
| | 17987 | | T measurement = _measurement; |
| | 17988 | | if (LengthUnits1 != _LengthUnits1) |
| | 17989 | | { |
| | 17990 | | measurement = Length<T>.Table[(int)_LengthUnits1][(int)LengthUnits1](measurement); |
| | 17991 | | //if (LengthUnits1 < _LengthUnits1) |
| | 17992 | | //{ |
| | 17993 | | // measurement = Length<T>.Table[(int)_LengthUnits1][(int)LengthUnits1](measurement); |
| | 17994 | | //} |
| | 17995 | | //else |
| | 17996 | | //{ |
| | 17997 | | // measurement = Length<T>.Table[(int)LengthUnits1][(int)_LengthUnits1](measurement); |
| | 17998 | | //} |
| | 17999 | | } |
| | 18000 | | if (TimeUnits2 != _TimeUnits2) |
| | 18001 | | { |
| | 18002 | | measurement = Time<T>.Table[(int)TimeUnits2][(int)_TimeUnits2](measurement); |
| | 18003 | | //if (TimeUnits2 > _TimeUnits2) |
| | 18004 | | //{ |
| | 18005 | | // measurement = Time<T>.Table[(int)_TimeUnits2][(int)TimeUnits2](measurement); |
| | 18006 | | //} |
| | 18007 | | //else |
| | 18008 | | //{ |
| | 18009 | | // measurement = Time<T>.Table[(int)TimeUnits2][(int)_TimeUnits2](measurement); |
| | 18010 | | //} |
| | 18011 | | } |
| | 18012 | | return measurement; |
| | 18013 | | } |
| | 18014 | | } |
| | 18015 | |
|
| | 18016 | | #endregion |
| | 18017 | |
|
| | 18018 | | #region Casting Operators |
| | 18019 | |
|
| | 18020 | | /// <summary>Converts a ValueTuple to a Speed measurement.</summary> |
| | 18021 | | /// <param name="valueTuple">The ValueTuple to converted into a Speed measurement.</param> |
| | 18022 | | public static implicit operator Speed<T>((T, MeasurementUnitsSyntaxTypes.SpeedBaseUnits) valueTuple) |
| | 18023 | | { |
| | 18024 | | return new Speed<T>(valueTuple.Item1, valueTuple.Item2); |
| | 18025 | | } |
| | 18026 | |
|
| | 18027 | | #endregion |
| | 18028 | |
|
| | 18029 | | #region Mathematics |
| | 18030 | |
|
| | 18031 | | #region Bases |
| | 18032 | |
|
| | 18033 | | internal static Speed<T> MathBase(Speed<T> a, T b, Func<T, T, T> func) |
| | 18034 | | { |
| | 18035 | | return new Speed<T>(func(a._measurement, b) |
| | 18036 | | , a._LengthUnits1 |
| | 18037 | | , a._TimeUnits2 |
| | 18038 | | ); |
| | 18039 | | } |
| | 18040 | |
|
| | 18041 | | internal static Speed<T> MathBase(Speed<T> a, Speed<T> b, Func<T, T, T> func) |
| | 18042 | | { |
| | 18043 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 18044 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 18045 | | T A = a[LengthUnits1, TimeUnits2]; |
| | 18046 | | T B = b[LengthUnits1, TimeUnits2]; |
| | 18047 | | T C = func(A, B); |
| | 18048 | | return new Speed<T>(C, LengthUnits1, TimeUnits2); |
| | 18049 | | } |
| | 18050 | |
|
| | 18051 | | internal static bool LogicBase(Speed<T> a, Speed<T> b, Func<T, T, bool> func) |
| | 18052 | | { |
| | 18053 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 18054 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 18055 | | T A = a[LengthUnits1, TimeUnits2]; |
| | 18056 | | T B = b[LengthUnits1, TimeUnits2]; |
| | 18057 | | return func(A, B); |
| | 18058 | | } |
| | 18059 | |
|
| | 18060 | | #endregion |
| | 18061 | |
|
| | 18062 | | #region Add |
| | 18063 | |
|
| | 18064 | | /// <summary>Adds two Speed measurements.</summary> |
| | 18065 | | /// <param name="a">The first operand of the addition.</param> |
| | 18066 | | /// <param name="b">The second operand of the addition.</param> |
| | 18067 | | /// <returns>The result of the addition operation.</returns> |
| | 18068 | | public static Speed<T> Add(Speed<T> a, Speed<T> b) |
| | 18069 | | { |
| | 18070 | | return MathBase(a, b, Statics.Addition); |
| | 18071 | | } |
| | 18072 | |
|
| | 18073 | | /// <summary>Adds two Speed measurements.</summary> |
| | 18074 | | /// <param name="a">The first operand of the addition.</param> |
| | 18075 | | /// <param name="b">The second operand of the addition.</param> |
| | 18076 | | /// <returns>The result of the addition operation.</returns> |
| | 18077 | | public static Speed<T> operator +(Speed<T> a, Speed<T> b) |
| | 18078 | | { |
| | 18079 | | return Add(a, b); |
| | 18080 | | } |
| | 18081 | |
|
| | 18082 | | /// <summary>Adds two Speed measurements.</summary> |
| | 18083 | | /// <param name="b">The second operand of the addition.</param> |
| | 18084 | | /// <returns>The result of the addition operation.</returns> |
| | 18085 | | public Speed<T> Add(Speed<T> b) |
| | 18086 | | { |
| | 18087 | | return this + b; |
| | 18088 | | } |
| | 18089 | |
|
| | 18090 | | #endregion |
| | 18091 | |
|
| | 18092 | | #region Subtract |
| | 18093 | |
|
| | 18094 | | /// <summary>Subtracts two Speed measurements.</summary> |
| | 18095 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 18096 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 18097 | | /// <returns>The result of the subtraction.</returns> |
| | 18098 | | public static Speed<T> Subtract(Speed<T> a, Speed<T> b) |
| | 18099 | | { |
| | 18100 | | return MathBase(a, b, Statics.Subtraction); |
| | 18101 | | } |
| | 18102 | |
|
| | 18103 | | /// <summary>Subtracts two Speed measurements.</summary> |
| | 18104 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 18105 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 18106 | | /// <returns>The result of the subtraction.</returns> |
| | 18107 | | public static Speed<T> operator -(Speed<T> a, Speed<T> b) |
| | 18108 | | { |
| | 18109 | | return Subtract(a, b); |
| | 18110 | | } |
| | 18111 | |
|
| | 18112 | | /// <summary>Subtracts two Speed measurements.</summary> |
| | 18113 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 18114 | | /// <returns>The result of the subtraction.</returns> |
| | 18115 | | public Speed<T> Subtract(Speed<T> b) |
| | 18116 | | { |
| | 18117 | | return this - b; |
| | 18118 | | } |
| | 18119 | |
|
| | 18120 | | #endregion |
| | 18121 | |
|
| | 18122 | | #region Multiply |
| | 18123 | |
|
| | 18124 | | /// <summary>Multiplies an Speed by a scalar numeric value.</summary> |
| | 18125 | | /// <param name="a">The Speed measurement to multiply.</param> |
| | 18126 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 18127 | | /// <returns>The result of the multiplication.</returns> |
| | 18128 | | public static Speed<T> Multiply(Speed<T> a, T b) |
| | 18129 | | { |
| | 18130 | | return MathBase(a, b, Statics.Multiplication); |
| | 18131 | | } |
| | 18132 | |
|
| | 18133 | | /// <summary>Multiplies an Speed by a scalar numeric value.</summary> |
| | 18134 | | /// <param name="a">The Speed measurement to multiply.</param> |
| | 18135 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 18136 | | /// <returns>The result of the multiplication.</returns> |
| | 18137 | | public static Speed<T> Multiply(T b, Speed<T> a) |
| | 18138 | | { |
| | 18139 | | return Multiply(a, b); |
| | 18140 | | } |
| | 18141 | |
|
| | 18142 | | /// <summary>Multiplies an Speed by a scalar numeric value.</summary> |
| | 18143 | | /// <param name="a">The Speed measurement to multiply.</param> |
| | 18144 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 18145 | | /// <returns>The result of the multiplication.</returns> |
| | 18146 | | public static Speed<T> operator *(Speed<T> a, T b) |
| | 18147 | | { |
| | 18148 | | return Multiply(a, b); |
| | 18149 | | } |
| | 18150 | |
|
| | 18151 | | /// <summary>Multiplies an Speed by a scalar numeric value.</summary> |
| | 18152 | | /// <param name="a">The Speed measurement to multiply.</param> |
| | 18153 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 18154 | | /// <returns>The result of the multiplication.</returns> |
| | 18155 | | public static Speed<T> operator *(T b, Speed<T> a) |
| | 18156 | | { |
| | 18157 | | return Multiply(b, a); |
| | 18158 | | } |
| | 18159 | |
|
| | 18160 | | /// <summary>Multiplies an Speed by a scalar numeric value.</summary> |
| | 18161 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 18162 | | /// <returns>The result of the multiplication.</returns> |
| | 18163 | | public Speed<T> Add(T b) |
| | 18164 | | { |
| | 18165 | | return this * b; |
| | 18166 | | } |
| | 18167 | |
|
| | 18168 | | #region Speed<T> * Area<T> = VolumeRate<T> |
| | 18169 | |
|
| | 18170 | | /// <summary>Mulitplies Speed by Area resulting in VolumeRate.</summary> |
| | 18171 | | /// <param name="a">The Speed to be multiplied.</param> |
| | 18172 | | /// <param name="b">The Area to multiply by.</param> |
| | 18173 | | /// <returns>The VolumeRate result of the multiplication.</returns> |
| | 18174 | | public static VolumeRate<T> Multiply(Speed<T> a, Area<T> b) |
| | 18175 | | { |
| | 18176 | |
|
| | 18177 | | T A = a[a._LengthUnits1, a._TimeUnits2]; |
| | 18178 | | T B = b[b._LengthUnits1, b._LengthUnits2]; |
| | 18179 | | T C = Statics.Multiplication(A, B); |
| | 18180 | |
|
| | 18181 | | return new VolumeRate<T>(C |
| | 18182 | | , a._LengthUnits1 |
| | 18183 | | , b._LengthUnits1 |
| | 18184 | | , b._LengthUnits2 |
| | 18185 | | , a._TimeUnits2 |
| | 18186 | | ); |
| | 18187 | | } |
| | 18188 | |
|
| | 18189 | | /// <summary>Mulitplies Speed by Area resulting in VolumeRate.</summary> |
| | 18190 | | /// <param name="a">The Speed to be multiplied.</param> |
| | 18191 | | /// <param name="b">The Area to multiply by.</param> |
| | 18192 | | /// <returns>The VolumeRate result of the multiplication.</returns> |
| | 18193 | | public static VolumeRate<T> operator *(Speed<T> a, Area<T> b) |
| | 18194 | | { |
| | 18195 | | return Multiply(a, b); |
| | 18196 | | } |
| | 18197 | |
|
| | 18198 | | /// <summary>Mulitplies Speed by Area resulting in VolumeRate.</summary> |
| | 18199 | | /// <param name="b">The Area to multiply by.</param> |
| | 18200 | | /// <returns>The VolumeRate result of the multiplication.</returns> |
| | 18201 | | public VolumeRate<T> Multiply(Area<T> b) |
| | 18202 | | { |
| | 18203 | | return this * b; |
| | 18204 | | } |
| | 18205 | |
|
| | 18206 | | #endregion |
| | 18207 | |
|
| | 18208 | | #region Speed<T> * Force<T> = Power<T> |
| | 18209 | |
|
| | 18210 | | /// <summary>Mulitplies Speed by Force resulting in Power.</summary> |
| | 18211 | | /// <param name="a">The Speed to be multiplied.</param> |
| | 18212 | | /// <param name="b">The Force to multiply by.</param> |
| | 18213 | | /// <returns>The Power result of the multiplication.</returns> |
| | 18214 | | public static Power<T> Multiply(Speed<T> a, Force<T> b) |
| | 18215 | | { |
| | 18216 | |
|
| | 18217 | | T A = a[a._LengthUnits1, a._TimeUnits2]; |
| | 18218 | | T B = b[b._MassUnits1, b._LengthUnits2, b._TimeUnits3, b._TimeUnits4]; |
| | 18219 | | T C = Statics.Multiplication(A, B); |
| | 18220 | |
|
| | 18221 | | return new Power<T>(C |
| | 18222 | | , b._MassUnits1 |
| | 18223 | | , a._LengthUnits1 |
| | 18224 | | , b._LengthUnits2 |
| | 18225 | | , a._TimeUnits2 |
| | 18226 | | , b._TimeUnits3 |
| | 18227 | | , b._TimeUnits4 |
| | 18228 | | ); |
| | 18229 | | } |
| | 18230 | |
|
| | 18231 | | /// <summary>Mulitplies Speed by Force resulting in Power.</summary> |
| | 18232 | | /// <param name="a">The Speed to be multiplied.</param> |
| | 18233 | | /// <param name="b">The Force to multiply by.</param> |
| | 18234 | | /// <returns>The Power result of the multiplication.</returns> |
| | 18235 | | public static Power<T> operator *(Speed<T> a, Force<T> b) |
| | 18236 | | { |
| | 18237 | | return Multiply(a, b); |
| | 18238 | | } |
| | 18239 | |
|
| | 18240 | | /// <summary>Mulitplies Speed by Force resulting in Power.</summary> |
| | 18241 | | /// <param name="b">The Force to multiply by.</param> |
| | 18242 | | /// <returns>The Power result of the multiplication.</returns> |
| | 18243 | | public Power<T> Multiply(Force<T> b) |
| | 18244 | | { |
| | 18245 | | return this * b; |
| | 18246 | | } |
| | 18247 | |
|
| | 18248 | | #endregion |
| | 18249 | |
|
| | 18250 | | #region Speed<T> * LinearDensity<T> = MassRate<T> |
| | 18251 | |
|
| | 18252 | | /// <summary>Mulitplies Speed by LinearDensity resulting in MassRate.</summary> |
| | 18253 | | /// <param name="a">The Speed to be multiplied.</param> |
| | 18254 | | /// <param name="b">The LinearDensity to multiply by.</param> |
| | 18255 | | /// <returns>The MassRate result of the multiplication.</returns> |
| | 18256 | | public static MassRate<T> Multiply(Speed<T> a, LinearDensity<T> b) |
| | 18257 | | { |
| | 18258 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits2 ? a._LengthUnits1 : b._LengthUnits2; |
| | 18259 | |
|
| | 18260 | | T A = a[LengthUnits1, a._TimeUnits2]; |
| | 18261 | | T B = b[b._MassUnits1, LengthUnits1]; |
| | 18262 | | T C = Statics.Multiplication(A, B); |
| | 18263 | |
|
| | 18264 | | return new MassRate<T>(C |
| | 18265 | | , b._MassUnits1 |
| | 18266 | | , a._TimeUnits2 |
| | 18267 | | ); |
| | 18268 | | } |
| | 18269 | |
|
| | 18270 | | /// <summary>Mulitplies Speed by LinearDensity resulting in MassRate.</summary> |
| | 18271 | | /// <param name="a">The Speed to be multiplied.</param> |
| | 18272 | | /// <param name="b">The LinearDensity to multiply by.</param> |
| | 18273 | | /// <returns>The MassRate result of the multiplication.</returns> |
| | 18274 | | public static MassRate<T> operator *(Speed<T> a, LinearDensity<T> b) |
| | 18275 | | { |
| | 18276 | | return Multiply(a, b); |
| | 18277 | | } |
| | 18278 | |
|
| | 18279 | | /// <summary>Mulitplies Speed by LinearDensity resulting in MassRate.</summary> |
| | 18280 | | /// <param name="b">The LinearDensity to multiply by.</param> |
| | 18281 | | /// <returns>The MassRate result of the multiplication.</returns> |
| | 18282 | | public MassRate<T> Multiply(LinearDensity<T> b) |
| | 18283 | | { |
| | 18284 | | return this * b; |
| | 18285 | | } |
| | 18286 | |
|
| | 18287 | | #endregion |
| | 18288 | |
|
| | 18289 | | #region Speed<T> * LinearMassFlow<T> = Energy<T> |
| | 18290 | |
|
| | 18291 | | /// <summary>Mulitplies Speed by LinearMassFlow resulting in Energy.</summary> |
| | 18292 | | /// <param name="a">The Speed to be multiplied.</param> |
| | 18293 | | /// <param name="b">The LinearMassFlow to multiply by.</param> |
| | 18294 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 18295 | | public static Energy<T> Multiply(Speed<T> a, LinearMassFlow<T> b) |
| | 18296 | | { |
| | 18297 | |
|
| | 18298 | | T A = a[a._LengthUnits1, a._TimeUnits2]; |
| | 18299 | | T B = b[b._MassUnits1, b._LengthUnits2, b._TimeUnits3]; |
| | 18300 | | T C = Statics.Multiplication(A, B); |
| | 18301 | |
|
| | 18302 | | return new Energy<T>(C |
| | 18303 | | , b._MassUnits1 |
| | 18304 | | , a._LengthUnits1 |
| | 18305 | | , b._LengthUnits2 |
| | 18306 | | , a._TimeUnits2 |
| | 18307 | | , b._TimeUnits3 |
| | 18308 | | ); |
| | 18309 | | } |
| | 18310 | |
|
| | 18311 | | /// <summary>Mulitplies Speed by LinearMassFlow resulting in Energy.</summary> |
| | 18312 | | /// <param name="a">The Speed to be multiplied.</param> |
| | 18313 | | /// <param name="b">The LinearMassFlow to multiply by.</param> |
| | 18314 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 18315 | | public static Energy<T> operator *(Speed<T> a, LinearMassFlow<T> b) |
| | 18316 | | { |
| | 18317 | | return Multiply(a, b); |
| | 18318 | | } |
| | 18319 | |
|
| | 18320 | | /// <summary>Mulitplies Speed by LinearMassFlow resulting in Energy.</summary> |
| | 18321 | | /// <param name="b">The LinearMassFlow to multiply by.</param> |
| | 18322 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 18323 | | public Energy<T> Multiply(LinearMassFlow<T> b) |
| | 18324 | | { |
| | 18325 | | return this * b; |
| | 18326 | | } |
| | 18327 | |
|
| | 18328 | | #endregion |
| | 18329 | |
|
| | 18330 | | #region Speed<T> * Mass<T> = LinearMassFlow<T> |
| | 18331 | |
|
| | 18332 | | /// <summary>Mulitplies Speed by Mass resulting in LinearMassFlow.</summary> |
| | 18333 | | /// <param name="a">The Speed to be multiplied.</param> |
| | 18334 | | /// <param name="b">The Mass to multiply by.</param> |
| | 18335 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 18336 | | public static LinearMassFlow<T> Multiply(Speed<T> a, Mass<T> b) |
| | 18337 | | { |
| | 18338 | |
|
| | 18339 | | T A = a[a._LengthUnits1, a._TimeUnits2]; |
| | 18340 | | T B = b[b._MassUnits1]; |
| | 18341 | | T C = Statics.Multiplication(A, B); |
| | 18342 | |
|
| | 18343 | | return new LinearMassFlow<T>(C |
| | 18344 | | , b._MassUnits1 |
| | 18345 | | , a._LengthUnits1 |
| | 18346 | | , a._TimeUnits2 |
| | 18347 | | ); |
| | 18348 | | } |
| | 18349 | |
|
| | 18350 | | /// <summary>Mulitplies Speed by Mass resulting in LinearMassFlow.</summary> |
| | 18351 | | /// <param name="a">The Speed to be multiplied.</param> |
| | 18352 | | /// <param name="b">The Mass to multiply by.</param> |
| | 18353 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 18354 | | public static LinearMassFlow<T> operator *(Speed<T> a, Mass<T> b) |
| | 18355 | | { |
| | 18356 | | return Multiply(a, b); |
| | 18357 | | } |
| | 18358 | |
|
| | 18359 | | /// <summary>Mulitplies Speed by Mass resulting in LinearMassFlow.</summary> |
| | 18360 | | /// <param name="b">The Mass to multiply by.</param> |
| | 18361 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 18362 | | public LinearMassFlow<T> Multiply(Mass<T> b) |
| | 18363 | | { |
| | 18364 | | return this * b; |
| | 18365 | | } |
| | 18366 | |
|
| | 18367 | | #endregion |
| | 18368 | |
|
| | 18369 | | #region Speed<T> * MassRate<T> = Force<T> |
| | 18370 | |
|
| | 18371 | | /// <summary>Mulitplies Speed by MassRate resulting in Force.</summary> |
| | 18372 | | /// <param name="a">The Speed to be multiplied.</param> |
| | 18373 | | /// <param name="b">The MassRate to multiply by.</param> |
| | 18374 | | /// <returns>The Force result of the multiplication.</returns> |
| | 18375 | | public static Force<T> Multiply(Speed<T> a, MassRate<T> b) |
| | 18376 | | { |
| | 18377 | |
|
| | 18378 | | T A = a[a._LengthUnits1, a._TimeUnits2]; |
| | 18379 | | T B = b[b._MassUnits1, b._TimeUnits2]; |
| | 18380 | | T C = Statics.Multiplication(A, B); |
| | 18381 | |
|
| | 18382 | | return new Force<T>(C |
| | 18383 | | , b._MassUnits1 |
| | 18384 | | , a._LengthUnits1 |
| | 18385 | | , a._TimeUnits2 |
| | 18386 | | , b._TimeUnits2 |
| | 18387 | | ); |
| | 18388 | | } |
| | 18389 | |
|
| | 18390 | | /// <summary>Mulitplies Speed by MassRate resulting in Force.</summary> |
| | 18391 | | /// <param name="a">The Speed to be multiplied.</param> |
| | 18392 | | /// <param name="b">The MassRate to multiply by.</param> |
| | 18393 | | /// <returns>The Force result of the multiplication.</returns> |
| | 18394 | | public static Force<T> operator *(Speed<T> a, MassRate<T> b) |
| | 18395 | | { |
| | 18396 | | return Multiply(a, b); |
| | 18397 | | } |
| | 18398 | |
|
| | 18399 | | /// <summary>Mulitplies Speed by MassRate resulting in Force.</summary> |
| | 18400 | | /// <param name="b">The MassRate to multiply by.</param> |
| | 18401 | | /// <returns>The Force result of the multiplication.</returns> |
| | 18402 | | public Force<T> Multiply(MassRate<T> b) |
| | 18403 | | { |
| | 18404 | | return this * b; |
| | 18405 | | } |
| | 18406 | |
|
| | 18407 | | #endregion |
| | 18408 | |
|
| | 18409 | | #region Speed<T> * Time<T> = Length<T> |
| | 18410 | |
|
| | 18411 | | /// <summary>Mulitplies Speed by Time resulting in Length.</summary> |
| | 18412 | | /// <param name="a">The Speed to be multiplied.</param> |
| | 18413 | | /// <param name="b">The Time to multiply by.</param> |
| | 18414 | | /// <returns>The Length result of the multiplication.</returns> |
| | 18415 | | public static Length<T> Multiply(Speed<T> a, Time<T> b) |
| | 18416 | | { |
| | 18417 | | Time.Units TimeUnits1 = a._TimeUnits2 <= b._TimeUnits1 ? a._TimeUnits2 : b._TimeUnits1; |
| | 18418 | |
|
| | 18419 | | T A = a[a._LengthUnits1, TimeUnits1]; |
| | 18420 | | T B = b[TimeUnits1]; |
| | 18421 | | T C = Statics.Multiplication(A, B); |
| | 18422 | |
|
| | 18423 | | return new Length<T>(C |
| | 18424 | | , a._LengthUnits1 |
| | 18425 | | ); |
| | 18426 | | } |
| | 18427 | |
|
| | 18428 | | /// <summary>Mulitplies Speed by Time resulting in Length.</summary> |
| | 18429 | | /// <param name="a">The Speed to be multiplied.</param> |
| | 18430 | | /// <param name="b">The Time to multiply by.</param> |
| | 18431 | | /// <returns>The Length result of the multiplication.</returns> |
| | 18432 | | public static Length<T> operator *(Speed<T> a, Time<T> b) |
| | 18433 | | { |
| | 18434 | | return Multiply(a, b); |
| | 18435 | | } |
| | 18436 | |
|
| | 18437 | | /// <summary>Mulitplies Speed by Time resulting in Length.</summary> |
| | 18438 | | /// <param name="b">The Time to multiply by.</param> |
| | 18439 | | /// <returns>The Length result of the multiplication.</returns> |
| | 18440 | | public Length<T> Multiply(Time<T> b) |
| | 18441 | | { |
| | 18442 | | return this * b; |
| | 18443 | | } |
| | 18444 | |
|
| | 18445 | | #endregion |
| | 18446 | |
|
| | 18447 | | #endregion |
| | 18448 | |
|
| | 18449 | | #region Divide |
| | 18450 | |
|
| | 18451 | | /// <summary>Divides an Speed measurement by another Speed measurement resulting in a scalar numeric value.</summary |
| | 18452 | | /// <param name="a">The first operand of the division operation.</param> |
| | 18453 | | /// <param name="b">The second operand of the division operation.</param> |
| | 18454 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 18455 | | public static T Divide(Speed<T> a, Speed<T> b) |
| | 18456 | | { |
| | 18457 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 18458 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 18459 | | T A = a[LengthUnits1, TimeUnits2]; |
| | 18460 | | T B = b[LengthUnits1, TimeUnits2]; |
| | 18461 | | return Statics.Division(A, B); |
| | 18462 | | } |
| | 18463 | |
|
| | 18464 | | /// <summary>Divides this Speed measurement by a numaric scalar value.</summary> |
| | 18465 | | /// <param name="a">The Speed measurement to divide.</param> |
| | 18466 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 18467 | | /// <returns>The result of the division.</returns> |
| | 18468 | | public static Speed<T> Divide(Speed<T> a, T b) |
| | 18469 | | { |
| | 18470 | | return MathBase(a, b, Statics.Division); |
| | 18471 | | } |
| | 18472 | |
|
| | 18473 | | /// <summary>Divides this Speed measurement by a numaric scalar value.</summary> |
| | 18474 | | /// <param name="a">The Speed measurement to divide.</param> |
| | 18475 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 18476 | | /// <returns>The result of the division.</returns> |
| | 18477 | | public static Speed<T> operator /(Speed<T> a, T b) |
| | 18478 | | { |
| | 18479 | | return Divide(a, b); |
| | 18480 | | } |
| | 18481 | |
|
| | 18482 | | /// <summary>Divides this Speed measurement by a numaric scalar value.</summary> |
| | 18483 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 18484 | | /// <returns>The result of the division.</returns> |
| | 18485 | | public Speed<T> Divide(T b) |
| | 18486 | | { |
| | 18487 | | return this / b; |
| | 18488 | | } |
| | 18489 | |
|
| | 18490 | | /// <summary>Divides an Speed measurement by another Speed measurement resulting in a scalar numeric value.</summary |
| | 18491 | | /// <param name="a">The first operand of the division operation.</param> |
| | 18492 | | /// <param name="b">The second operand of the division operation.</param> |
| | 18493 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 18494 | | public static T operator /(Speed<T> a, Speed<T> b) |
| | 18495 | | { |
| | 18496 | | return Divide(a, b); |
| | 18497 | | } |
| | 18498 | |
|
| | 18499 | | /// <summary>Divides an Speed measurement by another Speed measurement resulting in a scalar numeric value.</summary |
| | 18500 | | /// <param name="b">The second operand of the division operation.</param> |
| | 18501 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 18502 | | public T Divide(Speed<T> b) |
| | 18503 | | { |
| | 18504 | | return this / b; |
| | 18505 | | } |
| | 18506 | |
|
| | 18507 | |
|
| | 18508 | | #region Speed<T> / Acceleration<T> = Time<T> |
| | 18509 | |
|
| | 18510 | | /// <summary>Divides Speed by Acceleration resulting in Time.</summary> |
| | 18511 | | /// <param name="a">The Speed to be divided.</param> |
| | 18512 | | /// <param name="b">The Acceleration to divide by.</param> |
| | 18513 | | /// <returns>The Time result of the division.</returns> |
| | 18514 | | public static Time<T> Divide(Speed<T> a, Acceleration<T> b) |
| | 18515 | | { |
| | 18516 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 18517 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 18518 | |
|
| | 18519 | | T A = a[LengthUnits1, TimeUnits2]; |
| | 18520 | | T B = b[LengthUnits1, TimeUnits2, b._TimeUnits3]; |
| | 18521 | | T C = Statics.Division(A, B); |
| | 18522 | |
|
| | 18523 | | return new Time<T>(C |
| | 18524 | | , b._TimeUnits3 |
| | 18525 | | ); |
| | 18526 | | } |
| | 18527 | |
|
| | 18528 | | /// <summary>Divides Speed by Acceleration resulting in Time.</summary> |
| | 18529 | | /// <param name="a">The Speed to be divided.</param> |
| | 18530 | | /// <param name="b">The Acceleration to divide by.</param> |
| | 18531 | | /// <returns>The Time result of the division.</returns> |
| | 18532 | | public static Time<T> operator /(Speed<T> a, Acceleration<T> b) |
| | 18533 | | { |
| | 18534 | | return Divide(a, b); |
| | 18535 | | } |
| | 18536 | |
|
| | 18537 | | /// <summary>Divides Speed by Acceleration resulting in Time.</summary> |
| | 18538 | | /// <param name="b">The Acceleration to divide by.</param> |
| | 18539 | | /// <returns>The Time result of the division.</returns> |
| | 18540 | | public Time<T> Divide(Acceleration<T> b) |
| | 18541 | | { |
| | 18542 | | return this / b; |
| | 18543 | | } |
| | 18544 | |
|
| | 18545 | | #endregion |
| | 18546 | |
|
| | 18547 | |
|
| | 18548 | | #region Speed<T> / Time<T> = Acceleration<T> |
| | 18549 | |
|
| | 18550 | | /// <summary>Divides Speed by Time resulting in Acceleration.</summary> |
| | 18551 | | /// <param name="a">The Speed to be divided.</param> |
| | 18552 | | /// <param name="b">The Time to divide by.</param> |
| | 18553 | | /// <returns>The Acceleration result of the division.</returns> |
| | 18554 | | public static Acceleration<T> Divide(Speed<T> a, Time<T> b) |
| | 18555 | | { |
| | 18556 | |
|
| | 18557 | | T A = a[a._LengthUnits1, a._TimeUnits2]; |
| | 18558 | | T B = b[b._TimeUnits1]; |
| | 18559 | | T C = Statics.Division(A, B); |
| | 18560 | |
|
| | 18561 | | return new Acceleration<T>(C |
| | 18562 | | , a._LengthUnits1 |
| | 18563 | | , a._TimeUnits2 |
| | 18564 | | , b._TimeUnits1 |
| | 18565 | | ); |
| | 18566 | | } |
| | 18567 | |
|
| | 18568 | | /// <summary>Divides Speed by Time resulting in Acceleration.</summary> |
| | 18569 | | /// <param name="a">The Speed to be divided.</param> |
| | 18570 | | /// <param name="b">The Time to divide by.</param> |
| | 18571 | | /// <returns>The Acceleration result of the division.</returns> |
| | 18572 | | public static Acceleration<T> operator /(Speed<T> a, Time<T> b) |
| | 18573 | | { |
| | 18574 | | return Divide(a, b); |
| | 18575 | | } |
| | 18576 | |
|
| | 18577 | | /// <summary>Divides Speed by Time resulting in Acceleration.</summary> |
| | 18578 | | /// <param name="b">The Time to divide by.</param> |
| | 18579 | | /// <returns>The Acceleration result of the division.</returns> |
| | 18580 | | public Acceleration<T> Divide(Time<T> b) |
| | 18581 | | { |
| | 18582 | | return this / b; |
| | 18583 | | } |
| | 18584 | |
|
| | 18585 | | #endregion |
| | 18586 | |
|
| | 18587 | | #endregion |
| | 18588 | |
|
| | 18589 | | #region LessThan |
| | 18590 | |
|
| | 18591 | | /// <summary>Determines if an Speed measurement is less than another Speed measurement.</summary> |
| | 18592 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 18593 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 18594 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 18595 | | public static bool LessThan(Speed<T> a, Speed<T> b) |
| | 18596 | | { |
| | 18597 | | return LogicBase(a, b, Statics.LessThan); |
| | 18598 | | } |
| | 18599 | |
|
| | 18600 | | /// <summary>Determines if an Speed measurement is less than another Speed measurement.</summary> |
| | 18601 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 18602 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 18603 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 18604 | | public static bool operator <(Speed<T> a, Speed<T> b) |
| | 18605 | | { |
| | 18606 | | return LessThan(a, b); |
| | 18607 | | } |
| | 18608 | |
|
| | 18609 | | /// <summary>Determines if an Speed measurement is less than another Speed measurement.</summary> |
| | 18610 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 18611 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 18612 | | public bool LessThan(Speed<T> b) |
| | 18613 | | { |
| | 18614 | | return this < b; |
| | 18615 | | } |
| | 18616 | |
|
| | 18617 | | #endregion |
| | 18618 | |
|
| | 18619 | | #region GreaterThan |
| | 18620 | |
|
| | 18621 | | /// <summary>Determines if an Speed measurement is greater than another Speed measurement.</summary> |
| | 18622 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 18623 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 18624 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 18625 | | public static bool GreaterThan(Speed<T> a, Speed<T> b) |
| | 18626 | | { |
| | 18627 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 18628 | | } |
| | 18629 | |
|
| | 18630 | | /// <summary>Determines if an Speed measurement is greater than another Speed measurement.</summary> |
| | 18631 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 18632 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 18633 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 18634 | | public static bool operator >(Speed<T> a, Speed<T> b) |
| | 18635 | | { |
| | 18636 | | return GreaterThan(a, b); |
| | 18637 | | } |
| | 18638 | |
|
| | 18639 | | /// <summary>Determines if an Speed measurement is greater than another Speed measurement.</summary> |
| | 18640 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 18641 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 18642 | | public bool GreaterThan(Speed<T> b) |
| | 18643 | | { |
| | 18644 | | return this > b; |
| | 18645 | | } |
| | 18646 | |
|
| | 18647 | | #endregion |
| | 18648 | |
|
| | 18649 | | #region LessThanOrEqual |
| | 18650 | |
|
| | 18651 | | /// <summary>Determines if an Speed measurement is less than or equal to another Speed measurement.</summary> |
| | 18652 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 18653 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 18654 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 18655 | | public static bool LessThanOrEqual(Speed<T> a, Speed<T> b) |
| | 18656 | | { |
| | 18657 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 18658 | | } |
| | 18659 | |
|
| | 18660 | | /// <summary>Determines if an Speed measurement is less than or equal to another Speed measurement.</summary> |
| | 18661 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 18662 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 18663 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 18664 | | public static bool operator <=(Speed<T> a, Speed<T> b) |
| | 18665 | | { |
| | 18666 | | return LessThanOrEqual(a, b); |
| | 18667 | | } |
| | 18668 | |
|
| | 18669 | | /// <summary>Determines if an Speed measurement is less than or equal to another Speed measurement.</summary> |
| | 18670 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 18671 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 18672 | | public bool LessThanOrEqual(Speed<T> b) |
| | 18673 | | { |
| | 18674 | | return this <= b; |
| | 18675 | | } |
| | 18676 | |
|
| | 18677 | | #endregion |
| | 18678 | |
|
| | 18679 | | #region GreaterThanOrEqual |
| | 18680 | |
|
| | 18681 | | /// <summary>Determines if an Speed measurement is greater than or equal to another Speed measurement.</summary> |
| | 18682 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 18683 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 18684 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 18685 | | public static bool GreaterThanOrEqual(Speed<T> a, Speed<T> b) |
| | 18686 | | { |
| | 18687 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 18688 | | } |
| | 18689 | |
|
| | 18690 | | /// <summary>Determines if an Speed measurement is greater than or equal to another Speed measurement.</summary> |
| | 18691 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 18692 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 18693 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 18694 | | public static bool operator >=(Speed<T> a, Speed<T> b) |
| | 18695 | | { |
| | 18696 | | return GreaterThanOrEqual(a, b); |
| | 18697 | | } |
| | 18698 | |
|
| | 18699 | | /// <summary>Determines if an Speed measurement is greater than or equal to another Speed measurement.</summary> |
| | 18700 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 18701 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 18702 | | public bool GreaterThanOrEqual(Speed<T> b) |
| | 18703 | | { |
| | 18704 | | return this >= b; |
| | 18705 | | } |
| | 18706 | |
|
| | 18707 | | #endregion |
| | 18708 | |
|
| | 18709 | | #region Equal |
| | 18710 | |
|
| | 18711 | | /// <summary>Determines if an Speed measurement is equal to another Speed measurement.</summary> |
| | 18712 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 18713 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 18714 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 18715 | | public static bool Equal(Speed<T> a, Speed<T> b) |
| | 18716 | | { |
| | 18717 | | return LogicBase(a, b, Statics.Equate); |
| | 18718 | | } |
| | 18719 | |
|
| | 18720 | | /// <summary>Determines if an Speed measurement is equal to another Speed measurement.</summary> |
| | 18721 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 18722 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 18723 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 18724 | | public static bool operator ==(Speed<T> a, Speed<T> b) |
| | 18725 | | { |
| | 18726 | | return Equal(a, b); |
| | 18727 | | } |
| | 18728 | |
|
| | 18729 | | /// <summary>Determines if an Speed measurement is equal to another Speed measurement.</summary> |
| | 18730 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 18731 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 18732 | | public bool Equal(Speed<T> b) |
| | 18733 | | { |
| | 18734 | | return this == b; |
| | 18735 | | } |
| | 18736 | |
|
| | 18737 | | #endregion |
| | 18738 | |
|
| | 18739 | | #region NotEqual |
| | 18740 | |
|
| | 18741 | | /// <summary>Determines if an Speed measurement is not equal to another Speed measurement.</summary> |
| | 18742 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 18743 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 18744 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 18745 | | public static bool NotEqual(Speed<T> a, Speed<T> b) |
| | 18746 | | { |
| | 18747 | | return LogicBase(a, b, Statics.Inequate); |
| | 18748 | | } |
| | 18749 | |
|
| | 18750 | | /// <summary>Determines if an Speed measurement is not equal to another Speed measurement.</summary> |
| | 18751 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 18752 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 18753 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 18754 | | public static bool operator !=(Speed<T> a, Speed<T> b) |
| | 18755 | | { |
| | 18756 | | return NotEqual(a, b); |
| | 18757 | | } |
| | 18758 | |
|
| | 18759 | | /// <summary>Determines if an Speed measurement is not equal to another Speed measurement.</summary> |
| | 18760 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 18761 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 18762 | | public bool NotEqual(Speed<T> b) |
| | 18763 | | { |
| | 18764 | | return this != b; |
| | 18765 | | } |
| | 18766 | |
|
| | 18767 | | #endregion |
| | 18768 | |
|
| | 18769 | | #endregion |
| | 18770 | |
|
| | 18771 | | #region Overrides |
| | 18772 | |
|
| | 18773 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 18774 | | /// <param name="obj">The object to check for equality with.</param> |
| | 18775 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 18776 | | public override bool Equals(object obj) |
| | 18777 | | { |
| | 18778 | | if (obj is Speed<T>) |
| | 18779 | | { |
| | 18780 | | return this == (Speed<T>)obj; |
| | 18781 | | } |
| | 18782 | | return false; |
| | 18783 | | } |
| | 18784 | |
|
| | 18785 | | /// <summary>Converts the Speed measurement to a string represenation.</summary> |
| | 18786 | | /// <returns>The string representation of the measurement.</returns> |
| | 18787 | | public override string ToString() |
| | 18788 | | { |
| | 18789 | | return _measurement + " " + |
| | 18790 | | _LengthUnits1 |
| | 18791 | | + "/" + |
| | 18792 | | _TimeUnits2 |
| | 18793 | | ; |
| | 18794 | | } |
| | 18795 | |
|
| | 18796 | | /// <summary>Base hashing function for Speed measurements.</summary> |
| | 18797 | | /// <returns>Computed hash code for this instance.</returns> |
| | 18798 | | public override int GetHashCode() => Hash(_measurement); |
| | 18799 | |
|
| | 18800 | | #endregion |
| | 18801 | | } |
| | 18802 | |
|
| | 18803 | | #endregion |
| | 18804 | |
|
| | 18805 | | #region Tempurature |
| | 18806 | |
|
| | 18807 | | internal static partial class ParsingFunctions |
| | 18808 | | { |
| | 18809 | | [Measurement.Parseable("Tempurature")] |
| | 18810 | | public static object Tempurature<T>(T value, object[] units) |
| | 18811 | | { |
| | 18812 | | if (units.Length != 1) |
| | 18813 | | { |
| | 18814 | | throw new Exception("Bug in Towel. Invalid parameters to Tempurature Factory."); |
| | 18815 | | } |
| | 18816 | | if (!(units[0] is Tempurature.Units)) |
| | 18817 | | { |
| | 18818 | | throw new Exception("Bug in Towel. Invalid parameters to Tempurature Factory."); |
| | 18819 | | } |
| | 18820 | | return new Tempurature<T>(value |
| | 18821 | | , (Tempurature.Units)units[0] |
| | 18822 | | ); |
| | 18823 | | } |
| | 18824 | | } |
| | 18825 | |
|
| | 18826 | | /// <summary>Tempurature measurement with a value and the units.</summary> |
| | 18827 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 18828 | | public struct Tempurature<T> |
| | 18829 | | { |
| | 18830 | | internal static Func<T, T>[][] Table = UnitConversionTable.Build<Tempurature.Units, T>(); |
| | 18831 | | internal T _measurement; |
| | 18832 | | internal Tempurature.Units _TempuratureUnits1; |
| | 18833 | |
|
| | 18834 | | #region Statics |
| | 18835 | |
|
| | 18836 | | /// <summary>Converts a Tempurature measurement from units to another.</summary> |
| | 18837 | | /// <param name="value">The value to convert the units of.</param> |
| | 18838 | | /// <param name="fromTempuratureUnits1">The current units of the measurement.</param> |
| | 18839 | | /// <param name="toTempuratureUnits1">The desired units of the measurement.</param> |
| | 18840 | | /// <returns>The Tempurature measurement converted into the desired units.</returns> |
| | 18841 | | public static T Convert(T value |
| | 18842 | | , Tempurature.Units fromTempuratureUnits1 |
| | 18843 | | , Tempurature.Units toTempuratureUnits1 |
| | 18844 | | ) |
| | 18845 | | { |
| | 18846 | | Tempurature<T> measurement = new Tempurature<T>(value |
| | 18847 | | , fromTempuratureUnits1 |
| | 18848 | | ); |
| | 18849 | | return measurement[ |
| | 18850 | | toTempuratureUnits1 |
| | 18851 | | ]; |
| | 18852 | | } |
| | 18853 | |
|
| | 18854 | | /// <summary>Converts a Tempurature measurement from units to another.</summary> |
| | 18855 | | /// <param name="value">The value to convert the units of.</param> |
| | 18856 | | /// <param name="from">The current units of the measurement.</param> |
| | 18857 | | /// <param name="to">The desired units of the measurement.</param> |
| | 18858 | | /// <returns>The Tempurature measurement converted into the desired units.</returns> |
| | 18859 | | public static T Convert(T value, |
| | 18860 | | MeasurementUnitsSyntaxTypes.TempuratureUnits from, |
| | 18861 | | MeasurementUnitsSyntaxTypes.TempuratureUnits to) |
| | 18862 | | { |
| | 18863 | | return Convert(value |
| | 18864 | | , from._TempuratureUnits1 |
| | 18865 | | , to._TempuratureUnits1 |
| | 18866 | | ); |
| | 18867 | | } |
| | 18868 | |
|
| | 18869 | | /// <summary>Parses a Tempurature measurement string.</summary> |
| | 18870 | | /// <param name="string">The string to be parsed.</param> |
| | 18871 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 18872 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 18873 | | public static (bool Success, Tempurature<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value)> t |
| | 18874 | |
|
| | 18875 | | #endregion |
| | 18876 | |
|
| | 18877 | | #region Constructors |
| | 18878 | |
|
| | 18879 | | /// <summary>Constructs an Tempurature with the measurement value and units.</summary> |
| | 18880 | | /// <param name="measurement">The measurement value of the Tempurature.</param> |
| | 18881 | | /// <param name="units">The units of the Tempurature.</param> |
| | 18882 | | public Tempurature(T measurement, MeasurementUnitsSyntaxTypes.TempuratureUnits units) : this(measurement |
| | 18883 | | , units._TempuratureUnits1 |
| | 18884 | | ) { } |
| | 18885 | |
|
| | 18886 | |
|
| | 18887 | | /// <summary>Constructs an Tempurature with the measurement value and units.</summary> |
| | 18888 | | /// <param name="measurement">The measurement value of the Tempurature.</param> |
| | 18889 | | /// <param name="TempuratureUnits1">The units of the Tempurature.</param> |
| | 18890 | | public Tempurature(T measurement |
| | 18891 | | , Tempurature.Units TempuratureUnits1 |
| | 18892 | | ) |
| | 18893 | | { |
| | 18894 | | _measurement = measurement; |
| | 18895 | | _TempuratureUnits1 = TempuratureUnits1; |
| | 18896 | | } |
| | 18897 | |
|
| | 18898 | | #endregion |
| | 18899 | |
|
| | 18900 | | #region Properties |
| | 18901 | |
|
| | 18902 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 18903 | | public Tempurature.Units TempuratureUnits1 |
| | 18904 | | { |
| | 18905 | | get { return _TempuratureUnits1; } |
| | 18906 | | set |
| | 18907 | | { |
| | 18908 | | if (value != _TempuratureUnits1) |
| | 18909 | | { |
| | 18910 | | _measurement = this[value]; |
| | 18911 | | _TempuratureUnits1 = value; |
| | 18912 | | } |
| | 18913 | | } |
| | 18914 | | } |
| | 18915 | |
|
| | 18916 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 18917 | | /// <param name="units">The units to get the measurement in.</param> |
| | 18918 | | /// <returns>The measurement value in the specified units.</returns> |
| | 18919 | | public T this[MeasurementUnitsSyntaxTypes.TempuratureUnits units] |
| | 18920 | | { |
| | 18921 | | get { return this[units._TempuratureUnits1]; } |
| | 18922 | | } |
| | 18923 | |
|
| | 18924 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 18925 | | /// <param name="TempuratureUnits1">The #1 component of this measurements units.</param> |
| | 18926 | | /// <returns>The measurement value in the specified units.</returns> |
| | 18927 | | public T this[Tempurature.Units TempuratureUnits1] |
| | 18928 | | { |
| | 18929 | | get |
| | 18930 | | { |
| | 18931 | | T measurement = _measurement; |
| | 18932 | | if (TempuratureUnits1 != _TempuratureUnits1) |
| | 18933 | | { |
| | 18934 | | measurement = Tempurature<T>.Table[(int)_TempuratureUnits1][(int)TempuratureUnits1](measurement); |
| | 18935 | | //if (TempuratureUnits1 < _TempuratureUnits1) |
| | 18936 | | //{ |
| | 18937 | | // measurement = Tempurature<T>.Table[(int)_TempuratureUnits1][(int)TempuratureUnits1](measurement); |
| | 18938 | | //} |
| | 18939 | | //else |
| | 18940 | | //{ |
| | 18941 | | // measurement = Tempurature<T>.Table[(int)TempuratureUnits1][(int)_TempuratureUnits1](measurement); |
| | 18942 | | //} |
| | 18943 | | } |
| | 18944 | | return measurement; |
| | 18945 | | } |
| | 18946 | | } |
| | 18947 | |
|
| | 18948 | | #endregion |
| | 18949 | |
|
| | 18950 | | #region Casting Operators |
| | 18951 | |
|
| | 18952 | | /// <summary>Converts a ValueTuple to a Tempurature measurement.</summary> |
| | 18953 | | /// <param name="valueTuple">The ValueTuple to converted into a Tempurature measurement.</param> |
| | 18954 | | public static implicit operator Tempurature<T>((T, MeasurementUnitsSyntaxTypes.TempuratureUnits) valueTuple) |
| | 18955 | | { |
| | 18956 | | return new Tempurature<T>(valueTuple.Item1, valueTuple.Item2); |
| | 18957 | | } |
| | 18958 | |
|
| | 18959 | | #endregion |
| | 18960 | |
|
| | 18961 | | #region Mathematics |
| | 18962 | |
|
| | 18963 | | #region Bases |
| | 18964 | |
|
| | 18965 | | internal static Tempurature<T> MathBase(Tempurature<T> a, T b, Func<T, T, T> func) |
| | 18966 | | { |
| | 18967 | | return new Tempurature<T>(func(a._measurement, b) |
| | 18968 | | , a._TempuratureUnits1 |
| | 18969 | | ); |
| | 18970 | | } |
| | 18971 | |
|
| | 18972 | | internal static Tempurature<T> MathBase(Tempurature<T> a, Tempurature<T> b, Func<T, T, T> func) |
| | 18973 | | { |
| | 18974 | | Tempurature.Units TempuratureUnits1 = a._TempuratureUnits1 <= b._TempuratureUnits1 ? a._TempuratureUnits1 : b._Tem |
| | 18975 | | T A = a[TempuratureUnits1]; |
| | 18976 | | T B = b[TempuratureUnits1]; |
| | 18977 | | T C = func(A, B); |
| | 18978 | | return new Tempurature<T>(C, TempuratureUnits1); |
| | 18979 | | } |
| | 18980 | |
|
| | 18981 | | internal static bool LogicBase(Tempurature<T> a, Tempurature<T> b, Func<T, T, bool> func) |
| | 18982 | | { |
| | 18983 | | Tempurature.Units TempuratureUnits1 = a._TempuratureUnits1 <= b._TempuratureUnits1 ? a._TempuratureUnits1 : b._Tem |
| | 18984 | | T A = a[TempuratureUnits1]; |
| | 18985 | | T B = b[TempuratureUnits1]; |
| | 18986 | | return func(A, B); |
| | 18987 | | } |
| | 18988 | |
|
| | 18989 | | #endregion |
| | 18990 | |
|
| | 18991 | | #region Add |
| | 18992 | |
|
| | 18993 | | /// <summary>Adds two Tempurature measurements.</summary> |
| | 18994 | | /// <param name="a">The first operand of the addition.</param> |
| | 18995 | | /// <param name="b">The second operand of the addition.</param> |
| | 18996 | | /// <returns>The result of the addition operation.</returns> |
| | 18997 | | public static Tempurature<T> Add(Tempurature<T> a, Tempurature<T> b) |
| | 18998 | | { |
| | 18999 | | return MathBase(a, b, Statics.Addition); |
| | 19000 | | } |
| | 19001 | |
|
| | 19002 | | /// <summary>Adds two Tempurature measurements.</summary> |
| | 19003 | | /// <param name="a">The first operand of the addition.</param> |
| | 19004 | | /// <param name="b">The second operand of the addition.</param> |
| | 19005 | | /// <returns>The result of the addition operation.</returns> |
| | 19006 | | public static Tempurature<T> operator +(Tempurature<T> a, Tempurature<T> b) |
| | 19007 | | { |
| | 19008 | | return Add(a, b); |
| | 19009 | | } |
| | 19010 | |
|
| | 19011 | | /// <summary>Adds two Tempurature measurements.</summary> |
| | 19012 | | /// <param name="b">The second operand of the addition.</param> |
| | 19013 | | /// <returns>The result of the addition operation.</returns> |
| | 19014 | | public Tempurature<T> Add(Tempurature<T> b) |
| | 19015 | | { |
| | 19016 | | return this + b; |
| | 19017 | | } |
| | 19018 | |
|
| | 19019 | | #endregion |
| | 19020 | |
|
| | 19021 | | #region Subtract |
| | 19022 | |
|
| | 19023 | | /// <summary>Subtracts two Tempurature measurements.</summary> |
| | 19024 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 19025 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 19026 | | /// <returns>The result of the subtraction.</returns> |
| | 19027 | | public static Tempurature<T> Subtract(Tempurature<T> a, Tempurature<T> b) |
| | 19028 | | { |
| | 19029 | | return MathBase(a, b, Statics.Subtraction); |
| | 19030 | | } |
| | 19031 | |
|
| | 19032 | | /// <summary>Subtracts two Tempurature measurements.</summary> |
| | 19033 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 19034 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 19035 | | /// <returns>The result of the subtraction.</returns> |
| | 19036 | | public static Tempurature<T> operator -(Tempurature<T> a, Tempurature<T> b) |
| | 19037 | | { |
| | 19038 | | return Subtract(a, b); |
| | 19039 | | } |
| | 19040 | |
|
| | 19041 | | /// <summary>Subtracts two Tempurature measurements.</summary> |
| | 19042 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 19043 | | /// <returns>The result of the subtraction.</returns> |
| | 19044 | | public Tempurature<T> Subtract(Tempurature<T> b) |
| | 19045 | | { |
| | 19046 | | return this - b; |
| | 19047 | | } |
| | 19048 | |
|
| | 19049 | | #endregion |
| | 19050 | |
|
| | 19051 | | #region Multiply |
| | 19052 | |
|
| | 19053 | | /// <summary>Multiplies an Tempurature by a scalar numeric value.</summary> |
| | 19054 | | /// <param name="a">The Tempurature measurement to multiply.</param> |
| | 19055 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 19056 | | /// <returns>The result of the multiplication.</returns> |
| | 19057 | | public static Tempurature<T> Multiply(Tempurature<T> a, T b) |
| | 19058 | | { |
| | 19059 | | return MathBase(a, b, Statics.Multiplication); |
| | 19060 | | } |
| | 19061 | |
|
| | 19062 | | /// <summary>Multiplies an Tempurature by a scalar numeric value.</summary> |
| | 19063 | | /// <param name="a">The Tempurature measurement to multiply.</param> |
| | 19064 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 19065 | | /// <returns>The result of the multiplication.</returns> |
| | 19066 | | public static Tempurature<T> Multiply(T b, Tempurature<T> a) |
| | 19067 | | { |
| | 19068 | | return Multiply(a, b); |
| | 19069 | | } |
| | 19070 | |
|
| | 19071 | | /// <summary>Multiplies an Tempurature by a scalar numeric value.</summary> |
| | 19072 | | /// <param name="a">The Tempurature measurement to multiply.</param> |
| | 19073 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 19074 | | /// <returns>The result of the multiplication.</returns> |
| | 19075 | | public static Tempurature<T> operator *(Tempurature<T> a, T b) |
| | 19076 | | { |
| | 19077 | | return Multiply(a, b); |
| | 19078 | | } |
| | 19079 | |
|
| | 19080 | | /// <summary>Multiplies an Tempurature by a scalar numeric value.</summary> |
| | 19081 | | /// <param name="a">The Tempurature measurement to multiply.</param> |
| | 19082 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 19083 | | /// <returns>The result of the multiplication.</returns> |
| | 19084 | | public static Tempurature<T> operator *(T b, Tempurature<T> a) |
| | 19085 | | { |
| | 19086 | | return Multiply(b, a); |
| | 19087 | | } |
| | 19088 | |
|
| | 19089 | | /// <summary>Multiplies an Tempurature by a scalar numeric value.</summary> |
| | 19090 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 19091 | | /// <returns>The result of the multiplication.</returns> |
| | 19092 | | public Tempurature<T> Add(T b) |
| | 19093 | | { |
| | 19094 | | return this * b; |
| | 19095 | | } |
| | 19096 | |
|
| | 19097 | | #endregion |
| | 19098 | |
|
| | 19099 | | #region Divide |
| | 19100 | |
|
| | 19101 | | /// <summary>Divides an Tempurature measurement by another Tempurature measurement resulting in a scalar numeric val |
| | 19102 | | /// <param name="a">The first operand of the division operation.</param> |
| | 19103 | | /// <param name="b">The second operand of the division operation.</param> |
| | 19104 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 19105 | | public static T Divide(Tempurature<T> a, Tempurature<T> b) |
| | 19106 | | { |
| | 19107 | | Tempurature.Units TempuratureUnits1 = a._TempuratureUnits1 <= b._TempuratureUnits1 ? a._TempuratureUnits1 : b._Tem |
| | 19108 | | T A = a[TempuratureUnits1]; |
| | 19109 | | T B = b[TempuratureUnits1]; |
| | 19110 | | return Statics.Division(A, B); |
| | 19111 | | } |
| | 19112 | |
|
| | 19113 | | /// <summary>Divides this Tempurature measurement by a numaric scalar value.</summary> |
| | 19114 | | /// <param name="a">The Tempurature measurement to divide.</param> |
| | 19115 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 19116 | | /// <returns>The result of the division.</returns> |
| | 19117 | | public static Tempurature<T> Divide(Tempurature<T> a, T b) |
| | 19118 | | { |
| | 19119 | | return MathBase(a, b, Statics.Division); |
| | 19120 | | } |
| | 19121 | |
|
| | 19122 | | /// <summary>Divides this Tempurature measurement by a numaric scalar value.</summary> |
| | 19123 | | /// <param name="a">The Tempurature measurement to divide.</param> |
| | 19124 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 19125 | | /// <returns>The result of the division.</returns> |
| | 19126 | | public static Tempurature<T> operator /(Tempurature<T> a, T b) |
| | 19127 | | { |
| | 19128 | | return Divide(a, b); |
| | 19129 | | } |
| | 19130 | |
|
| | 19131 | | /// <summary>Divides this Tempurature measurement by a numaric scalar value.</summary> |
| | 19132 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 19133 | | /// <returns>The result of the division.</returns> |
| | 19134 | | public Tempurature<T> Divide(T b) |
| | 19135 | | { |
| | 19136 | | return this / b; |
| | 19137 | | } |
| | 19138 | |
|
| | 19139 | | /// <summary>Divides an Tempurature measurement by another Tempurature measurement resulting in a scalar numeric val |
| | 19140 | | /// <param name="a">The first operand of the division operation.</param> |
| | 19141 | | /// <param name="b">The second operand of the division operation.</param> |
| | 19142 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 19143 | | public static T operator /(Tempurature<T> a, Tempurature<T> b) |
| | 19144 | | { |
| | 19145 | | return Divide(a, b); |
| | 19146 | | } |
| | 19147 | |
|
| | 19148 | | /// <summary>Divides an Tempurature measurement by another Tempurature measurement resulting in a scalar numeric val |
| | 19149 | | /// <param name="b">The second operand of the division operation.</param> |
| | 19150 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 19151 | | public T Divide(Tempurature<T> b) |
| | 19152 | | { |
| | 19153 | | return this / b; |
| | 19154 | | } |
| | 19155 | |
|
| | 19156 | | #endregion |
| | 19157 | |
|
| | 19158 | | #region LessThan |
| | 19159 | |
|
| | 19160 | | /// <summary>Determines if an Tempurature measurement is less than another Tempurature measurement.</summary> |
| | 19161 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 19162 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 19163 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 19164 | | public static bool LessThan(Tempurature<T> a, Tempurature<T> b) |
| | 19165 | | { |
| | 19166 | | return LogicBase(a, b, Statics.LessThan); |
| | 19167 | | } |
| | 19168 | |
|
| | 19169 | | /// <summary>Determines if an Tempurature measurement is less than another Tempurature measurement.</summary> |
| | 19170 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 19171 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 19172 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 19173 | | public static bool operator <(Tempurature<T> a, Tempurature<T> b) |
| | 19174 | | { |
| | 19175 | | return LessThan(a, b); |
| | 19176 | | } |
| | 19177 | |
|
| | 19178 | | /// <summary>Determines if an Tempurature measurement is less than another Tempurature measurement.</summary> |
| | 19179 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 19180 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 19181 | | public bool LessThan(Tempurature<T> b) |
| | 19182 | | { |
| | 19183 | | return this < b; |
| | 19184 | | } |
| | 19185 | |
|
| | 19186 | | #endregion |
| | 19187 | |
|
| | 19188 | | #region GreaterThan |
| | 19189 | |
|
| | 19190 | | /// <summary>Determines if an Tempurature measurement is greater than another Tempurature measurement.</summary> |
| | 19191 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 19192 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 19193 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 19194 | | public static bool GreaterThan(Tempurature<T> a, Tempurature<T> b) |
| | 19195 | | { |
| | 19196 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 19197 | | } |
| | 19198 | |
|
| | 19199 | | /// <summary>Determines if an Tempurature measurement is greater than another Tempurature measurement.</summary> |
| | 19200 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 19201 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 19202 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 19203 | | public static bool operator >(Tempurature<T> a, Tempurature<T> b) |
| | 19204 | | { |
| | 19205 | | return GreaterThan(a, b); |
| | 19206 | | } |
| | 19207 | |
|
| | 19208 | | /// <summary>Determines if an Tempurature measurement is greater than another Tempurature measurement.</summary> |
| | 19209 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 19210 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 19211 | | public bool GreaterThan(Tempurature<T> b) |
| | 19212 | | { |
| | 19213 | | return this > b; |
| | 19214 | | } |
| | 19215 | |
|
| | 19216 | | #endregion |
| | 19217 | |
|
| | 19218 | | #region LessThanOrEqual |
| | 19219 | |
|
| | 19220 | | /// <summary>Determines if an Tempurature measurement is less than or equal to another Tempurature measurement.</sum |
| | 19221 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 19222 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 19223 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 19224 | | public static bool LessThanOrEqual(Tempurature<T> a, Tempurature<T> b) |
| | 19225 | | { |
| | 19226 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 19227 | | } |
| | 19228 | |
|
| | 19229 | | /// <summary>Determines if an Tempurature measurement is less than or equal to another Tempurature measurement.</sum |
| | 19230 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 19231 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 19232 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 19233 | | public static bool operator <=(Tempurature<T> a, Tempurature<T> b) |
| | 19234 | | { |
| | 19235 | | return LessThanOrEqual(a, b); |
| | 19236 | | } |
| | 19237 | |
|
| | 19238 | | /// <summary>Determines if an Tempurature measurement is less than or equal to another Tempurature measurement.</sum |
| | 19239 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 19240 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 19241 | | public bool LessThanOrEqual(Tempurature<T> b) |
| | 19242 | | { |
| | 19243 | | return this <= b; |
| | 19244 | | } |
| | 19245 | |
|
| | 19246 | | #endregion |
| | 19247 | |
|
| | 19248 | | #region GreaterThanOrEqual |
| | 19249 | |
|
| | 19250 | | /// <summary>Determines if an Tempurature measurement is greater than or equal to another Tempurature measurement.</ |
| | 19251 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 19252 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 19253 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 19254 | | public static bool GreaterThanOrEqual(Tempurature<T> a, Tempurature<T> b) |
| | 19255 | | { |
| | 19256 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 19257 | | } |
| | 19258 | |
|
| | 19259 | | /// <summary>Determines if an Tempurature measurement is greater than or equal to another Tempurature measurement.</ |
| | 19260 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 19261 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 19262 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 19263 | | public static bool operator >=(Tempurature<T> a, Tempurature<T> b) |
| | 19264 | | { |
| | 19265 | | return GreaterThanOrEqual(a, b); |
| | 19266 | | } |
| | 19267 | |
|
| | 19268 | | /// <summary>Determines if an Tempurature measurement is greater than or equal to another Tempurature measurement.</ |
| | 19269 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 19270 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 19271 | | public bool GreaterThanOrEqual(Tempurature<T> b) |
| | 19272 | | { |
| | 19273 | | return this >= b; |
| | 19274 | | } |
| | 19275 | |
|
| | 19276 | | #endregion |
| | 19277 | |
|
| | 19278 | | #region Equal |
| | 19279 | |
|
| | 19280 | | /// <summary>Determines if an Tempurature measurement is equal to another Tempurature measurement.</summary> |
| | 19281 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 19282 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 19283 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 19284 | | public static bool Equal(Tempurature<T> a, Tempurature<T> b) |
| | 19285 | | { |
| | 19286 | | return LogicBase(a, b, Statics.Equate); |
| | 19287 | | } |
| | 19288 | |
|
| | 19289 | | /// <summary>Determines if an Tempurature measurement is equal to another Tempurature measurement.</summary> |
| | 19290 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 19291 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 19292 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 19293 | | public static bool operator ==(Tempurature<T> a, Tempurature<T> b) |
| | 19294 | | { |
| | 19295 | | return Equal(a, b); |
| | 19296 | | } |
| | 19297 | |
|
| | 19298 | | /// <summary>Determines if an Tempurature measurement is equal to another Tempurature measurement.</summary> |
| | 19299 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 19300 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 19301 | | public bool Equal(Tempurature<T> b) |
| | 19302 | | { |
| | 19303 | | return this == b; |
| | 19304 | | } |
| | 19305 | |
|
| | 19306 | | #endregion |
| | 19307 | |
|
| | 19308 | | #region NotEqual |
| | 19309 | |
|
| | 19310 | | /// <summary>Determines if an Tempurature measurement is not equal to another Tempurature measurement.</summary> |
| | 19311 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 19312 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 19313 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 19314 | | public static bool NotEqual(Tempurature<T> a, Tempurature<T> b) |
| | 19315 | | { |
| | 19316 | | return LogicBase(a, b, Statics.Inequate); |
| | 19317 | | } |
| | 19318 | |
|
| | 19319 | | /// <summary>Determines if an Tempurature measurement is not equal to another Tempurature measurement.</summary> |
| | 19320 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 19321 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 19322 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 19323 | | public static bool operator !=(Tempurature<T> a, Tempurature<T> b) |
| | 19324 | | { |
| | 19325 | | return NotEqual(a, b); |
| | 19326 | | } |
| | 19327 | |
|
| | 19328 | | /// <summary>Determines if an Tempurature measurement is not equal to another Tempurature measurement.</summary> |
| | 19329 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 19330 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 19331 | | public bool NotEqual(Tempurature<T> b) |
| | 19332 | | { |
| | 19333 | | return this != b; |
| | 19334 | | } |
| | 19335 | |
|
| | 19336 | | #endregion |
| | 19337 | |
|
| | 19338 | | #endregion |
| | 19339 | |
|
| | 19340 | | #region Overrides |
| | 19341 | |
|
| | 19342 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 19343 | | /// <param name="obj">The object to check for equality with.</param> |
| | 19344 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 19345 | | public override bool Equals(object obj) |
| | 19346 | | { |
| | 19347 | | if (obj is Tempurature<T>) |
| | 19348 | | { |
| | 19349 | | return this == (Tempurature<T>)obj; |
| | 19350 | | } |
| | 19351 | | return false; |
| | 19352 | | } |
| | 19353 | |
|
| | 19354 | | /// <summary>Converts the Tempurature measurement to a string represenation.</summary> |
| | 19355 | | /// <returns>The string representation of the measurement.</returns> |
| | 19356 | | public override string ToString() |
| | 19357 | | { |
| | 19358 | | return _measurement + " " + |
| | 19359 | | _TempuratureUnits1 |
| | 19360 | |
|
| | 19361 | | ; |
| | 19362 | | } |
| | 19363 | |
|
| | 19364 | | /// <summary>Base hashing function for Tempurature measurements.</summary> |
| | 19365 | | /// <returns>Computed hash code for this instance.</returns> |
| | 19366 | | public override int GetHashCode() => Hash(_measurement); |
| | 19367 | |
|
| | 19368 | | #endregion |
| | 19369 | | } |
| | 19370 | |
|
| | 19371 | | #endregion |
| | 19372 | |
|
| | 19373 | | #region Time |
| | 19374 | |
|
| | 19375 | | internal static partial class ParsingFunctions |
| | 19376 | | { |
| | 19377 | | [Measurement.Parseable("Time")] |
| | 19378 | | public static object Time<T>(T value, object[] units) |
| | 19379 | | { |
| | 19380 | | if (units.Length != 1) |
| | 19381 | | { |
| | 19382 | | throw new Exception("Bug in Towel. Invalid parameters to Time Factory."); |
| | 19383 | | } |
| | 19384 | | if (!(units[0] is Time.Units)) |
| | 19385 | | { |
| | 19386 | | throw new Exception("Bug in Towel. Invalid parameters to Time Factory."); |
| | 19387 | | } |
| | 19388 | | return new Time<T>(value |
| | 19389 | | , (Time.Units)units[0] |
| | 19390 | | ); |
| | 19391 | | } |
| | 19392 | | } |
| | 19393 | |
|
| | 19394 | | /// <summary>Time measurement with a value and the units.</summary> |
| | 19395 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 19396 | | public struct Time<T> |
| | 19397 | | { |
| | 19398 | | internal static Func<T, T>[][] Table = UnitConversionTable.Build<Time.Units, T>(); |
| | 19399 | | internal T _measurement; |
| | 19400 | | internal Time.Units _TimeUnits1; |
| | 19401 | |
|
| | 19402 | | #region Statics |
| | 19403 | |
|
| | 19404 | | /// <summary>Converts a Time measurement from units to another.</summary> |
| | 19405 | | /// <param name="value">The value to convert the units of.</param> |
| | 19406 | | /// <param name="fromTimeUnits1">The current units of the measurement.</param> |
| | 19407 | | /// <param name="toTimeUnits1">The desired units of the measurement.</param> |
| | 19408 | | /// <returns>The Time measurement converted into the desired units.</returns> |
| | 19409 | | public static T Convert(T value |
| | 19410 | | , Time.Units fromTimeUnits1 |
| | 19411 | | , Time.Units toTimeUnits1 |
| | 19412 | | ) |
| | 19413 | | { |
| | 19414 | | Time<T> measurement = new Time<T>(value |
| | 19415 | | , fromTimeUnits1 |
| | 19416 | | ); |
| | 19417 | | return measurement[ |
| | 19418 | | toTimeUnits1 |
| | 19419 | | ]; |
| | 19420 | | } |
| | 19421 | |
|
| | 19422 | | /// <summary>Converts a Time measurement from units to another.</summary> |
| | 19423 | | /// <param name="value">The value to convert the units of.</param> |
| | 19424 | | /// <param name="from">The current units of the measurement.</param> |
| | 19425 | | /// <param name="to">The desired units of the measurement.</param> |
| | 19426 | | /// <returns>The Time measurement converted into the desired units.</returns> |
| | 19427 | | public static T Convert(T value, |
| | 19428 | | MeasurementUnitsSyntaxTypes.TimeUnits from, |
| | 19429 | | MeasurementUnitsSyntaxTypes.TimeUnits to) |
| | 19430 | | { |
| | 19431 | | return Convert(value |
| | 19432 | | , from._TimeUnits1 |
| | 19433 | | , to._TimeUnits1 |
| | 19434 | | ); |
| | 19435 | | } |
| | 19436 | |
|
| | 19437 | | /// <summary>Parses a Time measurement string.</summary> |
| | 19438 | | /// <param name="string">The string to be parsed.</param> |
| | 19439 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 19440 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 19441 | | public static (bool Success, Time<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value)> tryParse |
| | 19442 | |
|
| | 19443 | | #endregion |
| | 19444 | |
|
| | 19445 | | #region Constructors |
| | 19446 | |
|
| | 19447 | | /// <summary>Constructs an Time with the measurement value and units.</summary> |
| | 19448 | | /// <param name="measurement">The measurement value of the Time.</param> |
| | 19449 | | /// <param name="units">The units of the Time.</param> |
| | 19450 | | public Time(T measurement, MeasurementUnitsSyntaxTypes.TimeUnits units) : this(measurement |
| | 19451 | | , units._TimeUnits1 |
| | 19452 | | ) { } |
| | 19453 | |
|
| | 19454 | |
|
| | 19455 | | /// <summary>Constructs an Time with the measurement value and units.</summary> |
| | 19456 | | /// <param name="measurement">The measurement value of the Time.</param> |
| | 19457 | | /// <param name="TimeUnits1">The units of the Time.</param> |
| | 19458 | | public Time(T measurement |
| | 19459 | | , Time.Units TimeUnits1 |
| | 19460 | | ) |
| | 19461 | | { |
| | 19462 | | _measurement = measurement; |
| | 19463 | | _TimeUnits1 = TimeUnits1; |
| | 19464 | | } |
| | 19465 | |
|
| | 19466 | | #endregion |
| | 19467 | |
|
| | 19468 | | #region Properties |
| | 19469 | |
|
| | 19470 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 19471 | | public Time.Units TimeUnits1 |
| | 19472 | | { |
| | 19473 | | get { return _TimeUnits1; } |
| | 19474 | | set |
| | 19475 | | { |
| | 19476 | | if (value != _TimeUnits1) |
| | 19477 | | { |
| | 19478 | | _measurement = this[value]; |
| | 19479 | | _TimeUnits1 = value; |
| | 19480 | | } |
| | 19481 | | } |
| | 19482 | | } |
| | 19483 | |
|
| | 19484 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 19485 | | /// <param name="units">The units to get the measurement in.</param> |
| | 19486 | | /// <returns>The measurement value in the specified units.</returns> |
| | 19487 | | public T this[MeasurementUnitsSyntaxTypes.TimeUnits units] |
| | 19488 | | { |
| | 19489 | | get { return this[units._TimeUnits1]; } |
| | 19490 | | } |
| | 19491 | |
|
| | 19492 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 19493 | | /// <param name="TimeUnits1">The #1 component of this measurements units.</param> |
| | 19494 | | /// <returns>The measurement value in the specified units.</returns> |
| | 19495 | | public T this[Time.Units TimeUnits1] |
| | 19496 | | { |
| | 19497 | | get |
| | 19498 | | { |
| | 19499 | | T measurement = _measurement; |
| | 19500 | | if (TimeUnits1 != _TimeUnits1) |
| | 19501 | | { |
| | 19502 | | measurement = Time<T>.Table[(int)_TimeUnits1][(int)TimeUnits1](measurement); |
| | 19503 | | //if (TimeUnits1 < _TimeUnits1) |
| | 19504 | | //{ |
| | 19505 | | // measurement = Time<T>.Table[(int)_TimeUnits1][(int)TimeUnits1](measurement); |
| | 19506 | | //} |
| | 19507 | | //else |
| | 19508 | | //{ |
| | 19509 | | // measurement = Time<T>.Table[(int)TimeUnits1][(int)_TimeUnits1](measurement); |
| | 19510 | | //} |
| | 19511 | | } |
| | 19512 | | return measurement; |
| | 19513 | | } |
| | 19514 | | } |
| | 19515 | |
|
| | 19516 | | #endregion |
| | 19517 | |
|
| | 19518 | | #region Casting Operators |
| | 19519 | |
|
| | 19520 | | /// <summary>Converts a ValueTuple to a Time measurement.</summary> |
| | 19521 | | /// <param name="valueTuple">The ValueTuple to converted into a Time measurement.</param> |
| | 19522 | | public static implicit operator Time<T>((T, MeasurementUnitsSyntaxTypes.TimeUnits) valueTuple) |
| | 19523 | | { |
| | 19524 | | return new Time<T>(valueTuple.Item1, valueTuple.Item2); |
| | 19525 | | } |
| | 19526 | |
|
| | 19527 | | #endregion |
| | 19528 | |
|
| | 19529 | | #region Mathematics |
| | 19530 | |
|
| | 19531 | | #region Bases |
| | 19532 | |
|
| | 19533 | | internal static Time<T> MathBase(Time<T> a, T b, Func<T, T, T> func) |
| | 19534 | | { |
| | 19535 | | return new Time<T>(func(a._measurement, b) |
| | 19536 | | , a._TimeUnits1 |
| | 19537 | | ); |
| | 19538 | | } |
| | 19539 | |
|
| | 19540 | | internal static Time<T> MathBase(Time<T> a, Time<T> b, Func<T, T, T> func) |
| | 19541 | | { |
| | 19542 | | Time.Units TimeUnits1 = a._TimeUnits1 <= b._TimeUnits1 ? a._TimeUnits1 : b._TimeUnits1; |
| | 19543 | | T A = a[TimeUnits1]; |
| | 19544 | | T B = b[TimeUnits1]; |
| | 19545 | | T C = func(A, B); |
| | 19546 | | return new Time<T>(C, TimeUnits1); |
| | 19547 | | } |
| | 19548 | |
|
| | 19549 | | internal static bool LogicBase(Time<T> a, Time<T> b, Func<T, T, bool> func) |
| | 19550 | | { |
| | 19551 | | Time.Units TimeUnits1 = a._TimeUnits1 <= b._TimeUnits1 ? a._TimeUnits1 : b._TimeUnits1; |
| | 19552 | | T A = a[TimeUnits1]; |
| | 19553 | | T B = b[TimeUnits1]; |
| | 19554 | | return func(A, B); |
| | 19555 | | } |
| | 19556 | |
|
| | 19557 | | #endregion |
| | 19558 | |
|
| | 19559 | | #region Add |
| | 19560 | |
|
| | 19561 | | /// <summary>Adds two Time measurements.</summary> |
| | 19562 | | /// <param name="a">The first operand of the addition.</param> |
| | 19563 | | /// <param name="b">The second operand of the addition.</param> |
| | 19564 | | /// <returns>The result of the addition operation.</returns> |
| | 19565 | | public static Time<T> Add(Time<T> a, Time<T> b) |
| | 19566 | | { |
| | 19567 | | return MathBase(a, b, Statics.Addition); |
| | 19568 | | } |
| | 19569 | |
|
| | 19570 | | /// <summary>Adds two Time measurements.</summary> |
| | 19571 | | /// <param name="a">The first operand of the addition.</param> |
| | 19572 | | /// <param name="b">The second operand of the addition.</param> |
| | 19573 | | /// <returns>The result of the addition operation.</returns> |
| | 19574 | | public static Time<T> operator +(Time<T> a, Time<T> b) |
| | 19575 | | { |
| | 19576 | | return Add(a, b); |
| | 19577 | | } |
| | 19578 | |
|
| | 19579 | | /// <summary>Adds two Time measurements.</summary> |
| | 19580 | | /// <param name="b">The second operand of the addition.</param> |
| | 19581 | | /// <returns>The result of the addition operation.</returns> |
| | 19582 | | public Time<T> Add(Time<T> b) |
| | 19583 | | { |
| | 19584 | | return this + b; |
| | 19585 | | } |
| | 19586 | |
|
| | 19587 | | #endregion |
| | 19588 | |
|
| | 19589 | | #region Subtract |
| | 19590 | |
|
| | 19591 | | /// <summary>Subtracts two Time measurements.</summary> |
| | 19592 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 19593 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 19594 | | /// <returns>The result of the subtraction.</returns> |
| | 19595 | | public static Time<T> Subtract(Time<T> a, Time<T> b) |
| | 19596 | | { |
| | 19597 | | return MathBase(a, b, Statics.Subtraction); |
| | 19598 | | } |
| | 19599 | |
|
| | 19600 | | /// <summary>Subtracts two Time measurements.</summary> |
| | 19601 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 19602 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 19603 | | /// <returns>The result of the subtraction.</returns> |
| | 19604 | | public static Time<T> operator -(Time<T> a, Time<T> b) |
| | 19605 | | { |
| | 19606 | | return Subtract(a, b); |
| | 19607 | | } |
| | 19608 | |
|
| | 19609 | | /// <summary>Subtracts two Time measurements.</summary> |
| | 19610 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 19611 | | /// <returns>The result of the subtraction.</returns> |
| | 19612 | | public Time<T> Subtract(Time<T> b) |
| | 19613 | | { |
| | 19614 | | return this - b; |
| | 19615 | | } |
| | 19616 | |
|
| | 19617 | | #endregion |
| | 19618 | |
|
| | 19619 | | #region Multiply |
| | 19620 | |
|
| | 19621 | | /// <summary>Multiplies an Time by a scalar numeric value.</summary> |
| | 19622 | | /// <param name="a">The Time measurement to multiply.</param> |
| | 19623 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 19624 | | /// <returns>The result of the multiplication.</returns> |
| | 19625 | | public static Time<T> Multiply(Time<T> a, T b) |
| | 19626 | | { |
| | 19627 | | return MathBase(a, b, Statics.Multiplication); |
| | 19628 | | } |
| | 19629 | |
|
| | 19630 | | /// <summary>Multiplies an Time by a scalar numeric value.</summary> |
| | 19631 | | /// <param name="a">The Time measurement to multiply.</param> |
| | 19632 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 19633 | | /// <returns>The result of the multiplication.</returns> |
| | 19634 | | public static Time<T> Multiply(T b, Time<T> a) |
| | 19635 | | { |
| | 19636 | | return Multiply(a, b); |
| | 19637 | | } |
| | 19638 | |
|
| | 19639 | | /// <summary>Multiplies an Time by a scalar numeric value.</summary> |
| | 19640 | | /// <param name="a">The Time measurement to multiply.</param> |
| | 19641 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 19642 | | /// <returns>The result of the multiplication.</returns> |
| | 19643 | | public static Time<T> operator *(Time<T> a, T b) |
| | 19644 | | { |
| | 19645 | | return Multiply(a, b); |
| | 19646 | | } |
| | 19647 | |
|
| | 19648 | | /// <summary>Multiplies an Time by a scalar numeric value.</summary> |
| | 19649 | | /// <param name="a">The Time measurement to multiply.</param> |
| | 19650 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 19651 | | /// <returns>The result of the multiplication.</returns> |
| | 19652 | | public static Time<T> operator *(T b, Time<T> a) |
| | 19653 | | { |
| | 19654 | | return Multiply(b, a); |
| | 19655 | | } |
| | 19656 | |
|
| | 19657 | | /// <summary>Multiplies an Time by a scalar numeric value.</summary> |
| | 19658 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 19659 | | /// <returns>The result of the multiplication.</returns> |
| | 19660 | | public Time<T> Add(T b) |
| | 19661 | | { |
| | 19662 | | return this * b; |
| | 19663 | | } |
| | 19664 | |
|
| | 19665 | | #region Time<T> * Acceleration<T> = Speed<T> |
| | 19666 | |
|
| | 19667 | | /// <summary>Mulitplies Time by Acceleration resulting in Speed.</summary> |
| | 19668 | | /// <param name="a">The Time to be multiplied.</param> |
| | 19669 | | /// <param name="b">The Acceleration to multiply by.</param> |
| | 19670 | | /// <returns>The Speed result of the multiplication.</returns> |
| | 19671 | | public static Speed<T> Multiply(Time<T> a, Acceleration<T> b) |
| | 19672 | | { |
| | 19673 | | Time.Units TimeUnits1 = a._TimeUnits1 <= b._TimeUnits2 ? a._TimeUnits1 : b._TimeUnits2; |
| | 19674 | |
|
| | 19675 | | T A = a[TimeUnits1]; |
| | 19676 | | T B = b[b._LengthUnits1, TimeUnits1, b._TimeUnits3]; |
| | 19677 | | T C = Statics.Multiplication(A, B); |
| | 19678 | |
|
| | 19679 | | return new Speed<T>(C |
| | 19680 | | , b._LengthUnits1 |
| | 19681 | | , b._TimeUnits3 |
| | 19682 | | ); |
| | 19683 | | } |
| | 19684 | |
|
| | 19685 | | /// <summary>Mulitplies Time by Acceleration resulting in Speed.</summary> |
| | 19686 | | /// <param name="a">The Time to be multiplied.</param> |
| | 19687 | | /// <param name="b">The Acceleration to multiply by.</param> |
| | 19688 | | /// <returns>The Speed result of the multiplication.</returns> |
| | 19689 | | public static Speed<T> operator *(Time<T> a, Acceleration<T> b) |
| | 19690 | | { |
| | 19691 | | return Multiply(a, b); |
| | 19692 | | } |
| | 19693 | |
|
| | 19694 | | /// <summary>Mulitplies Time by Acceleration resulting in Speed.</summary> |
| | 19695 | | /// <param name="b">The Acceleration to multiply by.</param> |
| | 19696 | | /// <returns>The Speed result of the multiplication.</returns> |
| | 19697 | | public Speed<T> Multiply(Acceleration<T> b) |
| | 19698 | | { |
| | 19699 | | return this * b; |
| | 19700 | | } |
| | 19701 | |
|
| | 19702 | | #endregion |
| | 19703 | |
|
| | 19704 | | #region Time<T> * AngularAcceleration<T> = AngularSpeed<T> |
| | 19705 | |
|
| | 19706 | | /// <summary>Mulitplies Time by AngularAcceleration resulting in AngularSpeed.</summary> |
| | 19707 | | /// <param name="a">The Time to be multiplied.</param> |
| | 19708 | | /// <param name="b">The AngularAcceleration to multiply by.</param> |
| | 19709 | | /// <returns>The AngularSpeed result of the multiplication.</returns> |
| | 19710 | | public static AngularSpeed<T> Multiply(Time<T> a, AngularAcceleration<T> b) |
| | 19711 | | { |
| | 19712 | | Time.Units TimeUnits1 = a._TimeUnits1 <= b._TimeUnits2 ? a._TimeUnits1 : b._TimeUnits2; |
| | 19713 | |
|
| | 19714 | | T A = a[TimeUnits1]; |
| | 19715 | | T B = b[b._AngleUnits1, TimeUnits1, b._TimeUnits3]; |
| | 19716 | | T C = Statics.Multiplication(A, B); |
| | 19717 | |
|
| | 19718 | | return new AngularSpeed<T>(C |
| | 19719 | | , b._AngleUnits1 |
| | 19720 | | , b._TimeUnits3 |
| | 19721 | | ); |
| | 19722 | | } |
| | 19723 | |
|
| | 19724 | | /// <summary>Mulitplies Time by AngularAcceleration resulting in AngularSpeed.</summary> |
| | 19725 | | /// <param name="a">The Time to be multiplied.</param> |
| | 19726 | | /// <param name="b">The AngularAcceleration to multiply by.</param> |
| | 19727 | | /// <returns>The AngularSpeed result of the multiplication.</returns> |
| | 19728 | | public static AngularSpeed<T> operator *(Time<T> a, AngularAcceleration<T> b) |
| | 19729 | | { |
| | 19730 | | return Multiply(a, b); |
| | 19731 | | } |
| | 19732 | |
|
| | 19733 | | /// <summary>Mulitplies Time by AngularAcceleration resulting in AngularSpeed.</summary> |
| | 19734 | | /// <param name="b">The AngularAcceleration to multiply by.</param> |
| | 19735 | | /// <returns>The AngularSpeed result of the multiplication.</returns> |
| | 19736 | | public AngularSpeed<T> Multiply(AngularAcceleration<T> b) |
| | 19737 | | { |
| | 19738 | | return this * b; |
| | 19739 | | } |
| | 19740 | |
|
| | 19741 | | #endregion |
| | 19742 | |
|
| | 19743 | | #region Time<T> * AngularSpeed<T> = Angle<T> |
| | 19744 | |
|
| | 19745 | | /// <summary>Mulitplies Time by AngularSpeed resulting in Angle.</summary> |
| | 19746 | | /// <param name="a">The Time to be multiplied.</param> |
| | 19747 | | /// <param name="b">The AngularSpeed to multiply by.</param> |
| | 19748 | | /// <returns>The Angle result of the multiplication.</returns> |
| | 19749 | | public static Angle<T> Multiply(Time<T> a, AngularSpeed<T> b) |
| | 19750 | | { |
| | 19751 | | Time.Units TimeUnits1 = a._TimeUnits1 <= b._TimeUnits2 ? a._TimeUnits1 : b._TimeUnits2; |
| | 19752 | |
|
| | 19753 | | T A = a[TimeUnits1]; |
| | 19754 | | T B = b[b._AngleUnits1, TimeUnits1]; |
| | 19755 | | T C = Statics.Multiplication(A, B); |
| | 19756 | |
|
| | 19757 | | return new Angle<T>(C |
| | 19758 | | , b._AngleUnits1 |
| | 19759 | | ); |
| | 19760 | | } |
| | 19761 | |
|
| | 19762 | | /// <summary>Mulitplies Time by AngularSpeed resulting in Angle.</summary> |
| | 19763 | | /// <param name="a">The Time to be multiplied.</param> |
| | 19764 | | /// <param name="b">The AngularSpeed to multiply by.</param> |
| | 19765 | | /// <returns>The Angle result of the multiplication.</returns> |
| | 19766 | | public static Angle<T> operator *(Time<T> a, AngularSpeed<T> b) |
| | 19767 | | { |
| | 19768 | | return Multiply(a, b); |
| | 19769 | | } |
| | 19770 | |
|
| | 19771 | | /// <summary>Mulitplies Time by AngularSpeed resulting in Angle.</summary> |
| | 19772 | | /// <param name="b">The AngularSpeed to multiply by.</param> |
| | 19773 | | /// <returns>The Angle result of the multiplication.</returns> |
| | 19774 | | public Angle<T> Multiply(AngularSpeed<T> b) |
| | 19775 | | { |
| | 19776 | | return this * b; |
| | 19777 | | } |
| | 19778 | |
|
| | 19779 | | #endregion |
| | 19780 | |
|
| | 19781 | | #region Time<T> * ElectricCurrent<T> = ElectricCharge<T> |
| | 19782 | |
|
| | 19783 | | /// <summary>Mulitplies Time by ElectricCurrent resulting in ElectricCharge.</summary> |
| | 19784 | | /// <param name="a">The Time to be multiplied.</param> |
| | 19785 | | /// <param name="b">The ElectricCurrent to multiply by.</param> |
| | 19786 | | /// <returns>The ElectricCharge result of the multiplication.</returns> |
| | 19787 | | public static ElectricCharge<T> Multiply(Time<T> a, ElectricCurrent<T> b) |
| | 19788 | | { |
| | 19789 | | Time.Units TimeUnits1 = a._TimeUnits1 <= b._TimeUnits2 ? a._TimeUnits1 : b._TimeUnits2; |
| | 19790 | |
|
| | 19791 | | T A = a[TimeUnits1]; |
| | 19792 | | T B = b[b._ElectricChargeUnits1, TimeUnits1]; |
| | 19793 | | T C = Statics.Multiplication(A, B); |
| | 19794 | |
|
| | 19795 | | return new ElectricCharge<T>(C |
| | 19796 | | , b._ElectricChargeUnits1 |
| | 19797 | | ); |
| | 19798 | | } |
| | 19799 | |
|
| | 19800 | | /// <summary>Mulitplies Time by ElectricCurrent resulting in ElectricCharge.</summary> |
| | 19801 | | /// <param name="a">The Time to be multiplied.</param> |
| | 19802 | | /// <param name="b">The ElectricCurrent to multiply by.</param> |
| | 19803 | | /// <returns>The ElectricCharge result of the multiplication.</returns> |
| | 19804 | | public static ElectricCharge<T> operator *(Time<T> a, ElectricCurrent<T> b) |
| | 19805 | | { |
| | 19806 | | return Multiply(a, b); |
| | 19807 | | } |
| | 19808 | |
|
| | 19809 | | /// <summary>Mulitplies Time by ElectricCurrent resulting in ElectricCharge.</summary> |
| | 19810 | | /// <param name="b">The ElectricCurrent to multiply by.</param> |
| | 19811 | | /// <returns>The ElectricCharge result of the multiplication.</returns> |
| | 19812 | | public ElectricCharge<T> Multiply(ElectricCurrent<T> b) |
| | 19813 | | { |
| | 19814 | | return this * b; |
| | 19815 | | } |
| | 19816 | |
|
| | 19817 | | #endregion |
| | 19818 | |
|
| | 19819 | | #region Time<T> * Force<T> = LinearMassFlow<T> |
| | 19820 | |
|
| | 19821 | | /// <summary>Mulitplies Time by Force resulting in LinearMassFlow.</summary> |
| | 19822 | | /// <param name="a">The Time to be multiplied.</param> |
| | 19823 | | /// <param name="b">The Force to multiply by.</param> |
| | 19824 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 19825 | | public static LinearMassFlow<T> Multiply(Time<T> a, Force<T> b) |
| | 19826 | | { |
| | 19827 | | Time.Units TimeUnits1 = a._TimeUnits1 <= b._TimeUnits3 ? a._TimeUnits1 : b._TimeUnits3; |
| | 19828 | |
|
| | 19829 | | T A = a[TimeUnits1]; |
| | 19830 | | T B = b[b._MassUnits1, b._LengthUnits2, TimeUnits1, b._TimeUnits4]; |
| | 19831 | | T C = Statics.Multiplication(A, B); |
| | 19832 | |
|
| | 19833 | | return new LinearMassFlow<T>(C |
| | 19834 | | , b._MassUnits1 |
| | 19835 | | , b._LengthUnits2 |
| | 19836 | | , b._TimeUnits4 |
| | 19837 | | ); |
| | 19838 | | } |
| | 19839 | |
|
| | 19840 | | /// <summary>Mulitplies Time by Force resulting in LinearMassFlow.</summary> |
| | 19841 | | /// <param name="a">The Time to be multiplied.</param> |
| | 19842 | | /// <param name="b">The Force to multiply by.</param> |
| | 19843 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 19844 | | public static LinearMassFlow<T> operator *(Time<T> a, Force<T> b) |
| | 19845 | | { |
| | 19846 | | return Multiply(a, b); |
| | 19847 | | } |
| | 19848 | |
|
| | 19849 | | /// <summary>Mulitplies Time by Force resulting in LinearMassFlow.</summary> |
| | 19850 | | /// <param name="b">The Force to multiply by.</param> |
| | 19851 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 19852 | | public LinearMassFlow<T> Multiply(Force<T> b) |
| | 19853 | | { |
| | 19854 | | return this * b; |
| | 19855 | | } |
| | 19856 | |
|
| | 19857 | | #endregion |
| | 19858 | |
|
| | 19859 | | #region Time<T> * LinearMassFlow<T> = LinearMass<T> |
| | 19860 | |
|
| | 19861 | | /// <summary>Mulitplies Time by LinearMassFlow resulting in LinearMass.</summary> |
| | 19862 | | /// <param name="a">The Time to be multiplied.</param> |
| | 19863 | | /// <param name="b">The LinearMassFlow to multiply by.</param> |
| | 19864 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 19865 | | public static LinearMass<T> Multiply(Time<T> a, LinearMassFlow<T> b) |
| | 19866 | | { |
| | 19867 | | Time.Units TimeUnits1 = a._TimeUnits1 <= b._TimeUnits3 ? a._TimeUnits1 : b._TimeUnits3; |
| | 19868 | |
|
| | 19869 | | T A = a[TimeUnits1]; |
| | 19870 | | T B = b[b._MassUnits1, b._LengthUnits2, TimeUnits1]; |
| | 19871 | | T C = Statics.Multiplication(A, B); |
| | 19872 | |
|
| | 19873 | | return new LinearMass<T>(C |
| | 19874 | | , b._MassUnits1 |
| | 19875 | | , b._LengthUnits2 |
| | 19876 | | ); |
| | 19877 | | } |
| | 19878 | |
|
| | 19879 | | /// <summary>Mulitplies Time by LinearMassFlow resulting in LinearMass.</summary> |
| | 19880 | | /// <param name="a">The Time to be multiplied.</param> |
| | 19881 | | /// <param name="b">The LinearMassFlow to multiply by.</param> |
| | 19882 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 19883 | | public static LinearMass<T> operator *(Time<T> a, LinearMassFlow<T> b) |
| | 19884 | | { |
| | 19885 | | return Multiply(a, b); |
| | 19886 | | } |
| | 19887 | |
|
| | 19888 | | /// <summary>Mulitplies Time by LinearMassFlow resulting in LinearMass.</summary> |
| | 19889 | | /// <param name="b">The LinearMassFlow to multiply by.</param> |
| | 19890 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 19891 | | public LinearMass<T> Multiply(LinearMassFlow<T> b) |
| | 19892 | | { |
| | 19893 | | return this * b; |
| | 19894 | | } |
| | 19895 | |
|
| | 19896 | | #endregion |
| | 19897 | |
|
| | 19898 | | #region Time<T> * MassRate<T> = Mass<T> |
| | 19899 | |
|
| | 19900 | | /// <summary>Mulitplies Time by MassRate resulting in Mass.</summary> |
| | 19901 | | /// <param name="a">The Time to be multiplied.</param> |
| | 19902 | | /// <param name="b">The MassRate to multiply by.</param> |
| | 19903 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 19904 | | public static Mass<T> Multiply(Time<T> a, MassRate<T> b) |
| | 19905 | | { |
| | 19906 | | Time.Units TimeUnits1 = a._TimeUnits1 <= b._TimeUnits2 ? a._TimeUnits1 : b._TimeUnits2; |
| | 19907 | |
|
| | 19908 | | T A = a[TimeUnits1]; |
| | 19909 | | T B = b[b._MassUnits1, TimeUnits1]; |
| | 19910 | | T C = Statics.Multiplication(A, B); |
| | 19911 | |
|
| | 19912 | | return new Mass<T>(C |
| | 19913 | | , b._MassUnits1 |
| | 19914 | | ); |
| | 19915 | | } |
| | 19916 | |
|
| | 19917 | | /// <summary>Mulitplies Time by MassRate resulting in Mass.</summary> |
| | 19918 | | /// <param name="a">The Time to be multiplied.</param> |
| | 19919 | | /// <param name="b">The MassRate to multiply by.</param> |
| | 19920 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 19921 | | public static Mass<T> operator *(Time<T> a, MassRate<T> b) |
| | 19922 | | { |
| | 19923 | | return Multiply(a, b); |
| | 19924 | | } |
| | 19925 | |
|
| | 19926 | | /// <summary>Mulitplies Time by MassRate resulting in Mass.</summary> |
| | 19927 | | /// <param name="b">The MassRate to multiply by.</param> |
| | 19928 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 19929 | | public Mass<T> Multiply(MassRate<T> b) |
| | 19930 | | { |
| | 19931 | | return this * b; |
| | 19932 | | } |
| | 19933 | |
|
| | 19934 | | #endregion |
| | 19935 | |
|
| | 19936 | | #region Time<T> * Power<T> = Energy<T> |
| | 19937 | |
|
| | 19938 | | /// <summary>Mulitplies Time by Power resulting in Energy.</summary> |
| | 19939 | | /// <param name="a">The Time to be multiplied.</param> |
| | 19940 | | /// <param name="b">The Power to multiply by.</param> |
| | 19941 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 19942 | | public static Energy<T> Multiply(Time<T> a, Power<T> b) |
| | 19943 | | { |
| | 19944 | | Time.Units TimeUnits1 = a._TimeUnits1 <= b._TimeUnits4 ? a._TimeUnits1 : b._TimeUnits4; |
| | 19945 | |
|
| | 19946 | | T A = a[TimeUnits1]; |
| | 19947 | | T B = b[b._MassUnits1, b._LengthUnits2, b._LengthUnits3, TimeUnits1, b._TimeUnits5, b._TimeUnits6]; |
| | 19948 | | T C = Statics.Multiplication(A, B); |
| | 19949 | |
|
| | 19950 | | return new Energy<T>(C |
| | 19951 | | , b._MassUnits1 |
| | 19952 | | , b._LengthUnits2 |
| | 19953 | | , b._LengthUnits3 |
| | 19954 | | , b._TimeUnits5 |
| | 19955 | | , b._TimeUnits6 |
| | 19956 | | ); |
| | 19957 | | } |
| | 19958 | |
|
| | 19959 | | /// <summary>Mulitplies Time by Power resulting in Energy.</summary> |
| | 19960 | | /// <param name="a">The Time to be multiplied.</param> |
| | 19961 | | /// <param name="b">The Power to multiply by.</param> |
| | 19962 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 19963 | | public static Energy<T> operator *(Time<T> a, Power<T> b) |
| | 19964 | | { |
| | 19965 | | return Multiply(a, b); |
| | 19966 | | } |
| | 19967 | |
|
| | 19968 | | /// <summary>Mulitplies Time by Power resulting in Energy.</summary> |
| | 19969 | | /// <param name="b">The Power to multiply by.</param> |
| | 19970 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 19971 | | public Energy<T> Multiply(Power<T> b) |
| | 19972 | | { |
| | 19973 | | return this * b; |
| | 19974 | | } |
| | 19975 | |
|
| | 19976 | | #endregion |
| | 19977 | |
|
| | 19978 | | #region Time<T> * Speed<T> = Length<T> |
| | 19979 | |
|
| | 19980 | | /// <summary>Mulitplies Time by Speed resulting in Length.</summary> |
| | 19981 | | /// <param name="a">The Time to be multiplied.</param> |
| | 19982 | | /// <param name="b">The Speed to multiply by.</param> |
| | 19983 | | /// <returns>The Length result of the multiplication.</returns> |
| | 19984 | | public static Length<T> Multiply(Time<T> a, Speed<T> b) |
| | 19985 | | { |
| | 19986 | | Time.Units TimeUnits1 = a._TimeUnits1 <= b._TimeUnits2 ? a._TimeUnits1 : b._TimeUnits2; |
| | 19987 | |
|
| | 19988 | | T A = a[TimeUnits1]; |
| | 19989 | | T B = b[b._LengthUnits1, TimeUnits1]; |
| | 19990 | | T C = Statics.Multiplication(A, B); |
| | 19991 | |
|
| | 19992 | | return new Length<T>(C |
| | 19993 | | , b._LengthUnits1 |
| | 19994 | | ); |
| | 19995 | | } |
| | 19996 | |
|
| | 19997 | | /// <summary>Mulitplies Time by Speed resulting in Length.</summary> |
| | 19998 | | /// <param name="a">The Time to be multiplied.</param> |
| | 19999 | | /// <param name="b">The Speed to multiply by.</param> |
| | 20000 | | /// <returns>The Length result of the multiplication.</returns> |
| | 20001 | | public static Length<T> operator *(Time<T> a, Speed<T> b) |
| | 20002 | | { |
| | 20003 | | return Multiply(a, b); |
| | 20004 | | } |
| | 20005 | |
|
| | 20006 | | /// <summary>Mulitplies Time by Speed resulting in Length.</summary> |
| | 20007 | | /// <param name="b">The Speed to multiply by.</param> |
| | 20008 | | /// <returns>The Length result of the multiplication.</returns> |
| | 20009 | | public Length<T> Multiply(Speed<T> b) |
| | 20010 | | { |
| | 20011 | | return this * b; |
| | 20012 | | } |
| | 20013 | |
|
| | 20014 | | #endregion |
| | 20015 | |
|
| | 20016 | | #region Time<T> * Time<T> = TimeArea<T> |
| | 20017 | |
|
| | 20018 | | /// <summary>Mulitplies Time by Time resulting in TimeArea.</summary> |
| | 20019 | | /// <param name="a">The Time to be multiplied.</param> |
| | 20020 | | /// <param name="b">The Time to multiply by.</param> |
| | 20021 | | /// <returns>The TimeArea result of the multiplication.</returns> |
| | 20022 | | public static TimeArea<T> Multiply(Time<T> a, Time<T> b) |
| | 20023 | | { |
| | 20024 | |
|
| | 20025 | | T A = a[a._TimeUnits1]; |
| | 20026 | | T B = b[b._TimeUnits1]; |
| | 20027 | | T C = Statics.Multiplication(A, B); |
| | 20028 | |
|
| | 20029 | | return new TimeArea<T>(C |
| | 20030 | | , a._TimeUnits1 |
| | 20031 | | , b._TimeUnits1 |
| | 20032 | | ); |
| | 20033 | | } |
| | 20034 | |
|
| | 20035 | | /// <summary>Mulitplies Time by Time resulting in TimeArea.</summary> |
| | 20036 | | /// <param name="a">The Time to be multiplied.</param> |
| | 20037 | | /// <param name="b">The Time to multiply by.</param> |
| | 20038 | | /// <returns>The TimeArea result of the multiplication.</returns> |
| | 20039 | | public static TimeArea<T> operator *(Time<T> a, Time<T> b) |
| | 20040 | | { |
| | 20041 | | return Multiply(a, b); |
| | 20042 | | } |
| | 20043 | |
|
| | 20044 | | /// <summary>Mulitplies Time by Time resulting in TimeArea.</summary> |
| | 20045 | | /// <param name="b">The Time to multiply by.</param> |
| | 20046 | | /// <returns>The TimeArea result of the multiplication.</returns> |
| | 20047 | | public TimeArea<T> Multiply(Time<T> b) |
| | 20048 | | { |
| | 20049 | | return this * b; |
| | 20050 | | } |
| | 20051 | |
|
| | 20052 | | #endregion |
| | 20053 | |
|
| | 20054 | | #region Time<T> * VolumeRate<T> = Volume<T> |
| | 20055 | |
|
| | 20056 | | /// <summary>Mulitplies Time by VolumeRate resulting in Volume.</summary> |
| | 20057 | | /// <param name="a">The Time to be multiplied.</param> |
| | 20058 | | /// <param name="b">The VolumeRate to multiply by.</param> |
| | 20059 | | /// <returns>The Volume result of the multiplication.</returns> |
| | 20060 | | public static Volume<T> Multiply(Time<T> a, VolumeRate<T> b) |
| | 20061 | | { |
| | 20062 | | Time.Units TimeUnits1 = a._TimeUnits1 <= b._TimeUnits4 ? a._TimeUnits1 : b._TimeUnits4; |
| | 20063 | |
|
| | 20064 | | T A = a[TimeUnits1]; |
| | 20065 | | T B = b[b._LengthUnits1, b._LengthUnits2, b._LengthUnits3, TimeUnits1]; |
| | 20066 | | T C = Statics.Multiplication(A, B); |
| | 20067 | |
|
| | 20068 | | return new Volume<T>(C |
| | 20069 | | , b._LengthUnits1 |
| | 20070 | | , b._LengthUnits2 |
| | 20071 | | , b._LengthUnits3 |
| | 20072 | | ); |
| | 20073 | | } |
| | 20074 | |
|
| | 20075 | | /// <summary>Mulitplies Time by VolumeRate resulting in Volume.</summary> |
| | 20076 | | /// <param name="a">The Time to be multiplied.</param> |
| | 20077 | | /// <param name="b">The VolumeRate to multiply by.</param> |
| | 20078 | | /// <returns>The Volume result of the multiplication.</returns> |
| | 20079 | | public static Volume<T> operator *(Time<T> a, VolumeRate<T> b) |
| | 20080 | | { |
| | 20081 | | return Multiply(a, b); |
| | 20082 | | } |
| | 20083 | |
|
| | 20084 | | /// <summary>Mulitplies Time by VolumeRate resulting in Volume.</summary> |
| | 20085 | | /// <param name="b">The VolumeRate to multiply by.</param> |
| | 20086 | | /// <returns>The Volume result of the multiplication.</returns> |
| | 20087 | | public Volume<T> Multiply(VolumeRate<T> b) |
| | 20088 | | { |
| | 20089 | | return this * b; |
| | 20090 | | } |
| | 20091 | |
|
| | 20092 | | #endregion |
| | 20093 | |
|
| | 20094 | | #endregion |
| | 20095 | |
|
| | 20096 | | #region Divide |
| | 20097 | |
|
| | 20098 | | /// <summary>Divides an Time measurement by another Time measurement resulting in a scalar numeric value.</summary> |
| | 20099 | | /// <param name="a">The first operand of the division operation.</param> |
| | 20100 | | /// <param name="b">The second operand of the division operation.</param> |
| | 20101 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 20102 | | public static T Divide(Time<T> a, Time<T> b) |
| | 20103 | | { |
| | 20104 | | Time.Units TimeUnits1 = a._TimeUnits1 <= b._TimeUnits1 ? a._TimeUnits1 : b._TimeUnits1; |
| | 20105 | | T A = a[TimeUnits1]; |
| | 20106 | | T B = b[TimeUnits1]; |
| | 20107 | | return Statics.Division(A, B); |
| | 20108 | | } |
| | 20109 | |
|
| | 20110 | | /// <summary>Divides this Time measurement by a numaric scalar value.</summary> |
| | 20111 | | /// <param name="a">The Time measurement to divide.</param> |
| | 20112 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 20113 | | /// <returns>The result of the division.</returns> |
| | 20114 | | public static Time<T> Divide(Time<T> a, T b) |
| | 20115 | | { |
| | 20116 | | return MathBase(a, b, Statics.Division); |
| | 20117 | | } |
| | 20118 | |
|
| | 20119 | | /// <summary>Divides this Time measurement by a numaric scalar value.</summary> |
| | 20120 | | /// <param name="a">The Time measurement to divide.</param> |
| | 20121 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 20122 | | /// <returns>The result of the division.</returns> |
| | 20123 | | public static Time<T> operator /(Time<T> a, T b) |
| | 20124 | | { |
| | 20125 | | return Divide(a, b); |
| | 20126 | | } |
| | 20127 | |
|
| | 20128 | | /// <summary>Divides this Time measurement by a numaric scalar value.</summary> |
| | 20129 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 20130 | | /// <returns>The result of the division.</returns> |
| | 20131 | | public Time<T> Divide(T b) |
| | 20132 | | { |
| | 20133 | | return this / b; |
| | 20134 | | } |
| | 20135 | |
|
| | 20136 | | /// <summary>Divides an Time measurement by another Time measurement resulting in a scalar numeric value.</summary> |
| | 20137 | | /// <param name="a">The first operand of the division operation.</param> |
| | 20138 | | /// <param name="b">The second operand of the division operation.</param> |
| | 20139 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 20140 | | public static T operator /(Time<T> a, Time<T> b) |
| | 20141 | | { |
| | 20142 | | return Divide(a, b); |
| | 20143 | | } |
| | 20144 | |
|
| | 20145 | | /// <summary>Divides an Time measurement by another Time measurement resulting in a scalar numeric value.</summary> |
| | 20146 | | /// <param name="b">The second operand of the division operation.</param> |
| | 20147 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 20148 | | public T Divide(Time<T> b) |
| | 20149 | | { |
| | 20150 | | return this / b; |
| | 20151 | | } |
| | 20152 | |
|
| | 20153 | | #endregion |
| | 20154 | |
|
| | 20155 | | #region LessThan |
| | 20156 | |
|
| | 20157 | | /// <summary>Determines if an Time measurement is less than another Time measurement.</summary> |
| | 20158 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 20159 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 20160 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 20161 | | public static bool LessThan(Time<T> a, Time<T> b) |
| | 20162 | | { |
| | 20163 | | return LogicBase(a, b, Statics.LessThan); |
| | 20164 | | } |
| | 20165 | |
|
| | 20166 | | /// <summary>Determines if an Time measurement is less than another Time measurement.</summary> |
| | 20167 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 20168 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 20169 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 20170 | | public static bool operator <(Time<T> a, Time<T> b) |
| | 20171 | | { |
| | 20172 | | return LessThan(a, b); |
| | 20173 | | } |
| | 20174 | |
|
| | 20175 | | /// <summary>Determines if an Time measurement is less than another Time measurement.</summary> |
| | 20176 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 20177 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 20178 | | public bool LessThan(Time<T> b) |
| | 20179 | | { |
| | 20180 | | return this < b; |
| | 20181 | | } |
| | 20182 | |
|
| | 20183 | | #endregion |
| | 20184 | |
|
| | 20185 | | #region GreaterThan |
| | 20186 | |
|
| | 20187 | | /// <summary>Determines if an Time measurement is greater than another Time measurement.</summary> |
| | 20188 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 20189 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 20190 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 20191 | | public static bool GreaterThan(Time<T> a, Time<T> b) |
| | 20192 | | { |
| | 20193 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 20194 | | } |
| | 20195 | |
|
| | 20196 | | /// <summary>Determines if an Time measurement is greater than another Time measurement.</summary> |
| | 20197 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 20198 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 20199 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 20200 | | public static bool operator >(Time<T> a, Time<T> b) |
| | 20201 | | { |
| | 20202 | | return GreaterThan(a, b); |
| | 20203 | | } |
| | 20204 | |
|
| | 20205 | | /// <summary>Determines if an Time measurement is greater than another Time measurement.</summary> |
| | 20206 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 20207 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 20208 | | public bool GreaterThan(Time<T> b) |
| | 20209 | | { |
| | 20210 | | return this > b; |
| | 20211 | | } |
| | 20212 | |
|
| | 20213 | | #endregion |
| | 20214 | |
|
| | 20215 | | #region LessThanOrEqual |
| | 20216 | |
|
| | 20217 | | /// <summary>Determines if an Time measurement is less than or equal to another Time measurement.</summary> |
| | 20218 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 20219 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 20220 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 20221 | | public static bool LessThanOrEqual(Time<T> a, Time<T> b) |
| | 20222 | | { |
| | 20223 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 20224 | | } |
| | 20225 | |
|
| | 20226 | | /// <summary>Determines if an Time measurement is less than or equal to another Time measurement.</summary> |
| | 20227 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 20228 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 20229 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 20230 | | public static bool operator <=(Time<T> a, Time<T> b) |
| | 20231 | | { |
| | 20232 | | return LessThanOrEqual(a, b); |
| | 20233 | | } |
| | 20234 | |
|
| | 20235 | | /// <summary>Determines if an Time measurement is less than or equal to another Time measurement.</summary> |
| | 20236 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 20237 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 20238 | | public bool LessThanOrEqual(Time<T> b) |
| | 20239 | | { |
| | 20240 | | return this <= b; |
| | 20241 | | } |
| | 20242 | |
|
| | 20243 | | #endregion |
| | 20244 | |
|
| | 20245 | | #region GreaterThanOrEqual |
| | 20246 | |
|
| | 20247 | | /// <summary>Determines if an Time measurement is greater than or equal to another Time measurement.</summary> |
| | 20248 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 20249 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 20250 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 20251 | | public static bool GreaterThanOrEqual(Time<T> a, Time<T> b) |
| | 20252 | | { |
| | 20253 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 20254 | | } |
| | 20255 | |
|
| | 20256 | | /// <summary>Determines if an Time measurement is greater than or equal to another Time measurement.</summary> |
| | 20257 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 20258 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 20259 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 20260 | | public static bool operator >=(Time<T> a, Time<T> b) |
| | 20261 | | { |
| | 20262 | | return GreaterThanOrEqual(a, b); |
| | 20263 | | } |
| | 20264 | |
|
| | 20265 | | /// <summary>Determines if an Time measurement is greater than or equal to another Time measurement.</summary> |
| | 20266 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 20267 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 20268 | | public bool GreaterThanOrEqual(Time<T> b) |
| | 20269 | | { |
| | 20270 | | return this >= b; |
| | 20271 | | } |
| | 20272 | |
|
| | 20273 | | #endregion |
| | 20274 | |
|
| | 20275 | | #region Equal |
| | 20276 | |
|
| | 20277 | | /// <summary>Determines if an Time measurement is equal to another Time measurement.</summary> |
| | 20278 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 20279 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 20280 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 20281 | | public static bool Equal(Time<T> a, Time<T> b) |
| | 20282 | | { |
| | 20283 | | return LogicBase(a, b, Statics.Equate); |
| | 20284 | | } |
| | 20285 | |
|
| | 20286 | | /// <summary>Determines if an Time measurement is equal to another Time measurement.</summary> |
| | 20287 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 20288 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 20289 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 20290 | | public static bool operator ==(Time<T> a, Time<T> b) |
| | 20291 | | { |
| | 20292 | | return Equal(a, b); |
| | 20293 | | } |
| | 20294 | |
|
| | 20295 | | /// <summary>Determines if an Time measurement is equal to another Time measurement.</summary> |
| | 20296 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 20297 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 20298 | | public bool Equal(Time<T> b) |
| | 20299 | | { |
| | 20300 | | return this == b; |
| | 20301 | | } |
| | 20302 | |
|
| | 20303 | | #endregion |
| | 20304 | |
|
| | 20305 | | #region NotEqual |
| | 20306 | |
|
| | 20307 | | /// <summary>Determines if an Time measurement is not equal to another Time measurement.</summary> |
| | 20308 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 20309 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 20310 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 20311 | | public static bool NotEqual(Time<T> a, Time<T> b) |
| | 20312 | | { |
| | 20313 | | return LogicBase(a, b, Statics.Inequate); |
| | 20314 | | } |
| | 20315 | |
|
| | 20316 | | /// <summary>Determines if an Time measurement is not equal to another Time measurement.</summary> |
| | 20317 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 20318 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 20319 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 20320 | | public static bool operator !=(Time<T> a, Time<T> b) |
| | 20321 | | { |
| | 20322 | | return NotEqual(a, b); |
| | 20323 | | } |
| | 20324 | |
|
| | 20325 | | /// <summary>Determines if an Time measurement is not equal to another Time measurement.</summary> |
| | 20326 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 20327 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 20328 | | public bool NotEqual(Time<T> b) |
| | 20329 | | { |
| | 20330 | | return this != b; |
| | 20331 | | } |
| | 20332 | |
|
| | 20333 | | #endregion |
| | 20334 | |
|
| | 20335 | | #endregion |
| | 20336 | |
|
| | 20337 | | #region Overrides |
| | 20338 | |
|
| | 20339 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 20340 | | /// <param name="obj">The object to check for equality with.</param> |
| | 20341 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 20342 | | public override bool Equals(object obj) |
| | 20343 | | { |
| | 20344 | | if (obj is Time<T>) |
| | 20345 | | { |
| | 20346 | | return this == (Time<T>)obj; |
| | 20347 | | } |
| | 20348 | | return false; |
| | 20349 | | } |
| | 20350 | |
|
| | 20351 | | /// <summary>Converts the Time measurement to a string represenation.</summary> |
| | 20352 | | /// <returns>The string representation of the measurement.</returns> |
| | 20353 | | public override string ToString() |
| | 20354 | | { |
| | 20355 | | return _measurement + " " + |
| | 20356 | | _TimeUnits1 |
| | 20357 | |
|
| | 20358 | | ; |
| | 20359 | | } |
| | 20360 | |
|
| | 20361 | | /// <summary>Base hashing function for Time measurements.</summary> |
| | 20362 | | /// <returns>Computed hash code for this instance.</returns> |
| | 20363 | | public override int GetHashCode() => Hash(_measurement); |
| | 20364 | |
|
| | 20365 | | #endregion |
| | 20366 | | } |
| | 20367 | |
|
| | 20368 | | #endregion |
| | 20369 | |
|
| | 20370 | | #region TimeArea |
| | 20371 | |
|
| | 20372 | | internal static partial class ParsingFunctions |
| | 20373 | | { |
| | 20374 | | [Measurement.Parseable("Time*Time")] |
| | 20375 | | public static object TimeArea<T>(T value, object[] units) |
| | 20376 | | { |
| | 20377 | | if (units.Length != 2) |
| | 20378 | | { |
| | 20379 | | throw new Exception("Bug in Towel. Invalid parameters to TimeArea Factory."); |
| | 20380 | | } |
| | 20381 | | if (!(units[0] is Time.Units)) |
| | 20382 | | { |
| | 20383 | | throw new Exception("Bug in Towel. Invalid parameters to TimeArea Factory."); |
| | 20384 | | } |
| | 20385 | | if (!(units[1] is Time.Units)) |
| | 20386 | | { |
| | 20387 | | throw new Exception("Bug in Towel. Invalid parameters to TimeArea Factory."); |
| | 20388 | | } |
| | 20389 | | return new TimeArea<T>(value |
| | 20390 | | , (Time.Units)units[0] |
| | 20391 | | , (Time.Units)units[1] |
| | 20392 | | ); |
| | 20393 | | } |
| | 20394 | | } |
| | 20395 | |
|
| | 20396 | | /// <summary>TimeArea measurement with a value and the units.</summary> |
| | 20397 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 20398 | | public struct TimeArea<T> |
| | 20399 | | { |
| | 20400 | | internal T _measurement; |
| | 20401 | | internal Time.Units _TimeUnits1; |
| | 20402 | | internal Time.Units _TimeUnits2; |
| | 20403 | |
|
| | 20404 | | #region Statics |
| | 20405 | |
|
| | 20406 | | /// <summary>Converts a TimeArea measurement from units to another.</summary> |
| | 20407 | | /// <param name="value">The value to convert the units of.</param> |
| | 20408 | | /// <param name="fromTimeUnits1">The current units of the measurement.</param> |
| | 20409 | | /// <param name="fromTimeUnits2">The current units of the measurement.</param> |
| | 20410 | | /// <param name="toTimeUnits1">The desired units of the measurement.</param> |
| | 20411 | | /// <param name="toTimeUnits2">The desired units of the measurement.</param> |
| | 20412 | | /// <returns>The TimeArea measurement converted into the desired units.</returns> |
| | 20413 | | public static T Convert(T value |
| | 20414 | | , Time.Units fromTimeUnits1 |
| | 20415 | | , Time.Units fromTimeUnits2 |
| | 20416 | | , Time.Units toTimeUnits1 |
| | 20417 | | , Time.Units toTimeUnits2 |
| | 20418 | | ) |
| | 20419 | | { |
| | 20420 | | TimeArea<T> measurement = new TimeArea<T>(value |
| | 20421 | | , fromTimeUnits1 |
| | 20422 | | , fromTimeUnits2 |
| | 20423 | | ); |
| | 20424 | | return measurement[ |
| | 20425 | | toTimeUnits1 |
| | 20426 | | , toTimeUnits2 |
| | 20427 | | ]; |
| | 20428 | | } |
| | 20429 | |
|
| | 20430 | | /// <summary>Converts a TimeArea measurement from units to another.</summary> |
| | 20431 | | /// <param name="value">The value to convert the units of.</param> |
| | 20432 | | /// <param name="from">The current units of the measurement.</param> |
| | 20433 | | /// <param name="to">The desired units of the measurement.</param> |
| | 20434 | | /// <returns>The TimeArea measurement converted into the desired units.</returns> |
| | 20435 | | public static T Convert(T value, |
| | 20436 | | MeasurementUnitsSyntaxTypes.TimeAreaBaseUnits from, |
| | 20437 | | MeasurementUnitsSyntaxTypes.TimeAreaBaseUnits to) |
| | 20438 | | { |
| | 20439 | | return Convert(value |
| | 20440 | | , from._TimeUnits1 |
| | 20441 | | , from._TimeUnits2 |
| | 20442 | | , to._TimeUnits1 |
| | 20443 | | , to._TimeUnits2 |
| | 20444 | | ); |
| | 20445 | | } |
| | 20446 | |
|
| | 20447 | | /// <summary>Parses a TimeArea measurement string.</summary> |
| | 20448 | | /// <param name="string">The string to be parsed.</param> |
| | 20449 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 20450 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 20451 | | public static (bool Success, TimeArea<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value)> tryP |
| | 20452 | |
|
| | 20453 | | #endregion |
| | 20454 | |
|
| | 20455 | | #region Constructors |
| | 20456 | |
|
| | 20457 | | /// <summary>Constructs an TimeArea with the measurement value and units.</summary> |
| | 20458 | | /// <param name="measurement">The measurement value of the TimeArea.</param> |
| | 20459 | | /// <param name="units">The units of the TimeArea.</param> |
| | 20460 | | public TimeArea(T measurement, MeasurementUnitsSyntaxTypes.TimeAreaBaseUnits units) : this(measurement |
| | 20461 | | , units._TimeUnits1 |
| | 20462 | | , units._TimeUnits2 |
| | 20463 | | ) { } |
| | 20464 | |
|
| | 20465 | |
|
| | 20466 | | /// <summary>Constructs an TimeArea with the measurement value and units.</summary> |
| | 20467 | | /// <param name="measurement">The measurement value of the TimeArea.</param> |
| | 20468 | | /// <param name="TimeUnits1">The units of the TimeArea.</param> |
| | 20469 | | /// <param name="TimeUnits2">The units of the TimeArea.</param> |
| | 20470 | | public TimeArea(T measurement |
| | 20471 | | , Time.Units TimeUnits1 |
| | 20472 | | , Time.Units TimeUnits2 |
| | 20473 | | ) |
| | 20474 | | { |
| | 20475 | | _measurement = measurement; |
| | 20476 | | _TimeUnits1 = TimeUnits1; |
| | 20477 | | _TimeUnits2 = TimeUnits2; |
| | 20478 | | } |
| | 20479 | |
|
| | 20480 | | #endregion |
| | 20481 | |
|
| | 20482 | | #region Properties |
| | 20483 | |
|
| | 20484 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 20485 | | public Time.Units TimeUnits1 |
| | 20486 | | { |
| | 20487 | | get { return _TimeUnits1; } |
| | 20488 | | set |
| | 20489 | | { |
| | 20490 | | if (value != _TimeUnits1) |
| | 20491 | | { |
| | 20492 | | _measurement = this[value, _TimeUnits2]; |
| | 20493 | | _TimeUnits1 = value; |
| | 20494 | | } |
| | 20495 | | } |
| | 20496 | | } |
| | 20497 | |
|
| | 20498 | | /// <summary>The #2 component of this measurements units.</summary> |
| | 20499 | | public Time.Units TimeUnits2 |
| | 20500 | | { |
| | 20501 | | get { return _TimeUnits2; } |
| | 20502 | | set |
| | 20503 | | { |
| | 20504 | | if (value != _TimeUnits2) |
| | 20505 | | { |
| | 20506 | | _measurement = this[_TimeUnits1, value]; |
| | 20507 | | _TimeUnits2 = value; |
| | 20508 | | } |
| | 20509 | | } |
| | 20510 | | } |
| | 20511 | |
|
| | 20512 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 20513 | | /// <param name="units">The units to get the measurement in.</param> |
| | 20514 | | /// <returns>The measurement value in the specified units.</returns> |
| | 20515 | | public T this[MeasurementUnitsSyntaxTypes.TimeAreaBaseUnits units] |
| | 20516 | | { |
| | 20517 | | get { return this[units._TimeUnits1, units._TimeUnits2]; } |
| | 20518 | | } |
| | 20519 | |
|
| | 20520 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 20521 | | /// <param name="TimeUnits1">The #1 component of this measurements units.</param> |
| | 20522 | | /// <param name="TimeUnits2">The #2 component of this measurements units.</param> |
| | 20523 | | /// <returns>The measurement value in the specified units.</returns> |
| | 20524 | | public T this[Time.Units TimeUnits1, Time.Units TimeUnits2] |
| | 20525 | | { |
| | 20526 | | get |
| | 20527 | | { |
| | 20528 | | T measurement = _measurement; |
| | 20529 | | if (TimeUnits1 != _TimeUnits1) |
| | 20530 | | { |
| | 20531 | | measurement = Time<T>.Table[(int)_TimeUnits1][(int)TimeUnits1](measurement); |
| | 20532 | | //if (TimeUnits1 < _TimeUnits1) |
| | 20533 | | //{ |
| | 20534 | | // measurement = Time<T>.Table[(int)_TimeUnits1][(int)TimeUnits1](measurement); |
| | 20535 | | //} |
| | 20536 | | //else |
| | 20537 | | //{ |
| | 20538 | | // measurement = Time<T>.Table[(int)TimeUnits1][(int)_TimeUnits1](measurement); |
| | 20539 | | //} |
| | 20540 | | } |
| | 20541 | | if (TimeUnits2 != _TimeUnits2) |
| | 20542 | | { |
| | 20543 | | measurement = Time<T>.Table[(int)_TimeUnits2][(int)TimeUnits2](measurement); |
| | 20544 | | //if (TimeUnits2 < _TimeUnits2) |
| | 20545 | | //{ |
| | 20546 | | // measurement = Time<T>.Table[(int)_TimeUnits2][(int)TimeUnits2](measurement); |
| | 20547 | | //} |
| | 20548 | | //else |
| | 20549 | | //{ |
| | 20550 | | // measurement = Time<T>.Table[(int)TimeUnits2][(int)_TimeUnits2](measurement); |
| | 20551 | | //} |
| | 20552 | | } |
| | 20553 | | return measurement; |
| | 20554 | | } |
| | 20555 | | } |
| | 20556 | |
|
| | 20557 | | #endregion |
| | 20558 | |
|
| | 20559 | | #region Casting Operators |
| | 20560 | |
|
| | 20561 | | /// <summary>Converts a ValueTuple to a TimeArea measurement.</summary> |
| | 20562 | | /// <param name="valueTuple">The ValueTuple to converted into a TimeArea measurement.</param> |
| | 20563 | | public static implicit operator TimeArea<T>((T, MeasurementUnitsSyntaxTypes.TimeAreaBaseUnits) valueTuple) |
| | 20564 | | { |
| | 20565 | | return new TimeArea<T>(valueTuple.Item1, valueTuple.Item2); |
| | 20566 | | } |
| | 20567 | |
|
| | 20568 | | #endregion |
| | 20569 | |
|
| | 20570 | | #region Mathematics |
| | 20571 | |
|
| | 20572 | | #region Bases |
| | 20573 | |
|
| | 20574 | | internal static TimeArea<T> MathBase(TimeArea<T> a, T b, Func<T, T, T> func) |
| | 20575 | | { |
| | 20576 | | return new TimeArea<T>(func(a._measurement, b) |
| | 20577 | | , a._TimeUnits1 |
| | 20578 | | , a._TimeUnits2 |
| | 20579 | | ); |
| | 20580 | | } |
| | 20581 | |
|
| | 20582 | | internal static TimeArea<T> MathBase(TimeArea<T> a, TimeArea<T> b, Func<T, T, T> func) |
| | 20583 | | { |
| | 20584 | | Time.Units TimeUnits1 = a._TimeUnits1 <= b._TimeUnits1 ? a._TimeUnits1 : b._TimeUnits1; |
| | 20585 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 20586 | | T A = a[TimeUnits1, TimeUnits2]; |
| | 20587 | | T B = b[TimeUnits1, TimeUnits2]; |
| | 20588 | | T C = func(A, B); |
| | 20589 | | return new TimeArea<T>(C, TimeUnits1, TimeUnits2); |
| | 20590 | | } |
| | 20591 | |
|
| | 20592 | | internal static bool LogicBase(TimeArea<T> a, TimeArea<T> b, Func<T, T, bool> func) |
| | 20593 | | { |
| | 20594 | | Time.Units TimeUnits1 = a._TimeUnits1 <= b._TimeUnits1 ? a._TimeUnits1 : b._TimeUnits1; |
| | 20595 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 20596 | | T A = a[TimeUnits1, TimeUnits2]; |
| | 20597 | | T B = b[TimeUnits1, TimeUnits2]; |
| | 20598 | | return func(A, B); |
| | 20599 | | } |
| | 20600 | |
|
| | 20601 | | #endregion |
| | 20602 | |
|
| | 20603 | | #region Add |
| | 20604 | |
|
| | 20605 | | /// <summary>Adds two TimeArea measurements.</summary> |
| | 20606 | | /// <param name="a">The first operand of the addition.</param> |
| | 20607 | | /// <param name="b">The second operand of the addition.</param> |
| | 20608 | | /// <returns>The result of the addition operation.</returns> |
| | 20609 | | public static TimeArea<T> Add(TimeArea<T> a, TimeArea<T> b) |
| | 20610 | | { |
| | 20611 | | return MathBase(a, b, Statics.Addition); |
| | 20612 | | } |
| | 20613 | |
|
| | 20614 | | /// <summary>Adds two TimeArea measurements.</summary> |
| | 20615 | | /// <param name="a">The first operand of the addition.</param> |
| | 20616 | | /// <param name="b">The second operand of the addition.</param> |
| | 20617 | | /// <returns>The result of the addition operation.</returns> |
| | 20618 | | public static TimeArea<T> operator +(TimeArea<T> a, TimeArea<T> b) |
| | 20619 | | { |
| | 20620 | | return Add(a, b); |
| | 20621 | | } |
| | 20622 | |
|
| | 20623 | | /// <summary>Adds two TimeArea measurements.</summary> |
| | 20624 | | /// <param name="b">The second operand of the addition.</param> |
| | 20625 | | /// <returns>The result of the addition operation.</returns> |
| | 20626 | | public TimeArea<T> Add(TimeArea<T> b) |
| | 20627 | | { |
| | 20628 | | return this + b; |
| | 20629 | | } |
| | 20630 | |
|
| | 20631 | | #endregion |
| | 20632 | |
|
| | 20633 | | #region Subtract |
| | 20634 | |
|
| | 20635 | | /// <summary>Subtracts two TimeArea measurements.</summary> |
| | 20636 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 20637 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 20638 | | /// <returns>The result of the subtraction.</returns> |
| | 20639 | | public static TimeArea<T> Subtract(TimeArea<T> a, TimeArea<T> b) |
| | 20640 | | { |
| | 20641 | | return MathBase(a, b, Statics.Subtraction); |
| | 20642 | | } |
| | 20643 | |
|
| | 20644 | | /// <summary>Subtracts two TimeArea measurements.</summary> |
| | 20645 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 20646 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 20647 | | /// <returns>The result of the subtraction.</returns> |
| | 20648 | | public static TimeArea<T> operator -(TimeArea<T> a, TimeArea<T> b) |
| | 20649 | | { |
| | 20650 | | return Subtract(a, b); |
| | 20651 | | } |
| | 20652 | |
|
| | 20653 | | /// <summary>Subtracts two TimeArea measurements.</summary> |
| | 20654 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 20655 | | /// <returns>The result of the subtraction.</returns> |
| | 20656 | | public TimeArea<T> Subtract(TimeArea<T> b) |
| | 20657 | | { |
| | 20658 | | return this - b; |
| | 20659 | | } |
| | 20660 | |
|
| | 20661 | | #endregion |
| | 20662 | |
|
| | 20663 | | #region Multiply |
| | 20664 | |
|
| | 20665 | | /// <summary>Multiplies an TimeArea by a scalar numeric value.</summary> |
| | 20666 | | /// <param name="a">The TimeArea measurement to multiply.</param> |
| | 20667 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 20668 | | /// <returns>The result of the multiplication.</returns> |
| | 20669 | | public static TimeArea<T> Multiply(TimeArea<T> a, T b) |
| | 20670 | | { |
| | 20671 | | return MathBase(a, b, Statics.Multiplication); |
| | 20672 | | } |
| | 20673 | |
|
| | 20674 | | /// <summary>Multiplies an TimeArea by a scalar numeric value.</summary> |
| | 20675 | | /// <param name="a">The TimeArea measurement to multiply.</param> |
| | 20676 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 20677 | | /// <returns>The result of the multiplication.</returns> |
| | 20678 | | public static TimeArea<T> Multiply(T b, TimeArea<T> a) |
| | 20679 | | { |
| | 20680 | | return Multiply(a, b); |
| | 20681 | | } |
| | 20682 | |
|
| | 20683 | | /// <summary>Multiplies an TimeArea by a scalar numeric value.</summary> |
| | 20684 | | /// <param name="a">The TimeArea measurement to multiply.</param> |
| | 20685 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 20686 | | /// <returns>The result of the multiplication.</returns> |
| | 20687 | | public static TimeArea<T> operator *(TimeArea<T> a, T b) |
| | 20688 | | { |
| | 20689 | | return Multiply(a, b); |
| | 20690 | | } |
| | 20691 | |
|
| | 20692 | | /// <summary>Multiplies an TimeArea by a scalar numeric value.</summary> |
| | 20693 | | /// <param name="a">The TimeArea measurement to multiply.</param> |
| | 20694 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 20695 | | /// <returns>The result of the multiplication.</returns> |
| | 20696 | | public static TimeArea<T> operator *(T b, TimeArea<T> a) |
| | 20697 | | { |
| | 20698 | | return Multiply(b, a); |
| | 20699 | | } |
| | 20700 | |
|
| | 20701 | | /// <summary>Multiplies an TimeArea by a scalar numeric value.</summary> |
| | 20702 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 20703 | | /// <returns>The result of the multiplication.</returns> |
| | 20704 | | public TimeArea<T> Add(T b) |
| | 20705 | | { |
| | 20706 | | return this * b; |
| | 20707 | | } |
| | 20708 | |
|
| | 20709 | | #region TimeArea<T> * Acceleration<T> = Length<T> |
| | 20710 | |
|
| | 20711 | | /// <summary>Mulitplies TimeArea by Acceleration resulting in Length.</summary> |
| | 20712 | | /// <param name="a">The TimeArea to be multiplied.</param> |
| | 20713 | | /// <param name="b">The Acceleration to multiply by.</param> |
| | 20714 | | /// <returns>The Length result of the multiplication.</returns> |
| | 20715 | | public static Length<T> Multiply(TimeArea<T> a, Acceleration<T> b) |
| | 20716 | | { |
| | 20717 | | Time.Units TimeUnits1 = a._TimeUnits1 <= b._TimeUnits2 ? a._TimeUnits1 : b._TimeUnits2; |
| | 20718 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits3 ? a._TimeUnits2 : b._TimeUnits3; |
| | 20719 | |
|
| | 20720 | | T A = a[TimeUnits1, TimeUnits2]; |
| | 20721 | | T B = b[b._LengthUnits1, TimeUnits1, TimeUnits2]; |
| | 20722 | | T C = Statics.Multiplication(A, B); |
| | 20723 | |
|
| | 20724 | | return new Length<T>(C |
| | 20725 | | , b._LengthUnits1 |
| | 20726 | | ); |
| | 20727 | | } |
| | 20728 | |
|
| | 20729 | | /// <summary>Mulitplies TimeArea by Acceleration resulting in Length.</summary> |
| | 20730 | | /// <param name="a">The TimeArea to be multiplied.</param> |
| | 20731 | | /// <param name="b">The Acceleration to multiply by.</param> |
| | 20732 | | /// <returns>The Length result of the multiplication.</returns> |
| | 20733 | | public static Length<T> operator *(TimeArea<T> a, Acceleration<T> b) |
| | 20734 | | { |
| | 20735 | | return Multiply(a, b); |
| | 20736 | | } |
| | 20737 | |
|
| | 20738 | | /// <summary>Mulitplies TimeArea by Acceleration resulting in Length.</summary> |
| | 20739 | | /// <param name="b">The Acceleration to multiply by.</param> |
| | 20740 | | /// <returns>The Length result of the multiplication.</returns> |
| | 20741 | | public Length<T> Multiply(Acceleration<T> b) |
| | 20742 | | { |
| | 20743 | | return this * b; |
| | 20744 | | } |
| | 20745 | |
|
| | 20746 | | #endregion |
| | 20747 | |
|
| | 20748 | | #region TimeArea<T> * AngularAcceleration<T> = Angle<T> |
| | 20749 | |
|
| | 20750 | | /// <summary>Mulitplies TimeArea by AngularAcceleration resulting in Angle.</summary> |
| | 20751 | | /// <param name="a">The TimeArea to be multiplied.</param> |
| | 20752 | | /// <param name="b">The AngularAcceleration to multiply by.</param> |
| | 20753 | | /// <returns>The Angle result of the multiplication.</returns> |
| | 20754 | | public static Angle<T> Multiply(TimeArea<T> a, AngularAcceleration<T> b) |
| | 20755 | | { |
| | 20756 | | Time.Units TimeUnits1 = a._TimeUnits1 <= b._TimeUnits2 ? a._TimeUnits1 : b._TimeUnits2; |
| | 20757 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits3 ? a._TimeUnits2 : b._TimeUnits3; |
| | 20758 | |
|
| | 20759 | | T A = a[TimeUnits1, TimeUnits2]; |
| | 20760 | | T B = b[b._AngleUnits1, TimeUnits1, TimeUnits2]; |
| | 20761 | | T C = Statics.Multiplication(A, B); |
| | 20762 | |
|
| | 20763 | | return new Angle<T>(C |
| | 20764 | | , b._AngleUnits1 |
| | 20765 | | ); |
| | 20766 | | } |
| | 20767 | |
|
| | 20768 | | /// <summary>Mulitplies TimeArea by AngularAcceleration resulting in Angle.</summary> |
| | 20769 | | /// <param name="a">The TimeArea to be multiplied.</param> |
| | 20770 | | /// <param name="b">The AngularAcceleration to multiply by.</param> |
| | 20771 | | /// <returns>The Angle result of the multiplication.</returns> |
| | 20772 | | public static Angle<T> operator *(TimeArea<T> a, AngularAcceleration<T> b) |
| | 20773 | | { |
| | 20774 | | return Multiply(a, b); |
| | 20775 | | } |
| | 20776 | |
|
| | 20777 | | /// <summary>Mulitplies TimeArea by AngularAcceleration resulting in Angle.</summary> |
| | 20778 | | /// <param name="b">The AngularAcceleration to multiply by.</param> |
| | 20779 | | /// <returns>The Angle result of the multiplication.</returns> |
| | 20780 | | public Angle<T> Multiply(AngularAcceleration<T> b) |
| | 20781 | | { |
| | 20782 | | return this * b; |
| | 20783 | | } |
| | 20784 | |
|
| | 20785 | | #endregion |
| | 20786 | |
|
| | 20787 | | #region TimeArea<T> * Force<T> = LinearMass<T> |
| | 20788 | |
|
| | 20789 | | /// <summary>Mulitplies TimeArea by Force resulting in LinearMass.</summary> |
| | 20790 | | /// <param name="a">The TimeArea to be multiplied.</param> |
| | 20791 | | /// <param name="b">The Force to multiply by.</param> |
| | 20792 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 20793 | | public static LinearMass<T> Multiply(TimeArea<T> a, Force<T> b) |
| | 20794 | | { |
| | 20795 | | Time.Units TimeUnits1 = a._TimeUnits1 <= b._TimeUnits3 ? a._TimeUnits1 : b._TimeUnits3; |
| | 20796 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits4 ? a._TimeUnits2 : b._TimeUnits4; |
| | 20797 | |
|
| | 20798 | | T A = a[TimeUnits1, TimeUnits2]; |
| | 20799 | | T B = b[b._MassUnits1, b._LengthUnits2, TimeUnits1, TimeUnits2]; |
| | 20800 | | T C = Statics.Multiplication(A, B); |
| | 20801 | |
|
| | 20802 | | return new LinearMass<T>(C |
| | 20803 | | , b._MassUnits1 |
| | 20804 | | , b._LengthUnits2 |
| | 20805 | | ); |
| | 20806 | | } |
| | 20807 | |
|
| | 20808 | | /// <summary>Mulitplies TimeArea by Force resulting in LinearMass.</summary> |
| | 20809 | | /// <param name="a">The TimeArea to be multiplied.</param> |
| | 20810 | | /// <param name="b">The Force to multiply by.</param> |
| | 20811 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 20812 | | public static LinearMass<T> operator *(TimeArea<T> a, Force<T> b) |
| | 20813 | | { |
| | 20814 | | return Multiply(a, b); |
| | 20815 | | } |
| | 20816 | |
|
| | 20817 | | /// <summary>Mulitplies TimeArea by Force resulting in LinearMass.</summary> |
| | 20818 | | /// <param name="b">The Force to multiply by.</param> |
| | 20819 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 20820 | | public LinearMass<T> Multiply(Force<T> b) |
| | 20821 | | { |
| | 20822 | | return this * b; |
| | 20823 | | } |
| | 20824 | |
|
| | 20825 | | #endregion |
| | 20826 | |
|
| | 20827 | | #region TimeArea<T> * Pressure<T> = LinearDensity<T> |
| | 20828 | |
|
| | 20829 | | /// <summary>Mulitplies TimeArea by Pressure resulting in LinearDensity.</summary> |
| | 20830 | | /// <param name="a">The TimeArea to be multiplied.</param> |
| | 20831 | | /// <param name="b">The Pressure to multiply by.</param> |
| | 20832 | | /// <returns>The LinearDensity result of the multiplication.</returns> |
| | 20833 | | public static LinearDensity<T> Multiply(TimeArea<T> a, Pressure<T> b) |
| | 20834 | | { |
| | 20835 | | Time.Units TimeUnits1 = a._TimeUnits1 <= b._TimeUnits3 ? a._TimeUnits1 : b._TimeUnits3; |
| | 20836 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits4 ? a._TimeUnits2 : b._TimeUnits4; |
| | 20837 | |
|
| | 20838 | | T A = a[TimeUnits1, TimeUnits2]; |
| | 20839 | | T B = b[b._MassUnits1, b._LengthUnits2, TimeUnits1, TimeUnits2]; |
| | 20840 | | T C = Statics.Multiplication(A, B); |
| | 20841 | |
|
| | 20842 | | return new LinearDensity<T>(C |
| | 20843 | | , b._MassUnits1 |
| | 20844 | | , b._LengthUnits2 |
| | 20845 | | ); |
| | 20846 | | } |
| | 20847 | |
|
| | 20848 | | /// <summary>Mulitplies TimeArea by Pressure resulting in LinearDensity.</summary> |
| | 20849 | | /// <param name="a">The TimeArea to be multiplied.</param> |
| | 20850 | | /// <param name="b">The Pressure to multiply by.</param> |
| | 20851 | | /// <returns>The LinearDensity result of the multiplication.</returns> |
| | 20852 | | public static LinearDensity<T> operator *(TimeArea<T> a, Pressure<T> b) |
| | 20853 | | { |
| | 20854 | | return Multiply(a, b); |
| | 20855 | | } |
| | 20856 | |
|
| | 20857 | | /// <summary>Mulitplies TimeArea by Pressure resulting in LinearDensity.</summary> |
| | 20858 | | /// <param name="b">The Pressure to multiply by.</param> |
| | 20859 | | /// <returns>The LinearDensity result of the multiplication.</returns> |
| | 20860 | | public LinearDensity<T> Multiply(Pressure<T> b) |
| | 20861 | | { |
| | 20862 | | return this * b; |
| | 20863 | | } |
| | 20864 | |
|
| | 20865 | | #endregion |
| | 20866 | |
|
| | 20867 | | #endregion |
| | 20868 | |
|
| | 20869 | | #region Divide |
| | 20870 | |
|
| | 20871 | | /// <summary>Divides an TimeArea measurement by another TimeArea measurement resulting in a scalar numeric value.</s |
| | 20872 | | /// <param name="a">The first operand of the division operation.</param> |
| | 20873 | | /// <param name="b">The second operand of the division operation.</param> |
| | 20874 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 20875 | | public static T Divide(TimeArea<T> a, TimeArea<T> b) |
| | 20876 | | { |
| | 20877 | | Time.Units TimeUnits1 = a._TimeUnits1 <= b._TimeUnits1 ? a._TimeUnits1 : b._TimeUnits1; |
| | 20878 | | Time.Units TimeUnits2 = a._TimeUnits2 <= b._TimeUnits2 ? a._TimeUnits2 : b._TimeUnits2; |
| | 20879 | | T A = a[TimeUnits1, TimeUnits2]; |
| | 20880 | | T B = b[TimeUnits1, TimeUnits2]; |
| | 20881 | | return Statics.Division(A, B); |
| | 20882 | | } |
| | 20883 | |
|
| | 20884 | | /// <summary>Divides this TimeArea measurement by a numaric scalar value.</summary> |
| | 20885 | | /// <param name="a">The TimeArea measurement to divide.</param> |
| | 20886 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 20887 | | /// <returns>The result of the division.</returns> |
| | 20888 | | public static TimeArea<T> Divide(TimeArea<T> a, T b) |
| | 20889 | | { |
| | 20890 | | return MathBase(a, b, Statics.Division); |
| | 20891 | | } |
| | 20892 | |
|
| | 20893 | | /// <summary>Divides this TimeArea measurement by a numaric scalar value.</summary> |
| | 20894 | | /// <param name="a">The TimeArea measurement to divide.</param> |
| | 20895 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 20896 | | /// <returns>The result of the division.</returns> |
| | 20897 | | public static TimeArea<T> operator /(TimeArea<T> a, T b) |
| | 20898 | | { |
| | 20899 | | return Divide(a, b); |
| | 20900 | | } |
| | 20901 | |
|
| | 20902 | | /// <summary>Divides this TimeArea measurement by a numaric scalar value.</summary> |
| | 20903 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 20904 | | /// <returns>The result of the division.</returns> |
| | 20905 | | public TimeArea<T> Divide(T b) |
| | 20906 | | { |
| | 20907 | | return this / b; |
| | 20908 | | } |
| | 20909 | |
|
| | 20910 | | /// <summary>Divides an TimeArea measurement by another TimeArea measurement resulting in a scalar numeric value.</s |
| | 20911 | | /// <param name="a">The first operand of the division operation.</param> |
| | 20912 | | /// <param name="b">The second operand of the division operation.</param> |
| | 20913 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 20914 | | public static T operator /(TimeArea<T> a, TimeArea<T> b) |
| | 20915 | | { |
| | 20916 | | return Divide(a, b); |
| | 20917 | | } |
| | 20918 | |
|
| | 20919 | | /// <summary>Divides an TimeArea measurement by another TimeArea measurement resulting in a scalar numeric value.</s |
| | 20920 | | /// <param name="b">The second operand of the division operation.</param> |
| | 20921 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 20922 | | public T Divide(TimeArea<T> b) |
| | 20923 | | { |
| | 20924 | | return this / b; |
| | 20925 | | } |
| | 20926 | |
|
| | 20927 | |
|
| | 20928 | | #region TimeArea<T> / Time<T> = Time<T> |
| | 20929 | |
|
| | 20930 | | /// <summary>Divides TimeArea by Time resulting in Time.</summary> |
| | 20931 | | /// <param name="a">The TimeArea to be divided.</param> |
| | 20932 | | /// <param name="b">The Time to divide by.</param> |
| | 20933 | | /// <returns>The Time result of the division.</returns> |
| | 20934 | | public static Time<T> Divide(TimeArea<T> a, Time<T> b) |
| | 20935 | | { |
| | 20936 | | Time.Units TimeUnits1 = a._TimeUnits1 <= b._TimeUnits1 ? a._TimeUnits1 : b._TimeUnits1; |
| | 20937 | |
|
| | 20938 | | T A = a[TimeUnits1, a._TimeUnits2]; |
| | 20939 | | T B = b[TimeUnits1]; |
| | 20940 | | T C = Statics.Division(A, B); |
| | 20941 | |
|
| | 20942 | | return new Time<T>(C |
| | 20943 | | , a._TimeUnits2 |
| | 20944 | | ); |
| | 20945 | | } |
| | 20946 | |
|
| | 20947 | | /// <summary>Divides TimeArea by Time resulting in Time.</summary> |
| | 20948 | | /// <param name="a">The TimeArea to be divided.</param> |
| | 20949 | | /// <param name="b">The Time to divide by.</param> |
| | 20950 | | /// <returns>The Time result of the division.</returns> |
| | 20951 | | public static Time<T> operator /(TimeArea<T> a, Time<T> b) |
| | 20952 | | { |
| | 20953 | | return Divide(a, b); |
| | 20954 | | } |
| | 20955 | |
|
| | 20956 | | /// <summary>Divides TimeArea by Time resulting in Time.</summary> |
| | 20957 | | /// <param name="b">The Time to divide by.</param> |
| | 20958 | | /// <returns>The Time result of the division.</returns> |
| | 20959 | | public Time<T> Divide(Time<T> b) |
| | 20960 | | { |
| | 20961 | | return this / b; |
| | 20962 | | } |
| | 20963 | |
|
| | 20964 | | #endregion |
| | 20965 | |
|
| | 20966 | | #endregion |
| | 20967 | |
|
| | 20968 | | #region LessThan |
| | 20969 | |
|
| | 20970 | | /// <summary>Determines if an TimeArea measurement is less than another TimeArea measurement.</summary> |
| | 20971 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 20972 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 20973 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 20974 | | public static bool LessThan(TimeArea<T> a, TimeArea<T> b) |
| | 20975 | | { |
| | 20976 | | return LogicBase(a, b, Statics.LessThan); |
| | 20977 | | } |
| | 20978 | |
|
| | 20979 | | /// <summary>Determines if an TimeArea measurement is less than another TimeArea measurement.</summary> |
| | 20980 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 20981 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 20982 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 20983 | | public static bool operator <(TimeArea<T> a, TimeArea<T> b) |
| | 20984 | | { |
| | 20985 | | return LessThan(a, b); |
| | 20986 | | } |
| | 20987 | |
|
| | 20988 | | /// <summary>Determines if an TimeArea measurement is less than another TimeArea measurement.</summary> |
| | 20989 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 20990 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 20991 | | public bool LessThan(TimeArea<T> b) |
| | 20992 | | { |
| | 20993 | | return this < b; |
| | 20994 | | } |
| | 20995 | |
|
| | 20996 | | #endregion |
| | 20997 | |
|
| | 20998 | | #region GreaterThan |
| | 20999 | |
|
| | 21000 | | /// <summary>Determines if an TimeArea measurement is greater than another TimeArea measurement.</summary> |
| | 21001 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 21002 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 21003 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 21004 | | public static bool GreaterThan(TimeArea<T> a, TimeArea<T> b) |
| | 21005 | | { |
| | 21006 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 21007 | | } |
| | 21008 | |
|
| | 21009 | | /// <summary>Determines if an TimeArea measurement is greater than another TimeArea measurement.</summary> |
| | 21010 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 21011 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 21012 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 21013 | | public static bool operator >(TimeArea<T> a, TimeArea<T> b) |
| | 21014 | | { |
| | 21015 | | return GreaterThan(a, b); |
| | 21016 | | } |
| | 21017 | |
|
| | 21018 | | /// <summary>Determines if an TimeArea measurement is greater than another TimeArea measurement.</summary> |
| | 21019 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 21020 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 21021 | | public bool GreaterThan(TimeArea<T> b) |
| | 21022 | | { |
| | 21023 | | return this > b; |
| | 21024 | | } |
| | 21025 | |
|
| | 21026 | | #endregion |
| | 21027 | |
|
| | 21028 | | #region LessThanOrEqual |
| | 21029 | |
|
| | 21030 | | /// <summary>Determines if an TimeArea measurement is less than or equal to another TimeArea measurement.</summary> |
| | 21031 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 21032 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 21033 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 21034 | | public static bool LessThanOrEqual(TimeArea<T> a, TimeArea<T> b) |
| | 21035 | | { |
| | 21036 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 21037 | | } |
| | 21038 | |
|
| | 21039 | | /// <summary>Determines if an TimeArea measurement is less than or equal to another TimeArea measurement.</summary> |
| | 21040 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 21041 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 21042 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 21043 | | public static bool operator <=(TimeArea<T> a, TimeArea<T> b) |
| | 21044 | | { |
| | 21045 | | return LessThanOrEqual(a, b); |
| | 21046 | | } |
| | 21047 | |
|
| | 21048 | | /// <summary>Determines if an TimeArea measurement is less than or equal to another TimeArea measurement.</summary> |
| | 21049 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 21050 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 21051 | | public bool LessThanOrEqual(TimeArea<T> b) |
| | 21052 | | { |
| | 21053 | | return this <= b; |
| | 21054 | | } |
| | 21055 | |
|
| | 21056 | | #endregion |
| | 21057 | |
|
| | 21058 | | #region GreaterThanOrEqual |
| | 21059 | |
|
| | 21060 | | /// <summary>Determines if an TimeArea measurement is greater than or equal to another TimeArea measurement.</summar |
| | 21061 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 21062 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 21063 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 21064 | | public static bool GreaterThanOrEqual(TimeArea<T> a, TimeArea<T> b) |
| | 21065 | | { |
| | 21066 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 21067 | | } |
| | 21068 | |
|
| | 21069 | | /// <summary>Determines if an TimeArea measurement is greater than or equal to another TimeArea measurement.</summar |
| | 21070 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 21071 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 21072 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 21073 | | public static bool operator >=(TimeArea<T> a, TimeArea<T> b) |
| | 21074 | | { |
| | 21075 | | return GreaterThanOrEqual(a, b); |
| | 21076 | | } |
| | 21077 | |
|
| | 21078 | | /// <summary>Determines if an TimeArea measurement is greater than or equal to another TimeArea measurement.</summar |
| | 21079 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 21080 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 21081 | | public bool GreaterThanOrEqual(TimeArea<T> b) |
| | 21082 | | { |
| | 21083 | | return this >= b; |
| | 21084 | | } |
| | 21085 | |
|
| | 21086 | | #endregion |
| | 21087 | |
|
| | 21088 | | #region Equal |
| | 21089 | |
|
| | 21090 | | /// <summary>Determines if an TimeArea measurement is equal to another TimeArea measurement.</summary> |
| | 21091 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 21092 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 21093 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 21094 | | public static bool Equal(TimeArea<T> a, TimeArea<T> b) |
| | 21095 | | { |
| | 21096 | | return LogicBase(a, b, Statics.Equate); |
| | 21097 | | } |
| | 21098 | |
|
| | 21099 | | /// <summary>Determines if an TimeArea measurement is equal to another TimeArea measurement.</summary> |
| | 21100 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 21101 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 21102 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 21103 | | public static bool operator ==(TimeArea<T> a, TimeArea<T> b) |
| | 21104 | | { |
| | 21105 | | return Equal(a, b); |
| | 21106 | | } |
| | 21107 | |
|
| | 21108 | | /// <summary>Determines if an TimeArea measurement is equal to another TimeArea measurement.</summary> |
| | 21109 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 21110 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 21111 | | public bool Equal(TimeArea<T> b) |
| | 21112 | | { |
| | 21113 | | return this == b; |
| | 21114 | | } |
| | 21115 | |
|
| | 21116 | | #endregion |
| | 21117 | |
|
| | 21118 | | #region NotEqual |
| | 21119 | |
|
| | 21120 | | /// <summary>Determines if an TimeArea measurement is not equal to another TimeArea measurement.</summary> |
| | 21121 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 21122 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 21123 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 21124 | | public static bool NotEqual(TimeArea<T> a, TimeArea<T> b) |
| | 21125 | | { |
| | 21126 | | return LogicBase(a, b, Statics.Inequate); |
| | 21127 | | } |
| | 21128 | |
|
| | 21129 | | /// <summary>Determines if an TimeArea measurement is not equal to another TimeArea measurement.</summary> |
| | 21130 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 21131 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 21132 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 21133 | | public static bool operator !=(TimeArea<T> a, TimeArea<T> b) |
| | 21134 | | { |
| | 21135 | | return NotEqual(a, b); |
| | 21136 | | } |
| | 21137 | |
|
| | 21138 | | /// <summary>Determines if an TimeArea measurement is not equal to another TimeArea measurement.</summary> |
| | 21139 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 21140 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 21141 | | public bool NotEqual(TimeArea<T> b) |
| | 21142 | | { |
| | 21143 | | return this != b; |
| | 21144 | | } |
| | 21145 | |
|
| | 21146 | | #endregion |
| | 21147 | |
|
| | 21148 | | #endregion |
| | 21149 | |
|
| | 21150 | | #region Overrides |
| | 21151 | |
|
| | 21152 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 21153 | | /// <param name="obj">The object to check for equality with.</param> |
| | 21154 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 21155 | | public override bool Equals(object obj) |
| | 21156 | | { |
| | 21157 | | if (obj is TimeArea<T>) |
| | 21158 | | { |
| | 21159 | | return this == (TimeArea<T>)obj; |
| | 21160 | | } |
| | 21161 | | return false; |
| | 21162 | | } |
| | 21163 | |
|
| | 21164 | | /// <summary>Converts the TimeArea measurement to a string represenation.</summary> |
| | 21165 | | /// <returns>The string representation of the measurement.</returns> |
| | 21166 | | public override string ToString() |
| | 21167 | | { |
| | 21168 | | return _measurement + " " + |
| | 21169 | | _TimeUnits1 + "*" + _TimeUnits2 |
| | 21170 | |
|
| | 21171 | | ; |
| | 21172 | | } |
| | 21173 | |
|
| | 21174 | | /// <summary>Base hashing function for TimeArea measurements.</summary> |
| | 21175 | | /// <returns>Computed hash code for this instance.</returns> |
| | 21176 | | public override int GetHashCode() => Hash(_measurement); |
| | 21177 | |
|
| | 21178 | | #endregion |
| | 21179 | | } |
| | 21180 | |
|
| | 21181 | | #endregion |
| | 21182 | |
|
| | 21183 | | #region Volume |
| | 21184 | |
|
| | 21185 | | internal static partial class ParsingFunctions |
| | 21186 | | { |
| | 21187 | | [Measurement.Parseable("Length*Length*Length")] |
| | 21188 | | public static object Volume<T>(T value, object[] units) |
| | 21189 | | { |
| | 21190 | | if (units.Length != 3) |
| | 21191 | | { |
| | 21192 | | throw new Exception("Bug in Towel. Invalid parameters to Volume Factory."); |
| | 21193 | | } |
| | 21194 | | if (!(units[0] is Length.Units)) |
| | 21195 | | { |
| | 21196 | | throw new Exception("Bug in Towel. Invalid parameters to Volume Factory."); |
| | 21197 | | } |
| | 21198 | | if (!(units[1] is Length.Units)) |
| | 21199 | | { |
| | 21200 | | throw new Exception("Bug in Towel. Invalid parameters to Volume Factory."); |
| | 21201 | | } |
| | 21202 | | if (!(units[2] is Length.Units)) |
| | 21203 | | { |
| | 21204 | | throw new Exception("Bug in Towel. Invalid parameters to Volume Factory."); |
| | 21205 | | } |
| | 21206 | | return new Volume<T>(value |
| | 21207 | | , (Length.Units)units[0] |
| | 21208 | | , (Length.Units)units[1] |
| | 21209 | | , (Length.Units)units[2] |
| | 21210 | | ); |
| | 21211 | | } |
| | 21212 | | } |
| | 21213 | |
|
| | 21214 | | /// <summary>Volume measurement with a value and the units.</summary> |
| | 21215 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 21216 | | public struct Volume<T> |
| | 21217 | | { |
| | 21218 | | internal T _measurement; |
| | 21219 | | internal Length.Units _LengthUnits1; |
| | 21220 | | internal Length.Units _LengthUnits2; |
| | 21221 | | internal Length.Units _LengthUnits3; |
| | 21222 | |
|
| | 21223 | | #region Statics |
| | 21224 | |
|
| | 21225 | | /// <summary>Converts a Volume measurement from units to another.</summary> |
| | 21226 | | /// <param name="value">The value to convert the units of.</param> |
| | 21227 | | /// <param name="fromLengthUnits1">The current units of the measurement.</param> |
| | 21228 | | /// <param name="fromLengthUnits2">The current units of the measurement.</param> |
| | 21229 | | /// <param name="fromLengthUnits3">The current units of the measurement.</param> |
| | 21230 | | /// <param name="toLengthUnits1">The desired units of the measurement.</param> |
| | 21231 | | /// <param name="toLengthUnits2">The desired units of the measurement.</param> |
| | 21232 | | /// <param name="toLengthUnits3">The desired units of the measurement.</param> |
| | 21233 | | /// <returns>The Volume measurement converted into the desired units.</returns> |
| | 21234 | | public static T Convert(T value |
| | 21235 | | , Length.Units fromLengthUnits1 |
| | 21236 | | , Length.Units fromLengthUnits2 |
| | 21237 | | , Length.Units fromLengthUnits3 |
| | 21238 | | , Length.Units toLengthUnits1 |
| | 21239 | | , Length.Units toLengthUnits2 |
| | 21240 | | , Length.Units toLengthUnits3 |
| | 21241 | | ) |
| | 21242 | | { |
| | 21243 | | Volume<T> measurement = new Volume<T>(value |
| | 21244 | | , fromLengthUnits1 |
| | 21245 | | , fromLengthUnits2 |
| | 21246 | | , fromLengthUnits3 |
| | 21247 | | ); |
| | 21248 | | return measurement[ |
| | 21249 | | toLengthUnits1 |
| | 21250 | | , toLengthUnits2 |
| | 21251 | | , toLengthUnits3 |
| | 21252 | | ]; |
| | 21253 | | } |
| | 21254 | |
|
| | 21255 | | /// <summary>Converts a Volume measurement from units to another.</summary> |
| | 21256 | | /// <param name="value">The value to convert the units of.</param> |
| | 21257 | | /// <param name="from">The current units of the measurement.</param> |
| | 21258 | | /// <param name="to">The desired units of the measurement.</param> |
| | 21259 | | /// <returns>The Volume measurement converted into the desired units.</returns> |
| | 21260 | | public static T Convert(T value, |
| | 21261 | | MeasurementUnitsSyntaxTypes.VolumeBaseUnits from, |
| | 21262 | | MeasurementUnitsSyntaxTypes.VolumeBaseUnits to) |
| | 21263 | | { |
| | 21264 | | return Convert(value |
| | 21265 | | , from._LengthUnits1 |
| | 21266 | | , from._LengthUnits2 |
| | 21267 | | , from._LengthUnits3 |
| | 21268 | | , to._LengthUnits1 |
| | 21269 | | , to._LengthUnits2 |
| | 21270 | | , to._LengthUnits3 |
| | 21271 | | ); |
| | 21272 | | } |
| | 21273 | |
|
| | 21274 | | /// <summary>Parses a Volume measurement string.</summary> |
| | 21275 | | /// <param name="string">The string to be parsed.</param> |
| | 21276 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 21277 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 21278 | | public static (bool Success, Volume<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value)> tryPar |
| | 21279 | |
|
| | 21280 | | #endregion |
| | 21281 | |
|
| | 21282 | | #region Constructors |
| | 21283 | |
|
| | 21284 | | /// <summary>Constructs an Volume with the measurement value and units.</summary> |
| | 21285 | | /// <param name="measurement">The measurement value of the Volume.</param> |
| | 21286 | | /// <param name="units">The units of the Volume.</param> |
| | 21287 | | public Volume(T measurement, MeasurementUnitsSyntaxTypes.VolumeBaseUnits units) : this(measurement |
| | 21288 | | , units._LengthUnits1 |
| | 21289 | | , units._LengthUnits2 |
| | 21290 | | , units._LengthUnits3 |
| | 21291 | | ) { } |
| | 21292 | |
|
| | 21293 | |
|
| | 21294 | | /// <summary>Constructs an Volume with the measurement value and units.</summary> |
| | 21295 | | /// <param name="measurement">The measurement value of the Volume.</param> |
| | 21296 | | /// <param name="LengthUnits1">The units of the Volume.</param> |
| | 21297 | | /// <param name="LengthUnits2">The units of the Volume.</param> |
| | 21298 | | /// <param name="LengthUnits3">The units of the Volume.</param> |
| | 21299 | | public Volume(T measurement |
| | 21300 | | , Length.Units LengthUnits1 |
| | 21301 | | , Length.Units LengthUnits2 |
| | 21302 | | , Length.Units LengthUnits3 |
| | 21303 | | ) |
| | 21304 | | { |
| | 21305 | | _measurement = measurement; |
| | 21306 | | _LengthUnits1 = LengthUnits1; |
| | 21307 | | _LengthUnits2 = LengthUnits2; |
| | 21308 | | _LengthUnits3 = LengthUnits3; |
| | 21309 | | } |
| | 21310 | |
|
| | 21311 | | #endregion |
| | 21312 | |
|
| | 21313 | | #region Properties |
| | 21314 | |
|
| | 21315 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 21316 | | public Length.Units LengthUnits1 |
| | 21317 | | { |
| | 21318 | | get { return _LengthUnits1; } |
| | 21319 | | set |
| | 21320 | | { |
| | 21321 | | if (value != _LengthUnits1) |
| | 21322 | | { |
| | 21323 | | _measurement = this[value, _LengthUnits2, _LengthUnits3]; |
| | 21324 | | _LengthUnits1 = value; |
| | 21325 | | } |
| | 21326 | | } |
| | 21327 | | } |
| | 21328 | |
|
| | 21329 | | /// <summary>The #2 component of this measurements units.</summary> |
| | 21330 | | public Length.Units LengthUnits2 |
| | 21331 | | { |
| | 21332 | | get { return _LengthUnits2; } |
| | 21333 | | set |
| | 21334 | | { |
| | 21335 | | if (value != _LengthUnits2) |
| | 21336 | | { |
| | 21337 | | _measurement = this[_LengthUnits1, value, _LengthUnits3]; |
| | 21338 | | _LengthUnits2 = value; |
| | 21339 | | } |
| | 21340 | | } |
| | 21341 | | } |
| | 21342 | |
|
| | 21343 | | /// <summary>The #3 component of this measurements units.</summary> |
| | 21344 | | public Length.Units LengthUnits3 |
| | 21345 | | { |
| | 21346 | | get { return _LengthUnits3; } |
| | 21347 | | set |
| | 21348 | | { |
| | 21349 | | if (value != _LengthUnits3) |
| | 21350 | | { |
| | 21351 | | _measurement = this[_LengthUnits1, _LengthUnits2, value]; |
| | 21352 | | _LengthUnits3 = value; |
| | 21353 | | } |
| | 21354 | | } |
| | 21355 | | } |
| | 21356 | |
|
| | 21357 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 21358 | | /// <param name="units">The units to get the measurement in.</param> |
| | 21359 | | /// <returns>The measurement value in the specified units.</returns> |
| | 21360 | | public T this[MeasurementUnitsSyntaxTypes.VolumeBaseUnits units] |
| | 21361 | | { |
| | 21362 | | get { return this[units._LengthUnits1, units._LengthUnits2, units._LengthUnits3]; } |
| | 21363 | | } |
| | 21364 | |
|
| | 21365 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 21366 | | /// <param name="LengthUnits1">The #1 component of this measurements units.</param> |
| | 21367 | | /// <param name="LengthUnits2">The #2 component of this measurements units.</param> |
| | 21368 | | /// <param name="LengthUnits3">The #3 component of this measurements units.</param> |
| | 21369 | | /// <returns>The measurement value in the specified units.</returns> |
| | 21370 | | public T this[Length.Units LengthUnits1, Length.Units LengthUnits2, Length.Units LengthUnits3] |
| | 21371 | | { |
| | 21372 | | get |
| | 21373 | | { |
| | 21374 | | T measurement = _measurement; |
| | 21375 | | if (LengthUnits1 != _LengthUnits1) |
| | 21376 | | { |
| | 21377 | | measurement = Length<T>.Table[(int)_LengthUnits1][(int)LengthUnits1](measurement); |
| | 21378 | | //if (LengthUnits1 < _LengthUnits1) |
| | 21379 | | //{ |
| | 21380 | | // measurement = Length<T>.Table[(int)_LengthUnits1][(int)LengthUnits1](measurement); |
| | 21381 | | //} |
| | 21382 | | //else |
| | 21383 | | //{ |
| | 21384 | | // measurement = Length<T>.Table[(int)LengthUnits1][(int)_LengthUnits1](measurement); |
| | 21385 | | //} |
| | 21386 | | } |
| | 21387 | | if (LengthUnits2 != _LengthUnits2) |
| | 21388 | | { |
| | 21389 | | measurement = Length<T>.Table[(int)_LengthUnits2][(int)LengthUnits2](measurement); |
| | 21390 | | //if (LengthUnits2 < _LengthUnits2) |
| | 21391 | | //{ |
| | 21392 | | // measurement = Length<T>.Table[(int)_LengthUnits2][(int)LengthUnits2](measurement); |
| | 21393 | | //} |
| | 21394 | | //else |
| | 21395 | | //{ |
| | 21396 | | // measurement = Length<T>.Table[(int)LengthUnits2][(int)_LengthUnits2](measurement); |
| | 21397 | | //} |
| | 21398 | | } |
| | 21399 | | if (LengthUnits3 != _LengthUnits3) |
| | 21400 | | { |
| | 21401 | | measurement = Length<T>.Table[(int)_LengthUnits3][(int)LengthUnits3](measurement); |
| | 21402 | | //if (LengthUnits3 < _LengthUnits3) |
| | 21403 | | //{ |
| | 21404 | | // measurement = Length<T>.Table[(int)_LengthUnits3][(int)LengthUnits3](measurement); |
| | 21405 | | //} |
| | 21406 | | //else |
| | 21407 | | //{ |
| | 21408 | | // measurement = Length<T>.Table[(int)LengthUnits3][(int)_LengthUnits3](measurement); |
| | 21409 | | //} |
| | 21410 | | } |
| | 21411 | | return measurement; |
| | 21412 | | } |
| | 21413 | | } |
| | 21414 | |
|
| | 21415 | | #endregion |
| | 21416 | |
|
| | 21417 | | #region Casting Operators |
| | 21418 | |
|
| | 21419 | | /// <summary>Converts a ValueTuple to a Volume measurement.</summary> |
| | 21420 | | /// <param name="valueTuple">The ValueTuple to converted into a Volume measurement.</param> |
| | 21421 | | public static implicit operator Volume<T>((T, MeasurementUnitsSyntaxTypes.VolumeBaseUnits) valueTuple) |
| | 21422 | | { |
| | 21423 | | return new Volume<T>(valueTuple.Item1, valueTuple.Item2); |
| | 21424 | | } |
| | 21425 | |
|
| | 21426 | | #endregion |
| | 21427 | |
|
| | 21428 | | #region Mathematics |
| | 21429 | |
|
| | 21430 | | #region Bases |
| | 21431 | |
|
| | 21432 | | internal static Volume<T> MathBase(Volume<T> a, T b, Func<T, T, T> func) |
| | 21433 | | { |
| | 21434 | | return new Volume<T>(func(a._measurement, b) |
| | 21435 | | , a._LengthUnits1 |
| | 21436 | | , a._LengthUnits2 |
| | 21437 | | , a._LengthUnits3 |
| | 21438 | | ); |
| | 21439 | | } |
| | 21440 | |
|
| | 21441 | | internal static Volume<T> MathBase(Volume<T> a, Volume<T> b, Func<T, T, T> func) |
| | 21442 | | { |
| | 21443 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 21444 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 21445 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits3 ? a._LengthUnits3 : b._LengthUnits3; |
| | 21446 | | T A = a[LengthUnits1, LengthUnits2, LengthUnits3]; |
| | 21447 | | T B = b[LengthUnits1, LengthUnits2, LengthUnits3]; |
| | 21448 | | T C = func(A, B); |
| | 21449 | | return new Volume<T>(C, LengthUnits1, LengthUnits2, LengthUnits3); |
| | 21450 | | } |
| | 21451 | |
|
| | 21452 | | internal static bool LogicBase(Volume<T> a, Volume<T> b, Func<T, T, bool> func) |
| | 21453 | | { |
| | 21454 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 21455 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 21456 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits3 ? a._LengthUnits3 : b._LengthUnits3; |
| | 21457 | | T A = a[LengthUnits1, LengthUnits2, LengthUnits3]; |
| | 21458 | | T B = b[LengthUnits1, LengthUnits2, LengthUnits3]; |
| | 21459 | | return func(A, B); |
| | 21460 | | } |
| | 21461 | |
|
| | 21462 | | #endregion |
| | 21463 | |
|
| | 21464 | | #region Add |
| | 21465 | |
|
| | 21466 | | /// <summary>Adds two Volume measurements.</summary> |
| | 21467 | | /// <param name="a">The first operand of the addition.</param> |
| | 21468 | | /// <param name="b">The second operand of the addition.</param> |
| | 21469 | | /// <returns>The result of the addition operation.</returns> |
| | 21470 | | public static Volume<T> Add(Volume<T> a, Volume<T> b) |
| | 21471 | | { |
| | 21472 | | return MathBase(a, b, Statics.Addition); |
| | 21473 | | } |
| | 21474 | |
|
| | 21475 | | /// <summary>Adds two Volume measurements.</summary> |
| | 21476 | | /// <param name="a">The first operand of the addition.</param> |
| | 21477 | | /// <param name="b">The second operand of the addition.</param> |
| | 21478 | | /// <returns>The result of the addition operation.</returns> |
| | 21479 | | public static Volume<T> operator +(Volume<T> a, Volume<T> b) |
| | 21480 | | { |
| | 21481 | | return Add(a, b); |
| | 21482 | | } |
| | 21483 | |
|
| | 21484 | | /// <summary>Adds two Volume measurements.</summary> |
| | 21485 | | /// <param name="b">The second operand of the addition.</param> |
| | 21486 | | /// <returns>The result of the addition operation.</returns> |
| | 21487 | | public Volume<T> Add(Volume<T> b) |
| | 21488 | | { |
| | 21489 | | return this + b; |
| | 21490 | | } |
| | 21491 | |
|
| | 21492 | | #endregion |
| | 21493 | |
|
| | 21494 | | #region Subtract |
| | 21495 | |
|
| | 21496 | | /// <summary>Subtracts two Volume measurements.</summary> |
| | 21497 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 21498 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 21499 | | /// <returns>The result of the subtraction.</returns> |
| | 21500 | | public static Volume<T> Subtract(Volume<T> a, Volume<T> b) |
| | 21501 | | { |
| | 21502 | | return MathBase(a, b, Statics.Subtraction); |
| | 21503 | | } |
| | 21504 | |
|
| | 21505 | | /// <summary>Subtracts two Volume measurements.</summary> |
| | 21506 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 21507 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 21508 | | /// <returns>The result of the subtraction.</returns> |
| | 21509 | | public static Volume<T> operator -(Volume<T> a, Volume<T> b) |
| | 21510 | | { |
| | 21511 | | return Subtract(a, b); |
| | 21512 | | } |
| | 21513 | |
|
| | 21514 | | /// <summary>Subtracts two Volume measurements.</summary> |
| | 21515 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 21516 | | /// <returns>The result of the subtraction.</returns> |
| | 21517 | | public Volume<T> Subtract(Volume<T> b) |
| | 21518 | | { |
| | 21519 | | return this - b; |
| | 21520 | | } |
| | 21521 | |
|
| | 21522 | | #endregion |
| | 21523 | |
|
| | 21524 | | #region Multiply |
| | 21525 | |
|
| | 21526 | | /// <summary>Multiplies an Volume by a scalar numeric value.</summary> |
| | 21527 | | /// <param name="a">The Volume measurement to multiply.</param> |
| | 21528 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 21529 | | /// <returns>The result of the multiplication.</returns> |
| | 21530 | | public static Volume<T> Multiply(Volume<T> a, T b) |
| | 21531 | | { |
| | 21532 | | return MathBase(a, b, Statics.Multiplication); |
| | 21533 | | } |
| | 21534 | |
|
| | 21535 | | /// <summary>Multiplies an Volume by a scalar numeric value.</summary> |
| | 21536 | | /// <param name="a">The Volume measurement to multiply.</param> |
| | 21537 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 21538 | | /// <returns>The result of the multiplication.</returns> |
| | 21539 | | public static Volume<T> Multiply(T b, Volume<T> a) |
| | 21540 | | { |
| | 21541 | | return Multiply(a, b); |
| | 21542 | | } |
| | 21543 | |
|
| | 21544 | | /// <summary>Multiplies an Volume by a scalar numeric value.</summary> |
| | 21545 | | /// <param name="a">The Volume measurement to multiply.</param> |
| | 21546 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 21547 | | /// <returns>The result of the multiplication.</returns> |
| | 21548 | | public static Volume<T> operator *(Volume<T> a, T b) |
| | 21549 | | { |
| | 21550 | | return Multiply(a, b); |
| | 21551 | | } |
| | 21552 | |
|
| | 21553 | | /// <summary>Multiplies an Volume by a scalar numeric value.</summary> |
| | 21554 | | /// <param name="a">The Volume measurement to multiply.</param> |
| | 21555 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 21556 | | /// <returns>The result of the multiplication.</returns> |
| | 21557 | | public static Volume<T> operator *(T b, Volume<T> a) |
| | 21558 | | { |
| | 21559 | | return Multiply(b, a); |
| | 21560 | | } |
| | 21561 | |
|
| | 21562 | | /// <summary>Multiplies an Volume by a scalar numeric value.</summary> |
| | 21563 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 21564 | | /// <returns>The result of the multiplication.</returns> |
| | 21565 | | public Volume<T> Add(T b) |
| | 21566 | | { |
| | 21567 | | return this * b; |
| | 21568 | | } |
| | 21569 | |
|
| | 21570 | | #region Volume<T> * AreaDensity<T> = LinearMass<T> |
| | 21571 | |
|
| | 21572 | | /// <summary>Mulitplies Volume by AreaDensity resulting in LinearMass.</summary> |
| | 21573 | | /// <param name="a">The Volume to be multiplied.</param> |
| | 21574 | | /// <param name="b">The AreaDensity to multiply by.</param> |
| | 21575 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 21576 | | public static LinearMass<T> Multiply(Volume<T> a, AreaDensity<T> b) |
| | 21577 | | { |
| | 21578 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits2 ? a._LengthUnits1 : b._LengthUnits2; |
| | 21579 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits3 ? a._LengthUnits2 : b._LengthUnits3; |
| | 21580 | |
|
| | 21581 | | T A = a[LengthUnits1, LengthUnits2, a._LengthUnits3]; |
| | 21582 | | T B = b[b._MassUnits1, LengthUnits1, LengthUnits2]; |
| | 21583 | | T C = Statics.Multiplication(A, B); |
| | 21584 | |
|
| | 21585 | | return new LinearMass<T>(C |
| | 21586 | | , b._MassUnits1 |
| | 21587 | | , a._LengthUnits3 |
| | 21588 | | ); |
| | 21589 | | } |
| | 21590 | |
|
| | 21591 | | /// <summary>Mulitplies Volume by AreaDensity resulting in LinearMass.</summary> |
| | 21592 | | /// <param name="a">The Volume to be multiplied.</param> |
| | 21593 | | /// <param name="b">The AreaDensity to multiply by.</param> |
| | 21594 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 21595 | | public static LinearMass<T> operator *(Volume<T> a, AreaDensity<T> b) |
| | 21596 | | { |
| | 21597 | | return Multiply(a, b); |
| | 21598 | | } |
| | 21599 | |
|
| | 21600 | | /// <summary>Mulitplies Volume by AreaDensity resulting in LinearMass.</summary> |
| | 21601 | | /// <param name="b">The AreaDensity to multiply by.</param> |
| | 21602 | | /// <returns>The LinearMass result of the multiplication.</returns> |
| | 21603 | | public LinearMass<T> Multiply(AreaDensity<T> b) |
| | 21604 | | { |
| | 21605 | | return this * b; |
| | 21606 | | } |
| | 21607 | |
|
| | 21608 | | #endregion |
| | 21609 | |
|
| | 21610 | | #region Volume<T> * Density<T> = Mass<T> |
| | 21611 | |
|
| | 21612 | | /// <summary>Mulitplies Volume by Density resulting in Mass.</summary> |
| | 21613 | | /// <param name="a">The Volume to be multiplied.</param> |
| | 21614 | | /// <param name="b">The Density to multiply by.</param> |
| | 21615 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 21616 | | public static Mass<T> Multiply(Volume<T> a, Density<T> b) |
| | 21617 | | { |
| | 21618 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits2 ? a._LengthUnits1 : b._LengthUnits2; |
| | 21619 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits3 ? a._LengthUnits2 : b._LengthUnits3; |
| | 21620 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits4 ? a._LengthUnits3 : b._LengthUnits4; |
| | 21621 | |
|
| | 21622 | | T A = a[LengthUnits1, LengthUnits2, LengthUnits3]; |
| | 21623 | | T B = b[b._MassUnits1, LengthUnits1, LengthUnits2, LengthUnits3]; |
| | 21624 | | T C = Statics.Multiplication(A, B); |
| | 21625 | |
|
| | 21626 | | return new Mass<T>(C |
| | 21627 | | , b._MassUnits1 |
| | 21628 | | ); |
| | 21629 | | } |
| | 21630 | |
|
| | 21631 | | /// <summary>Mulitplies Volume by Density resulting in Mass.</summary> |
| | 21632 | | /// <param name="a">The Volume to be multiplied.</param> |
| | 21633 | | /// <param name="b">The Density to multiply by.</param> |
| | 21634 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 21635 | | public static Mass<T> operator *(Volume<T> a, Density<T> b) |
| | 21636 | | { |
| | 21637 | | return Multiply(a, b); |
| | 21638 | | } |
| | 21639 | |
|
| | 21640 | | /// <summary>Mulitplies Volume by Density resulting in Mass.</summary> |
| | 21641 | | /// <param name="b">The Density to multiply by.</param> |
| | 21642 | | /// <returns>The Mass result of the multiplication.</returns> |
| | 21643 | | public Mass<T> Multiply(Density<T> b) |
| | 21644 | | { |
| | 21645 | | return this * b; |
| | 21646 | | } |
| | 21647 | |
|
| | 21648 | | #endregion |
| | 21649 | |
|
| | 21650 | | #region Volume<T> * Pressure<T> = Energy<T> |
| | 21651 | |
|
| | 21652 | | /// <summary>Mulitplies Volume by Pressure resulting in Energy.</summary> |
| | 21653 | | /// <param name="a">The Volume to be multiplied.</param> |
| | 21654 | | /// <param name="b">The Pressure to multiply by.</param> |
| | 21655 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 21656 | | public static Energy<T> Multiply(Volume<T> a, Pressure<T> b) |
| | 21657 | | { |
| | 21658 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits2 ? a._LengthUnits1 : b._LengthUnits2; |
| | 21659 | |
|
| | 21660 | | T A = a[LengthUnits1, a._LengthUnits2, a._LengthUnits3]; |
| | 21661 | | T B = b[b._MassUnits1, LengthUnits1, b._TimeUnits3, b._TimeUnits4]; |
| | 21662 | | T C = Statics.Multiplication(A, B); |
| | 21663 | |
|
| | 21664 | | return new Energy<T>(C |
| | 21665 | | , b._MassUnits1 |
| | 21666 | | , a._LengthUnits2 |
| | 21667 | | , a._LengthUnits3 |
| | 21668 | | , b._TimeUnits3 |
| | 21669 | | , b._TimeUnits4 |
| | 21670 | | ); |
| | 21671 | | } |
| | 21672 | |
|
| | 21673 | | /// <summary>Mulitplies Volume by Pressure resulting in Energy.</summary> |
| | 21674 | | /// <param name="a">The Volume to be multiplied.</param> |
| | 21675 | | /// <param name="b">The Pressure to multiply by.</param> |
| | 21676 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 21677 | | public static Energy<T> operator *(Volume<T> a, Pressure<T> b) |
| | 21678 | | { |
| | 21679 | | return Multiply(a, b); |
| | 21680 | | } |
| | 21681 | |
|
| | 21682 | | /// <summary>Mulitplies Volume by Pressure resulting in Energy.</summary> |
| | 21683 | | /// <param name="b">The Pressure to multiply by.</param> |
| | 21684 | | /// <returns>The Energy result of the multiplication.</returns> |
| | 21685 | | public Energy<T> Multiply(Pressure<T> b) |
| | 21686 | | { |
| | 21687 | | return this * b; |
| | 21688 | | } |
| | 21689 | |
|
| | 21690 | | #endregion |
| | 21691 | |
|
| | 21692 | | #endregion |
| | 21693 | |
|
| | 21694 | | #region Divide |
| | 21695 | |
|
| | 21696 | | /// <summary>Divides an Volume measurement by another Volume measurement resulting in a scalar numeric value.</summa |
| | 21697 | | /// <param name="a">The first operand of the division operation.</param> |
| | 21698 | | /// <param name="b">The second operand of the division operation.</param> |
| | 21699 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 21700 | | public static T Divide(Volume<T> a, Volume<T> b) |
| | 21701 | | { |
| | 21702 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 21703 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 21704 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits3 ? a._LengthUnits3 : b._LengthUnits3; |
| | 21705 | | T A = a[LengthUnits1, LengthUnits2, LengthUnits3]; |
| | 21706 | | T B = b[LengthUnits1, LengthUnits2, LengthUnits3]; |
| | 21707 | | return Statics.Division(A, B); |
| | 21708 | | } |
| | 21709 | |
|
| | 21710 | | /// <summary>Divides this Volume measurement by a numaric scalar value.</summary> |
| | 21711 | | /// <param name="a">The Volume measurement to divide.</param> |
| | 21712 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 21713 | | /// <returns>The result of the division.</returns> |
| | 21714 | | public static Volume<T> Divide(Volume<T> a, T b) |
| | 21715 | | { |
| | 21716 | | return MathBase(a, b, Statics.Division); |
| | 21717 | | } |
| | 21718 | |
|
| | 21719 | | /// <summary>Divides this Volume measurement by a numaric scalar value.</summary> |
| | 21720 | | /// <param name="a">The Volume measurement to divide.</param> |
| | 21721 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 21722 | | /// <returns>The result of the division.</returns> |
| | 21723 | | public static Volume<T> operator /(Volume<T> a, T b) |
| | 21724 | | { |
| | 21725 | | return Divide(a, b); |
| | 21726 | | } |
| | 21727 | |
|
| | 21728 | | /// <summary>Divides this Volume measurement by a numaric scalar value.</summary> |
| | 21729 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 21730 | | /// <returns>The result of the division.</returns> |
| | 21731 | | public Volume<T> Divide(T b) |
| | 21732 | | { |
| | 21733 | | return this / b; |
| | 21734 | | } |
| | 21735 | |
|
| | 21736 | | /// <summary>Divides an Volume measurement by another Volume measurement resulting in a scalar numeric value.</summa |
| | 21737 | | /// <param name="a">The first operand of the division operation.</param> |
| | 21738 | | /// <param name="b">The second operand of the division operation.</param> |
| | 21739 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 21740 | | public static T operator /(Volume<T> a, Volume<T> b) |
| | 21741 | | { |
| | 21742 | | return Divide(a, b); |
| | 21743 | | } |
| | 21744 | |
|
| | 21745 | | /// <summary>Divides an Volume measurement by another Volume measurement resulting in a scalar numeric value.</summa |
| | 21746 | | /// <param name="b">The second operand of the division operation.</param> |
| | 21747 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 21748 | | public T Divide(Volume<T> b) |
| | 21749 | | { |
| | 21750 | | return this / b; |
| | 21751 | | } |
| | 21752 | |
|
| | 21753 | |
|
| | 21754 | | #region Volume<T> / Area<T> = Length<T> |
| | 21755 | |
|
| | 21756 | | /// <summary>Divides Volume by Area resulting in Length.</summary> |
| | 21757 | | /// <param name="a">The Volume to be divided.</param> |
| | 21758 | | /// <param name="b">The Area to divide by.</param> |
| | 21759 | | /// <returns>The Length result of the division.</returns> |
| | 21760 | | public static Length<T> Divide(Volume<T> a, Area<T> b) |
| | 21761 | | { |
| | 21762 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 21763 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 21764 | |
|
| | 21765 | | T A = a[LengthUnits1, LengthUnits2, a._LengthUnits3]; |
| | 21766 | | T B = b[LengthUnits1, LengthUnits2]; |
| | 21767 | | T C = Statics.Division(A, B); |
| | 21768 | |
|
| | 21769 | | return new Length<T>(C |
| | 21770 | | , a._LengthUnits3 |
| | 21771 | | ); |
| | 21772 | | } |
| | 21773 | |
|
| | 21774 | | /// <summary>Divides Volume by Area resulting in Length.</summary> |
| | 21775 | | /// <param name="a">The Volume to be divided.</param> |
| | 21776 | | /// <param name="b">The Area to divide by.</param> |
| | 21777 | | /// <returns>The Length result of the division.</returns> |
| | 21778 | | public static Length<T> operator /(Volume<T> a, Area<T> b) |
| | 21779 | | { |
| | 21780 | | return Divide(a, b); |
| | 21781 | | } |
| | 21782 | |
|
| | 21783 | | /// <summary>Divides Volume by Area resulting in Length.</summary> |
| | 21784 | | /// <param name="b">The Area to divide by.</param> |
| | 21785 | | /// <returns>The Length result of the division.</returns> |
| | 21786 | | public Length<T> Divide(Area<T> b) |
| | 21787 | | { |
| | 21788 | | return this / b; |
| | 21789 | | } |
| | 21790 | |
|
| | 21791 | | #endregion |
| | 21792 | |
|
| | 21793 | |
|
| | 21794 | | #region Volume<T> / Length<T> = Area<T> |
| | 21795 | |
|
| | 21796 | | /// <summary>Divides Volume by Length resulting in Area.</summary> |
| | 21797 | | /// <param name="a">The Volume to be divided.</param> |
| | 21798 | | /// <param name="b">The Length to divide by.</param> |
| | 21799 | | /// <returns>The Area result of the division.</returns> |
| | 21800 | | public static Area<T> Divide(Volume<T> a, Length<T> b) |
| | 21801 | | { |
| | 21802 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 21803 | |
|
| | 21804 | | T A = a[LengthUnits1, a._LengthUnits2, a._LengthUnits3]; |
| | 21805 | | T B = b[LengthUnits1]; |
| | 21806 | | T C = Statics.Division(A, B); |
| | 21807 | |
|
| | 21808 | | return new Area<T>(C |
| | 21809 | | , a._LengthUnits2 |
| | 21810 | | , a._LengthUnits3 |
| | 21811 | | ); |
| | 21812 | | } |
| | 21813 | |
|
| | 21814 | | /// <summary>Divides Volume by Length resulting in Area.</summary> |
| | 21815 | | /// <param name="a">The Volume to be divided.</param> |
| | 21816 | | /// <param name="b">The Length to divide by.</param> |
| | 21817 | | /// <returns>The Area result of the division.</returns> |
| | 21818 | | public static Area<T> operator /(Volume<T> a, Length<T> b) |
| | 21819 | | { |
| | 21820 | | return Divide(a, b); |
| | 21821 | | } |
| | 21822 | |
|
| | 21823 | | /// <summary>Divides Volume by Length resulting in Area.</summary> |
| | 21824 | | /// <param name="b">The Length to divide by.</param> |
| | 21825 | | /// <returns>The Area result of the division.</returns> |
| | 21826 | | public Area<T> Divide(Length<T> b) |
| | 21827 | | { |
| | 21828 | | return this / b; |
| | 21829 | | } |
| | 21830 | |
|
| | 21831 | | #endregion |
| | 21832 | |
|
| | 21833 | |
|
| | 21834 | | #region Volume<T> / Time<T> = VolumeRate<T> |
| | 21835 | |
|
| | 21836 | | /// <summary>Divides Volume by Time resulting in VolumeRate.</summary> |
| | 21837 | | /// <param name="a">The Volume to be divided.</param> |
| | 21838 | | /// <param name="b">The Time to divide by.</param> |
| | 21839 | | /// <returns>The VolumeRate result of the division.</returns> |
| | 21840 | | public static VolumeRate<T> Divide(Volume<T> a, Time<T> b) |
| | 21841 | | { |
| | 21842 | |
|
| | 21843 | | T A = a[a._LengthUnits1, a._LengthUnits2, a._LengthUnits3]; |
| | 21844 | | T B = b[b._TimeUnits1]; |
| | 21845 | | T C = Statics.Division(A, B); |
| | 21846 | |
|
| | 21847 | | return new VolumeRate<T>(C |
| | 21848 | | , a._LengthUnits1 |
| | 21849 | | , a._LengthUnits2 |
| | 21850 | | , a._LengthUnits3 |
| | 21851 | | , b._TimeUnits1 |
| | 21852 | | ); |
| | 21853 | | } |
| | 21854 | |
|
| | 21855 | | /// <summary>Divides Volume by Time resulting in VolumeRate.</summary> |
| | 21856 | | /// <param name="a">The Volume to be divided.</param> |
| | 21857 | | /// <param name="b">The Time to divide by.</param> |
| | 21858 | | /// <returns>The VolumeRate result of the division.</returns> |
| | 21859 | | public static VolumeRate<T> operator /(Volume<T> a, Time<T> b) |
| | 21860 | | { |
| | 21861 | | return Divide(a, b); |
| | 21862 | | } |
| | 21863 | |
|
| | 21864 | | /// <summary>Divides Volume by Time resulting in VolumeRate.</summary> |
| | 21865 | | /// <param name="b">The Time to divide by.</param> |
| | 21866 | | /// <returns>The VolumeRate result of the division.</returns> |
| | 21867 | | public VolumeRate<T> Divide(Time<T> b) |
| | 21868 | | { |
| | 21869 | | return this / b; |
| | 21870 | | } |
| | 21871 | |
|
| | 21872 | | #endregion |
| | 21873 | |
|
| | 21874 | |
|
| | 21875 | | #region Volume<T> / VolumeRate<T> = Time<T> |
| | 21876 | |
|
| | 21877 | | /// <summary>Divides Volume by VolumeRate resulting in Time.</summary> |
| | 21878 | | /// <param name="a">The Volume to be divided.</param> |
| | 21879 | | /// <param name="b">The VolumeRate to divide by.</param> |
| | 21880 | | /// <returns>The Time result of the division.</returns> |
| | 21881 | | public static Time<T> Divide(Volume<T> a, VolumeRate<T> b) |
| | 21882 | | { |
| | 21883 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 21884 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 21885 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits3 ? a._LengthUnits3 : b._LengthUnits3; |
| | 21886 | |
|
| | 21887 | | T A = a[LengthUnits1, LengthUnits2, LengthUnits3]; |
| | 21888 | | T B = b[LengthUnits1, LengthUnits2, LengthUnits3, b._TimeUnits4]; |
| | 21889 | | T C = Statics.Division(A, B); |
| | 21890 | |
|
| | 21891 | | return new Time<T>(C |
| | 21892 | | , b._TimeUnits4 |
| | 21893 | | ); |
| | 21894 | | } |
| | 21895 | |
|
| | 21896 | | /// <summary>Divides Volume by VolumeRate resulting in Time.</summary> |
| | 21897 | | /// <param name="a">The Volume to be divided.</param> |
| | 21898 | | /// <param name="b">The VolumeRate to divide by.</param> |
| | 21899 | | /// <returns>The Time result of the division.</returns> |
| | 21900 | | public static Time<T> operator /(Volume<T> a, VolumeRate<T> b) |
| | 21901 | | { |
| | 21902 | | return Divide(a, b); |
| | 21903 | | } |
| | 21904 | |
|
| | 21905 | | /// <summary>Divides Volume by VolumeRate resulting in Time.</summary> |
| | 21906 | | /// <param name="b">The VolumeRate to divide by.</param> |
| | 21907 | | /// <returns>The Time result of the division.</returns> |
| | 21908 | | public Time<T> Divide(VolumeRate<T> b) |
| | 21909 | | { |
| | 21910 | | return this / b; |
| | 21911 | | } |
| | 21912 | |
|
| | 21913 | | #endregion |
| | 21914 | |
|
| | 21915 | | #endregion |
| | 21916 | |
|
| | 21917 | | #region LessThan |
| | 21918 | |
|
| | 21919 | | /// <summary>Determines if an Volume measurement is less than another Volume measurement.</summary> |
| | 21920 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 21921 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 21922 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 21923 | | public static bool LessThan(Volume<T> a, Volume<T> b) |
| | 21924 | | { |
| | 21925 | | return LogicBase(a, b, Statics.LessThan); |
| | 21926 | | } |
| | 21927 | |
|
| | 21928 | | /// <summary>Determines if an Volume measurement is less than another Volume measurement.</summary> |
| | 21929 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 21930 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 21931 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 21932 | | public static bool operator <(Volume<T> a, Volume<T> b) |
| | 21933 | | { |
| | 21934 | | return LessThan(a, b); |
| | 21935 | | } |
| | 21936 | |
|
| | 21937 | | /// <summary>Determines if an Volume measurement is less than another Volume measurement.</summary> |
| | 21938 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 21939 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 21940 | | public bool LessThan(Volume<T> b) |
| | 21941 | | { |
| | 21942 | | return this < b; |
| | 21943 | | } |
| | 21944 | |
|
| | 21945 | | #endregion |
| | 21946 | |
|
| | 21947 | | #region GreaterThan |
| | 21948 | |
|
| | 21949 | | /// <summary>Determines if an Volume measurement is greater than another Volume measurement.</summary> |
| | 21950 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 21951 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 21952 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 21953 | | public static bool GreaterThan(Volume<T> a, Volume<T> b) |
| | 21954 | | { |
| | 21955 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 21956 | | } |
| | 21957 | |
|
| | 21958 | | /// <summary>Determines if an Volume measurement is greater than another Volume measurement.</summary> |
| | 21959 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 21960 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 21961 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 21962 | | public static bool operator >(Volume<T> a, Volume<T> b) |
| | 21963 | | { |
| | 21964 | | return GreaterThan(a, b); |
| | 21965 | | } |
| | 21966 | |
|
| | 21967 | | /// <summary>Determines if an Volume measurement is greater than another Volume measurement.</summary> |
| | 21968 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 21969 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 21970 | | public bool GreaterThan(Volume<T> b) |
| | 21971 | | { |
| | 21972 | | return this > b; |
| | 21973 | | } |
| | 21974 | |
|
| | 21975 | | #endregion |
| | 21976 | |
|
| | 21977 | | #region LessThanOrEqual |
| | 21978 | |
|
| | 21979 | | /// <summary>Determines if an Volume measurement is less than or equal to another Volume measurement.</summary> |
| | 21980 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 21981 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 21982 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 21983 | | public static bool LessThanOrEqual(Volume<T> a, Volume<T> b) |
| | 21984 | | { |
| | 21985 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 21986 | | } |
| | 21987 | |
|
| | 21988 | | /// <summary>Determines if an Volume measurement is less than or equal to another Volume measurement.</summary> |
| | 21989 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 21990 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 21991 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 21992 | | public static bool operator <=(Volume<T> a, Volume<T> b) |
| | 21993 | | { |
| | 21994 | | return LessThanOrEqual(a, b); |
| | 21995 | | } |
| | 21996 | |
|
| | 21997 | | /// <summary>Determines if an Volume measurement is less than or equal to another Volume measurement.</summary> |
| | 21998 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 21999 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 22000 | | public bool LessThanOrEqual(Volume<T> b) |
| | 22001 | | { |
| | 22002 | | return this <= b; |
| | 22003 | | } |
| | 22004 | |
|
| | 22005 | | #endregion |
| | 22006 | |
|
| | 22007 | | #region GreaterThanOrEqual |
| | 22008 | |
|
| | 22009 | | /// <summary>Determines if an Volume measurement is greater than or equal to another Volume measurement.</summary> |
| | 22010 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 22011 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 22012 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 22013 | | public static bool GreaterThanOrEqual(Volume<T> a, Volume<T> b) |
| | 22014 | | { |
| | 22015 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 22016 | | } |
| | 22017 | |
|
| | 22018 | | /// <summary>Determines if an Volume measurement is greater than or equal to another Volume measurement.</summary> |
| | 22019 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 22020 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 22021 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 22022 | | public static bool operator >=(Volume<T> a, Volume<T> b) |
| | 22023 | | { |
| | 22024 | | return GreaterThanOrEqual(a, b); |
| | 22025 | | } |
| | 22026 | |
|
| | 22027 | | /// <summary>Determines if an Volume measurement is greater than or equal to another Volume measurement.</summary> |
| | 22028 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 22029 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 22030 | | public bool GreaterThanOrEqual(Volume<T> b) |
| | 22031 | | { |
| | 22032 | | return this >= b; |
| | 22033 | | } |
| | 22034 | |
|
| | 22035 | | #endregion |
| | 22036 | |
|
| | 22037 | | #region Equal |
| | 22038 | |
|
| | 22039 | | /// <summary>Determines if an Volume measurement is equal to another Volume measurement.</summary> |
| | 22040 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 22041 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 22042 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 22043 | | public static bool Equal(Volume<T> a, Volume<T> b) |
| | 22044 | | { |
| | 22045 | | return LogicBase(a, b, Statics.Equate); |
| | 22046 | | } |
| | 22047 | |
|
| | 22048 | | /// <summary>Determines if an Volume measurement is equal to another Volume measurement.</summary> |
| | 22049 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 22050 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 22051 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 22052 | | public static bool operator ==(Volume<T> a, Volume<T> b) |
| | 22053 | | { |
| | 22054 | | return Equal(a, b); |
| | 22055 | | } |
| | 22056 | |
|
| | 22057 | | /// <summary>Determines if an Volume measurement is equal to another Volume measurement.</summary> |
| | 22058 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 22059 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 22060 | | public bool Equal(Volume<T> b) |
| | 22061 | | { |
| | 22062 | | return this == b; |
| | 22063 | | } |
| | 22064 | |
|
| | 22065 | | #endregion |
| | 22066 | |
|
| | 22067 | | #region NotEqual |
| | 22068 | |
|
| | 22069 | | /// <summary>Determines if an Volume measurement is not equal to another Volume measurement.</summary> |
| | 22070 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 22071 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 22072 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 22073 | | public static bool NotEqual(Volume<T> a, Volume<T> b) |
| | 22074 | | { |
| | 22075 | | return LogicBase(a, b, Statics.Inequate); |
| | 22076 | | } |
| | 22077 | |
|
| | 22078 | | /// <summary>Determines if an Volume measurement is not equal to another Volume measurement.</summary> |
| | 22079 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 22080 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 22081 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 22082 | | public static bool operator !=(Volume<T> a, Volume<T> b) |
| | 22083 | | { |
| | 22084 | | return NotEqual(a, b); |
| | 22085 | | } |
| | 22086 | |
|
| | 22087 | | /// <summary>Determines if an Volume measurement is not equal to another Volume measurement.</summary> |
| | 22088 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 22089 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 22090 | | public bool NotEqual(Volume<T> b) |
| | 22091 | | { |
| | 22092 | | return this != b; |
| | 22093 | | } |
| | 22094 | |
|
| | 22095 | | #endregion |
| | 22096 | |
|
| | 22097 | | #endregion |
| | 22098 | |
|
| | 22099 | | #region Overrides |
| | 22100 | |
|
| | 22101 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 22102 | | /// <param name="obj">The object to check for equality with.</param> |
| | 22103 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 22104 | | public override bool Equals(object obj) |
| | 22105 | | { |
| | 22106 | | if (obj is Volume<T>) |
| | 22107 | | { |
| | 22108 | | return this == (Volume<T>)obj; |
| | 22109 | | } |
| | 22110 | | return false; |
| | 22111 | | } |
| | 22112 | |
|
| | 22113 | | /// <summary>Converts the Volume measurement to a string represenation.</summary> |
| | 22114 | | /// <returns>The string representation of the measurement.</returns> |
| | 22115 | | public override string ToString() |
| | 22116 | | { |
| | 22117 | | return _measurement + " " + |
| | 22118 | | _LengthUnits1 + "*" + _LengthUnits2 + "*" + _LengthUnits3 |
| | 22119 | |
|
| | 22120 | | ; |
| | 22121 | | } |
| | 22122 | |
|
| | 22123 | | /// <summary>Base hashing function for Volume measurements.</summary> |
| | 22124 | | /// <returns>Computed hash code for this instance.</returns> |
| | 22125 | | public override int GetHashCode() => Hash(_measurement); |
| | 22126 | |
|
| | 22127 | | #endregion |
| | 22128 | | } |
| | 22129 | |
|
| | 22130 | | #endregion |
| | 22131 | |
|
| | 22132 | | #region VolumeRate |
| | 22133 | |
|
| | 22134 | | internal static partial class ParsingFunctions |
| | 22135 | | { |
| | 22136 | | [Measurement.Parseable("Length*Length*Length/Time")] |
| | 22137 | | public static object VolumeRate<T>(T value, object[] units) |
| | 22138 | | { |
| | 22139 | | if (units.Length != 4) |
| | 22140 | | { |
| | 22141 | | throw new Exception("Bug in Towel. Invalid parameters to VolumeRate Factory."); |
| | 22142 | | } |
| | 22143 | | if (!(units[0] is Length.Units)) |
| | 22144 | | { |
| | 22145 | | throw new Exception("Bug in Towel. Invalid parameters to VolumeRate Factory."); |
| | 22146 | | } |
| | 22147 | | if (!(units[1] is Length.Units)) |
| | 22148 | | { |
| | 22149 | | throw new Exception("Bug in Towel. Invalid parameters to VolumeRate Factory."); |
| | 22150 | | } |
| | 22151 | | if (!(units[2] is Length.Units)) |
| | 22152 | | { |
| | 22153 | | throw new Exception("Bug in Towel. Invalid parameters to VolumeRate Factory."); |
| | 22154 | | } |
| | 22155 | | if (!(units[3] is Time.Units)) |
| | 22156 | | { |
| | 22157 | | throw new Exception("Bug in Towel. Invalid parameters to VolumeRate Factory."); |
| | 22158 | | } |
| | 22159 | | return new VolumeRate<T>(value |
| | 22160 | | , (Length.Units)units[0] |
| | 22161 | | , (Length.Units)units[1] |
| | 22162 | | , (Length.Units)units[2] |
| | 22163 | | , (Time.Units)units[3] |
| | 22164 | | ); |
| | 22165 | | } |
| | 22166 | | } |
| | 22167 | |
|
| | 22168 | | /// <summary>VolumeRate measurement with a value and the units.</summary> |
| | 22169 | | /// <typeparam name="T">The generic numeric type used to store the value of the measurement.</typeparam> |
| | 22170 | | public struct VolumeRate<T> |
| | 22171 | | { |
| | 22172 | | internal T _measurement; |
| | 22173 | | internal Length.Units _LengthUnits1; |
| | 22174 | | internal Length.Units _LengthUnits2; |
| | 22175 | | internal Length.Units _LengthUnits3; |
| | 22176 | | internal Time.Units _TimeUnits4; |
| | 22177 | |
|
| | 22178 | | #region Statics |
| | 22179 | |
|
| | 22180 | | /// <summary>Converts a VolumeRate measurement from units to another.</summary> |
| | 22181 | | /// <param name="value">The value to convert the units of.</param> |
| | 22182 | | /// <param name="fromLengthUnits1">The current units of the measurement.</param> |
| | 22183 | | /// <param name="fromLengthUnits2">The current units of the measurement.</param> |
| | 22184 | | /// <param name="fromLengthUnits3">The current units of the measurement.</param> |
| | 22185 | | /// <param name="fromTimeUnits4">The current units of the measurement.</param> |
| | 22186 | | /// <param name="toLengthUnits1">The desired units of the measurement.</param> |
| | 22187 | | /// <param name="toLengthUnits2">The desired units of the measurement.</param> |
| | 22188 | | /// <param name="toLengthUnits3">The desired units of the measurement.</param> |
| | 22189 | | /// <param name="toTimeUnits4">The desired units of the measurement.</param> |
| | 22190 | | /// <returns>The VolumeRate measurement converted into the desired units.</returns> |
| | 22191 | | public static T Convert(T value |
| | 22192 | | , Length.Units fromLengthUnits1 |
| | 22193 | | , Length.Units fromLengthUnits2 |
| | 22194 | | , Length.Units fromLengthUnits3 |
| | 22195 | | , Time.Units fromTimeUnits4 |
| | 22196 | | , Length.Units toLengthUnits1 |
| | 22197 | | , Length.Units toLengthUnits2 |
| | 22198 | | , Length.Units toLengthUnits3 |
| | 22199 | | , Time.Units toTimeUnits4 |
| | 22200 | | ) |
| | 22201 | | { |
| | 22202 | | VolumeRate<T> measurement = new VolumeRate<T>(value |
| | 22203 | | , fromLengthUnits1 |
| | 22204 | | , fromLengthUnits2 |
| | 22205 | | , fromLengthUnits3 |
| | 22206 | | , fromTimeUnits4 |
| | 22207 | | ); |
| | 22208 | | return measurement[ |
| | 22209 | | toLengthUnits1 |
| | 22210 | | , toLengthUnits2 |
| | 22211 | | , toLengthUnits3 |
| | 22212 | | , toTimeUnits4 |
| | 22213 | | ]; |
| | 22214 | | } |
| | 22215 | |
|
| | 22216 | | /// <summary>Converts a VolumeRate measurement from units to another.</summary> |
| | 22217 | | /// <param name="value">The value to convert the units of.</param> |
| | 22218 | | /// <param name="from">The current units of the measurement.</param> |
| | 22219 | | /// <param name="to">The desired units of the measurement.</param> |
| | 22220 | | /// <returns>The VolumeRate measurement converted into the desired units.</returns> |
| | 22221 | | public static T Convert(T value, |
| | 22222 | | MeasurementUnitsSyntaxTypes.VolumeRateBaseUnits from, |
| | 22223 | | MeasurementUnitsSyntaxTypes.VolumeRateBaseUnits to) |
| | 22224 | | { |
| | 22225 | | return Convert(value |
| | 22226 | | , from._LengthUnits1 |
| | 22227 | | , from._LengthUnits2 |
| | 22228 | | , from._LengthUnits3 |
| | 22229 | | , from._TimeUnits4 |
| | 22230 | | , to._LengthUnits1 |
| | 22231 | | , to._LengthUnits2 |
| | 22232 | | , to._LengthUnits3 |
| | 22233 | | , to._TimeUnits4 |
| | 22234 | | ); |
| | 22235 | | } |
| | 22236 | |
|
| | 22237 | | /// <summary>Parses a VolumeRate measurement string.</summary> |
| | 22238 | | /// <param name="string">The string to be parsed.</param> |
| | 22239 | | /// <param name="tryParse">The tryparse function for the generic type.</param> |
| | 22240 | | /// <returns>True if the parse was successful or false if not.</returns> |
| | 22241 | | public static (bool Success, VolumeRate<T>? Value) TryParse(string @string, Func<string, (bool Success, T Value)> tr |
| | 22242 | |
|
| | 22243 | | #endregion |
| | 22244 | |
|
| | 22245 | | #region Constructors |
| | 22246 | |
|
| | 22247 | | /// <summary>Constructs an VolumeRate with the measurement value and units.</summary> |
| | 22248 | | /// <param name="measurement">The measurement value of the VolumeRate.</param> |
| | 22249 | | /// <param name="units">The units of the VolumeRate.</param> |
| | 22250 | | public VolumeRate(T measurement, MeasurementUnitsSyntaxTypes.VolumeRateBaseUnits units) : this(measurement |
| | 22251 | | , units._LengthUnits1 |
| | 22252 | | , units._LengthUnits2 |
| | 22253 | | , units._LengthUnits3 |
| | 22254 | | , units._TimeUnits4 |
| | 22255 | | ) { } |
| | 22256 | |
|
| | 22257 | |
|
| | 22258 | | /// <summary>Constructs an VolumeRate with the measurement value and units.</summary> |
| | 22259 | | /// <param name="measurement">The measurement value of the VolumeRate.</param> |
| | 22260 | | /// <param name="LengthUnits1">The units of the VolumeRate.</param> |
| | 22261 | | /// <param name="LengthUnits2">The units of the VolumeRate.</param> |
| | 22262 | | /// <param name="LengthUnits3">The units of the VolumeRate.</param> |
| | 22263 | | /// <param name="TimeUnits4">The units of the VolumeRate.</param> |
| | 22264 | | public VolumeRate(T measurement |
| | 22265 | | , Length.Units LengthUnits1 |
| | 22266 | | , Length.Units LengthUnits2 |
| | 22267 | | , Length.Units LengthUnits3 |
| | 22268 | | , Time.Units TimeUnits4 |
| | 22269 | | ) |
| | 22270 | | { |
| | 22271 | | _measurement = measurement; |
| | 22272 | | _LengthUnits1 = LengthUnits1; |
| | 22273 | | _LengthUnits2 = LengthUnits2; |
| | 22274 | | _LengthUnits3 = LengthUnits3; |
| | 22275 | | _TimeUnits4 = TimeUnits4; |
| | 22276 | | } |
| | 22277 | |
|
| | 22278 | | #endregion |
| | 22279 | |
|
| | 22280 | | #region Properties |
| | 22281 | |
|
| | 22282 | | /// <summary>The #1 component of this measurements units.</summary> |
| | 22283 | | public Length.Units LengthUnits1 |
| | 22284 | | { |
| | 22285 | | get { return _LengthUnits1; } |
| | 22286 | | set |
| | 22287 | | { |
| | 22288 | | if (value != _LengthUnits1) |
| | 22289 | | { |
| | 22290 | | _measurement = this[value, _LengthUnits2, _LengthUnits3, _TimeUnits4]; |
| | 22291 | | _LengthUnits1 = value; |
| | 22292 | | } |
| | 22293 | | } |
| | 22294 | | } |
| | 22295 | |
|
| | 22296 | | /// <summary>The #2 component of this measurements units.</summary> |
| | 22297 | | public Length.Units LengthUnits2 |
| | 22298 | | { |
| | 22299 | | get { return _LengthUnits2; } |
| | 22300 | | set |
| | 22301 | | { |
| | 22302 | | if (value != _LengthUnits2) |
| | 22303 | | { |
| | 22304 | | _measurement = this[_LengthUnits1, value, _LengthUnits3, _TimeUnits4]; |
| | 22305 | | _LengthUnits2 = value; |
| | 22306 | | } |
| | 22307 | | } |
| | 22308 | | } |
| | 22309 | |
|
| | 22310 | | /// <summary>The #3 component of this measurements units.</summary> |
| | 22311 | | public Length.Units LengthUnits3 |
| | 22312 | | { |
| | 22313 | | get { return _LengthUnits3; } |
| | 22314 | | set |
| | 22315 | | { |
| | 22316 | | if (value != _LengthUnits3) |
| | 22317 | | { |
| | 22318 | | _measurement = this[_LengthUnits1, _LengthUnits2, value, _TimeUnits4]; |
| | 22319 | | _LengthUnits3 = value; |
| | 22320 | | } |
| | 22321 | | } |
| | 22322 | | } |
| | 22323 | |
|
| | 22324 | | /// <summary>The #4 component of this measurements units.</summary> |
| | 22325 | | public Time.Units TimeUnits4 |
| | 22326 | | { |
| | 22327 | | get { return _TimeUnits4; } |
| | 22328 | | set |
| | 22329 | | { |
| | 22330 | | if (value != _TimeUnits4) |
| | 22331 | | { |
| | 22332 | | _measurement = this[_LengthUnits1, _LengthUnits2, _LengthUnits3, value]; |
| | 22333 | | _TimeUnits4 = value; |
| | 22334 | | } |
| | 22335 | | } |
| | 22336 | | } |
| | 22337 | |
|
| | 22338 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 22339 | | /// <param name="units">The units to get the measurement in.</param> |
| | 22340 | | /// <returns>The measurement value in the specified units.</returns> |
| | 22341 | | public T this[MeasurementUnitsSyntaxTypes.VolumeRateBaseUnits units] |
| | 22342 | | { |
| | 22343 | | get { return this[units._LengthUnits1, units._LengthUnits2, units._LengthUnits3, units._TimeUnits4]; } |
| | 22344 | | } |
| | 22345 | |
|
| | 22346 | | /// <summary>Gets the measurement in the specified units.</summary> |
| | 22347 | | /// <param name="LengthUnits1">The #1 component of this measurements units.</param> |
| | 22348 | | /// <param name="LengthUnits2">The #2 component of this measurements units.</param> |
| | 22349 | | /// <param name="LengthUnits3">The #3 component of this measurements units.</param> |
| | 22350 | | /// <param name="TimeUnits4">The #4 component of this measurements units.</param> |
| | 22351 | | /// <returns>The measurement value in the specified units.</returns> |
| | 22352 | | public T this[Length.Units LengthUnits1, Length.Units LengthUnits2, Length.Units LengthUnits3, Time.Units TimeUnits4 |
| | 22353 | | { |
| | 22354 | | get |
| | 22355 | | { |
| | 22356 | | T measurement = _measurement; |
| | 22357 | | if (LengthUnits1 != _LengthUnits1) |
| | 22358 | | { |
| | 22359 | | measurement = Length<T>.Table[(int)_LengthUnits1][(int)LengthUnits1](measurement); |
| | 22360 | | //if (LengthUnits1 < _LengthUnits1) |
| | 22361 | | //{ |
| | 22362 | | // measurement = Length<T>.Table[(int)_LengthUnits1][(int)LengthUnits1](measurement); |
| | 22363 | | //} |
| | 22364 | | //else |
| | 22365 | | //{ |
| | 22366 | | // measurement = Length<T>.Table[(int)LengthUnits1][(int)_LengthUnits1](measurement); |
| | 22367 | | //} |
| | 22368 | | } |
| | 22369 | | if (LengthUnits2 != _LengthUnits2) |
| | 22370 | | { |
| | 22371 | | measurement = Length<T>.Table[(int)_LengthUnits2][(int)LengthUnits2](measurement); |
| | 22372 | | //if (LengthUnits2 < _LengthUnits2) |
| | 22373 | | //{ |
| | 22374 | | // measurement = Length<T>.Table[(int)_LengthUnits2][(int)LengthUnits2](measurement); |
| | 22375 | | //} |
| | 22376 | | //else |
| | 22377 | | //{ |
| | 22378 | | // measurement = Length<T>.Table[(int)LengthUnits2][(int)_LengthUnits2](measurement); |
| | 22379 | | //} |
| | 22380 | | } |
| | 22381 | | if (LengthUnits3 != _LengthUnits3) |
| | 22382 | | { |
| | 22383 | | measurement = Length<T>.Table[(int)_LengthUnits3][(int)LengthUnits3](measurement); |
| | 22384 | | //if (LengthUnits3 < _LengthUnits3) |
| | 22385 | | //{ |
| | 22386 | | // measurement = Length<T>.Table[(int)_LengthUnits3][(int)LengthUnits3](measurement); |
| | 22387 | | //} |
| | 22388 | | //else |
| | 22389 | | //{ |
| | 22390 | | // measurement = Length<T>.Table[(int)LengthUnits3][(int)_LengthUnits3](measurement); |
| | 22391 | | //} |
| | 22392 | | } |
| | 22393 | | if (TimeUnits4 != _TimeUnits4) |
| | 22394 | | { |
| | 22395 | | measurement = Time<T>.Table[(int)TimeUnits4][(int)_TimeUnits4](measurement); |
| | 22396 | | //if (TimeUnits4 > _TimeUnits4) |
| | 22397 | | //{ |
| | 22398 | | // measurement = Time<T>.Table[(int)_TimeUnits4][(int)TimeUnits4](measurement); |
| | 22399 | | //} |
| | 22400 | | //else |
| | 22401 | | //{ |
| | 22402 | | // measurement = Time<T>.Table[(int)TimeUnits4][(int)_TimeUnits4](measurement); |
| | 22403 | | //} |
| | 22404 | | } |
| | 22405 | | return measurement; |
| | 22406 | | } |
| | 22407 | | } |
| | 22408 | |
|
| | 22409 | | #endregion |
| | 22410 | |
|
| | 22411 | | #region Casting Operators |
| | 22412 | |
|
| | 22413 | | /// <summary>Converts a ValueTuple to a VolumeRate measurement.</summary> |
| | 22414 | | /// <param name="valueTuple">The ValueTuple to converted into a VolumeRate measurement.</param> |
| | 22415 | | public static implicit operator VolumeRate<T>((T, MeasurementUnitsSyntaxTypes.VolumeRateBaseUnits) valueTuple) |
| | 22416 | | { |
| | 22417 | | return new VolumeRate<T>(valueTuple.Item1, valueTuple.Item2); |
| | 22418 | | } |
| | 22419 | |
|
| | 22420 | | #endregion |
| | 22421 | |
|
| | 22422 | | #region Mathematics |
| | 22423 | |
|
| | 22424 | | #region Bases |
| | 22425 | |
|
| | 22426 | | internal static VolumeRate<T> MathBase(VolumeRate<T> a, T b, Func<T, T, T> func) |
| | 22427 | | { |
| | 22428 | | return new VolumeRate<T>(func(a._measurement, b) |
| | 22429 | | , a._LengthUnits1 |
| | 22430 | | , a._LengthUnits2 |
| | 22431 | | , a._LengthUnits3 |
| | 22432 | | , a._TimeUnits4 |
| | 22433 | | ); |
| | 22434 | | } |
| | 22435 | |
|
| | 22436 | | internal static VolumeRate<T> MathBase(VolumeRate<T> a, VolumeRate<T> b, Func<T, T, T> func) |
| | 22437 | | { |
| | 22438 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 22439 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 22440 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits3 ? a._LengthUnits3 : b._LengthUnits3; |
| | 22441 | | Time.Units TimeUnits4 = a._TimeUnits4 <= b._TimeUnits4 ? a._TimeUnits4 : b._TimeUnits4; |
| | 22442 | | T A = a[LengthUnits1, LengthUnits2, LengthUnits3, TimeUnits4]; |
| | 22443 | | T B = b[LengthUnits1, LengthUnits2, LengthUnits3, TimeUnits4]; |
| | 22444 | | T C = func(A, B); |
| | 22445 | | return new VolumeRate<T>(C, LengthUnits1, LengthUnits2, LengthUnits3, TimeUnits4); |
| | 22446 | | } |
| | 22447 | |
|
| | 22448 | | internal static bool LogicBase(VolumeRate<T> a, VolumeRate<T> b, Func<T, T, bool> func) |
| | 22449 | | { |
| | 22450 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 22451 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 22452 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits3 ? a._LengthUnits3 : b._LengthUnits3; |
| | 22453 | | Time.Units TimeUnits4 = a._TimeUnits4 <= b._TimeUnits4 ? a._TimeUnits4 : b._TimeUnits4; |
| | 22454 | | T A = a[LengthUnits1, LengthUnits2, LengthUnits3, TimeUnits4]; |
| | 22455 | | T B = b[LengthUnits1, LengthUnits2, LengthUnits3, TimeUnits4]; |
| | 22456 | | return func(A, B); |
| | 22457 | | } |
| | 22458 | |
|
| | 22459 | | #endregion |
| | 22460 | |
|
| | 22461 | | #region Add |
| | 22462 | |
|
| | 22463 | | /// <summary>Adds two VolumeRate measurements.</summary> |
| | 22464 | | /// <param name="a">The first operand of the addition.</param> |
| | 22465 | | /// <param name="b">The second operand of the addition.</param> |
| | 22466 | | /// <returns>The result of the addition operation.</returns> |
| | 22467 | | public static VolumeRate<T> Add(VolumeRate<T> a, VolumeRate<T> b) |
| | 22468 | | { |
| | 22469 | | return MathBase(a, b, Statics.Addition); |
| | 22470 | | } |
| | 22471 | |
|
| | 22472 | | /// <summary>Adds two VolumeRate measurements.</summary> |
| | 22473 | | /// <param name="a">The first operand of the addition.</param> |
| | 22474 | | /// <param name="b">The second operand of the addition.</param> |
| | 22475 | | /// <returns>The result of the addition operation.</returns> |
| | 22476 | | public static VolumeRate<T> operator +(VolumeRate<T> a, VolumeRate<T> b) |
| | 22477 | | { |
| | 22478 | | return Add(a, b); |
| | 22479 | | } |
| | 22480 | |
|
| | 22481 | | /// <summary>Adds two VolumeRate measurements.</summary> |
| | 22482 | | /// <param name="b">The second operand of the addition.</param> |
| | 22483 | | /// <returns>The result of the addition operation.</returns> |
| | 22484 | | public VolumeRate<T> Add(VolumeRate<T> b) |
| | 22485 | | { |
| | 22486 | | return this + b; |
| | 22487 | | } |
| | 22488 | |
|
| | 22489 | | #endregion |
| | 22490 | |
|
| | 22491 | | #region Subtract |
| | 22492 | |
|
| | 22493 | | /// <summary>Subtracts two VolumeRate measurements.</summary> |
| | 22494 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 22495 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 22496 | | /// <returns>The result of the subtraction.</returns> |
| | 22497 | | public static VolumeRate<T> Subtract(VolumeRate<T> a, VolumeRate<T> b) |
| | 22498 | | { |
| | 22499 | | return MathBase(a, b, Statics.Subtraction); |
| | 22500 | | } |
| | 22501 | |
|
| | 22502 | | /// <summary>Subtracts two VolumeRate measurements.</summary> |
| | 22503 | | /// <param name="a">The first operand of the subtraction.</param> |
| | 22504 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 22505 | | /// <returns>The result of the subtraction.</returns> |
| | 22506 | | public static VolumeRate<T> operator -(VolumeRate<T> a, VolumeRate<T> b) |
| | 22507 | | { |
| | 22508 | | return Subtract(a, b); |
| | 22509 | | } |
| | 22510 | |
|
| | 22511 | | /// <summary>Subtracts two VolumeRate measurements.</summary> |
| | 22512 | | /// <param name="b">The second operand of the subtraction.</param> |
| | 22513 | | /// <returns>The result of the subtraction.</returns> |
| | 22514 | | public VolumeRate<T> Subtract(VolumeRate<T> b) |
| | 22515 | | { |
| | 22516 | | return this - b; |
| | 22517 | | } |
| | 22518 | |
|
| | 22519 | | #endregion |
| | 22520 | |
|
| | 22521 | | #region Multiply |
| | 22522 | |
|
| | 22523 | | /// <summary>Multiplies an VolumeRate by a scalar numeric value.</summary> |
| | 22524 | | /// <param name="a">The VolumeRate measurement to multiply.</param> |
| | 22525 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 22526 | | /// <returns>The result of the multiplication.</returns> |
| | 22527 | | public static VolumeRate<T> Multiply(VolumeRate<T> a, T b) |
| | 22528 | | { |
| | 22529 | | return MathBase(a, b, Statics.Multiplication); |
| | 22530 | | } |
| | 22531 | |
|
| | 22532 | | /// <summary>Multiplies an VolumeRate by a scalar numeric value.</summary> |
| | 22533 | | /// <param name="a">The VolumeRate measurement to multiply.</param> |
| | 22534 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 22535 | | /// <returns>The result of the multiplication.</returns> |
| | 22536 | | public static VolumeRate<T> Multiply(T b, VolumeRate<T> a) |
| | 22537 | | { |
| | 22538 | | return Multiply(a, b); |
| | 22539 | | } |
| | 22540 | |
|
| | 22541 | | /// <summary>Multiplies an VolumeRate by a scalar numeric value.</summary> |
| | 22542 | | /// <param name="a">The VolumeRate measurement to multiply.</param> |
| | 22543 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 22544 | | /// <returns>The result of the multiplication.</returns> |
| | 22545 | | public static VolumeRate<T> operator *(VolumeRate<T> a, T b) |
| | 22546 | | { |
| | 22547 | | return Multiply(a, b); |
| | 22548 | | } |
| | 22549 | |
|
| | 22550 | | /// <summary>Multiplies an VolumeRate by a scalar numeric value.</summary> |
| | 22551 | | /// <param name="a">The VolumeRate measurement to multiply.</param> |
| | 22552 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 22553 | | /// <returns>The result of the multiplication.</returns> |
| | 22554 | | public static VolumeRate<T> operator *(T b, VolumeRate<T> a) |
| | 22555 | | { |
| | 22556 | | return Multiply(b, a); |
| | 22557 | | } |
| | 22558 | |
|
| | 22559 | | /// <summary>Multiplies an VolumeRate by a scalar numeric value.</summary> |
| | 22560 | | /// <param name="b">The scalar numeric value to multiply the measurement by.</param> |
| | 22561 | | /// <returns>The result of the multiplication.</returns> |
| | 22562 | | public VolumeRate<T> Add(T b) |
| | 22563 | | { |
| | 22564 | | return this * b; |
| | 22565 | | } |
| | 22566 | |
|
| | 22567 | | #region VolumeRate<T> * AreaDensity<T> = LinearMassFlow<T> |
| | 22568 | |
|
| | 22569 | | /// <summary>Mulitplies VolumeRate by AreaDensity resulting in LinearMassFlow.</summary> |
| | 22570 | | /// <param name="a">The VolumeRate to be multiplied.</param> |
| | 22571 | | /// <param name="b">The AreaDensity to multiply by.</param> |
| | 22572 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 22573 | | public static LinearMassFlow<T> Multiply(VolumeRate<T> a, AreaDensity<T> b) |
| | 22574 | | { |
| | 22575 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits2 ? a._LengthUnits1 : b._LengthUnits2; |
| | 22576 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits3 ? a._LengthUnits2 : b._LengthUnits3; |
| | 22577 | |
|
| | 22578 | | T A = a[LengthUnits1, LengthUnits2, a._LengthUnits3, a._TimeUnits4]; |
| | 22579 | | T B = b[b._MassUnits1, LengthUnits1, LengthUnits2]; |
| | 22580 | | T C = Statics.Multiplication(A, B); |
| | 22581 | |
|
| | 22582 | | return new LinearMassFlow<T>(C |
| | 22583 | | , b._MassUnits1 |
| | 22584 | | , a._LengthUnits3 |
| | 22585 | | , a._TimeUnits4 |
| | 22586 | | ); |
| | 22587 | | } |
| | 22588 | |
|
| | 22589 | | /// <summary>Mulitplies VolumeRate by AreaDensity resulting in LinearMassFlow.</summary> |
| | 22590 | | /// <param name="a">The VolumeRate to be multiplied.</param> |
| | 22591 | | /// <param name="b">The AreaDensity to multiply by.</param> |
| | 22592 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 22593 | | public static LinearMassFlow<T> operator *(VolumeRate<T> a, AreaDensity<T> b) |
| | 22594 | | { |
| | 22595 | | return Multiply(a, b); |
| | 22596 | | } |
| | 22597 | |
|
| | 22598 | | /// <summary>Mulitplies VolumeRate by AreaDensity resulting in LinearMassFlow.</summary> |
| | 22599 | | /// <param name="b">The AreaDensity to multiply by.</param> |
| | 22600 | | /// <returns>The LinearMassFlow result of the multiplication.</returns> |
| | 22601 | | public LinearMassFlow<T> Multiply(AreaDensity<T> b) |
| | 22602 | | { |
| | 22603 | | return this * b; |
| | 22604 | | } |
| | 22605 | |
|
| | 22606 | | #endregion |
| | 22607 | |
|
| | 22608 | | #region VolumeRate<T> * Density<T> = MassRate<T> |
| | 22609 | |
|
| | 22610 | | /// <summary>Mulitplies VolumeRate by Density resulting in MassRate.</summary> |
| | 22611 | | /// <param name="a">The VolumeRate to be multiplied.</param> |
| | 22612 | | /// <param name="b">The Density to multiply by.</param> |
| | 22613 | | /// <returns>The MassRate result of the multiplication.</returns> |
| | 22614 | | public static MassRate<T> Multiply(VolumeRate<T> a, Density<T> b) |
| | 22615 | | { |
| | 22616 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits2 ? a._LengthUnits1 : b._LengthUnits2; |
| | 22617 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits3 ? a._LengthUnits2 : b._LengthUnits3; |
| | 22618 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits4 ? a._LengthUnits3 : b._LengthUnits4; |
| | 22619 | |
|
| | 22620 | | T A = a[LengthUnits1, LengthUnits2, LengthUnits3, a._TimeUnits4]; |
| | 22621 | | T B = b[b._MassUnits1, LengthUnits1, LengthUnits2, LengthUnits3]; |
| | 22622 | | T C = Statics.Multiplication(A, B); |
| | 22623 | |
|
| | 22624 | | return new MassRate<T>(C |
| | 22625 | | , b._MassUnits1 |
| | 22626 | | , a._TimeUnits4 |
| | 22627 | | ); |
| | 22628 | | } |
| | 22629 | |
|
| | 22630 | | /// <summary>Mulitplies VolumeRate by Density resulting in MassRate.</summary> |
| | 22631 | | /// <param name="a">The VolumeRate to be multiplied.</param> |
| | 22632 | | /// <param name="b">The Density to multiply by.</param> |
| | 22633 | | /// <returns>The MassRate result of the multiplication.</returns> |
| | 22634 | | public static MassRate<T> operator *(VolumeRate<T> a, Density<T> b) |
| | 22635 | | { |
| | 22636 | | return Multiply(a, b); |
| | 22637 | | } |
| | 22638 | |
|
| | 22639 | | /// <summary>Mulitplies VolumeRate by Density resulting in MassRate.</summary> |
| | 22640 | | /// <param name="b">The Density to multiply by.</param> |
| | 22641 | | /// <returns>The MassRate result of the multiplication.</returns> |
| | 22642 | | public MassRate<T> Multiply(Density<T> b) |
| | 22643 | | { |
| | 22644 | | return this * b; |
| | 22645 | | } |
| | 22646 | |
|
| | 22647 | | #endregion |
| | 22648 | |
|
| | 22649 | | #region VolumeRate<T> * Pressure<T> = Power<T> |
| | 22650 | |
|
| | 22651 | | /// <summary>Mulitplies VolumeRate by Pressure resulting in Power.</summary> |
| | 22652 | | /// <param name="a">The VolumeRate to be multiplied.</param> |
| | 22653 | | /// <param name="b">The Pressure to multiply by.</param> |
| | 22654 | | /// <returns>The Power result of the multiplication.</returns> |
| | 22655 | | public static Power<T> Multiply(VolumeRate<T> a, Pressure<T> b) |
| | 22656 | | { |
| | 22657 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits2 ? a._LengthUnits1 : b._LengthUnits2; |
| | 22658 | |
|
| | 22659 | | T A = a[LengthUnits1, a._LengthUnits2, a._LengthUnits3, a._TimeUnits4]; |
| | 22660 | | T B = b[b._MassUnits1, LengthUnits1, b._TimeUnits3, b._TimeUnits4]; |
| | 22661 | | T C = Statics.Multiplication(A, B); |
| | 22662 | |
|
| | 22663 | | return new Power<T>(C |
| | 22664 | | , b._MassUnits1 |
| | 22665 | | , a._LengthUnits2 |
| | 22666 | | , a._LengthUnits3 |
| | 22667 | | , a._TimeUnits4 |
| | 22668 | | , b._TimeUnits3 |
| | 22669 | | , b._TimeUnits4 |
| | 22670 | | ); |
| | 22671 | | } |
| | 22672 | |
|
| | 22673 | | /// <summary>Mulitplies VolumeRate by Pressure resulting in Power.</summary> |
| | 22674 | | /// <param name="a">The VolumeRate to be multiplied.</param> |
| | 22675 | | /// <param name="b">The Pressure to multiply by.</param> |
| | 22676 | | /// <returns>The Power result of the multiplication.</returns> |
| | 22677 | | public static Power<T> operator *(VolumeRate<T> a, Pressure<T> b) |
| | 22678 | | { |
| | 22679 | | return Multiply(a, b); |
| | 22680 | | } |
| | 22681 | |
|
| | 22682 | | /// <summary>Mulitplies VolumeRate by Pressure resulting in Power.</summary> |
| | 22683 | | /// <param name="b">The Pressure to multiply by.</param> |
| | 22684 | | /// <returns>The Power result of the multiplication.</returns> |
| | 22685 | | public Power<T> Multiply(Pressure<T> b) |
| | 22686 | | { |
| | 22687 | | return this * b; |
| | 22688 | | } |
| | 22689 | |
|
| | 22690 | | #endregion |
| | 22691 | |
|
| | 22692 | | #region VolumeRate<T> * Time<T> = Volume<T> |
| | 22693 | |
|
| | 22694 | | /// <summary>Mulitplies VolumeRate by Time resulting in Volume.</summary> |
| | 22695 | | /// <param name="a">The VolumeRate to be multiplied.</param> |
| | 22696 | | /// <param name="b">The Time to multiply by.</param> |
| | 22697 | | /// <returns>The Volume result of the multiplication.</returns> |
| | 22698 | | public static Volume<T> Multiply(VolumeRate<T> a, Time<T> b) |
| | 22699 | | { |
| | 22700 | | Time.Units TimeUnits1 = a._TimeUnits4 <= b._TimeUnits1 ? a._TimeUnits4 : b._TimeUnits1; |
| | 22701 | |
|
| | 22702 | | T A = a[a._LengthUnits1, a._LengthUnits2, a._LengthUnits3, TimeUnits1]; |
| | 22703 | | T B = b[TimeUnits1]; |
| | 22704 | | T C = Statics.Multiplication(A, B); |
| | 22705 | |
|
| | 22706 | | return new Volume<T>(C |
| | 22707 | | , a._LengthUnits1 |
| | 22708 | | , a._LengthUnits2 |
| | 22709 | | , a._LengthUnits3 |
| | 22710 | | ); |
| | 22711 | | } |
| | 22712 | |
|
| | 22713 | | /// <summary>Mulitplies VolumeRate by Time resulting in Volume.</summary> |
| | 22714 | | /// <param name="a">The VolumeRate to be multiplied.</param> |
| | 22715 | | /// <param name="b">The Time to multiply by.</param> |
| | 22716 | | /// <returns>The Volume result of the multiplication.</returns> |
| | 22717 | | public static Volume<T> operator *(VolumeRate<T> a, Time<T> b) |
| | 22718 | | { |
| | 22719 | | return Multiply(a, b); |
| | 22720 | | } |
| | 22721 | |
|
| | 22722 | | /// <summary>Mulitplies VolumeRate by Time resulting in Volume.</summary> |
| | 22723 | | /// <param name="b">The Time to multiply by.</param> |
| | 22724 | | /// <returns>The Volume result of the multiplication.</returns> |
| | 22725 | | public Volume<T> Multiply(Time<T> b) |
| | 22726 | | { |
| | 22727 | | return this * b; |
| | 22728 | | } |
| | 22729 | |
|
| | 22730 | | #endregion |
| | 22731 | |
|
| | 22732 | | #endregion |
| | 22733 | |
|
| | 22734 | | #region Divide |
| | 22735 | |
|
| | 22736 | | /// <summary>Divides an VolumeRate measurement by another VolumeRate measurement resulting in a scalar numeric value |
| | 22737 | | /// <param name="a">The first operand of the division operation.</param> |
| | 22738 | | /// <param name="b">The second operand of the division operation.</param> |
| | 22739 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 22740 | | public static T Divide(VolumeRate<T> a, VolumeRate<T> b) |
| | 22741 | | { |
| | 22742 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 22743 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 22744 | | Length.Units LengthUnits3 = a._LengthUnits3 <= b._LengthUnits3 ? a._LengthUnits3 : b._LengthUnits3; |
| | 22745 | | Time.Units TimeUnits4 = a._TimeUnits4 <= b._TimeUnits4 ? a._TimeUnits4 : b._TimeUnits4; |
| | 22746 | | T A = a[LengthUnits1, LengthUnits2, LengthUnits3, TimeUnits4]; |
| | 22747 | | T B = b[LengthUnits1, LengthUnits2, LengthUnits3, TimeUnits4]; |
| | 22748 | | return Statics.Division(A, B); |
| | 22749 | | } |
| | 22750 | |
|
| | 22751 | | /// <summary>Divides this VolumeRate measurement by a numaric scalar value.</summary> |
| | 22752 | | /// <param name="a">The VolumeRate measurement to divide.</param> |
| | 22753 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 22754 | | /// <returns>The result of the division.</returns> |
| | 22755 | | public static VolumeRate<T> Divide(VolumeRate<T> a, T b) |
| | 22756 | | { |
| | 22757 | | return MathBase(a, b, Statics.Division); |
| | 22758 | | } |
| | 22759 | |
|
| | 22760 | | /// <summary>Divides this VolumeRate measurement by a numaric scalar value.</summary> |
| | 22761 | | /// <param name="a">The VolumeRate measurement to divide.</param> |
| | 22762 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 22763 | | /// <returns>The result of the division.</returns> |
| | 22764 | | public static VolumeRate<T> operator /(VolumeRate<T> a, T b) |
| | 22765 | | { |
| | 22766 | | return Divide(a, b); |
| | 22767 | | } |
| | 22768 | |
|
| | 22769 | | /// <summary>Divides this VolumeRate measurement by a numaric scalar value.</summary> |
| | 22770 | | /// <param name="b">The numeric scalar to divide by.</param> |
| | 22771 | | /// <returns>The result of the division.</returns> |
| | 22772 | | public VolumeRate<T> Divide(T b) |
| | 22773 | | { |
| | 22774 | | return this / b; |
| | 22775 | | } |
| | 22776 | |
|
| | 22777 | | /// <summary>Divides an VolumeRate measurement by another VolumeRate measurement resulting in a scalar numeric value |
| | 22778 | | /// <param name="a">The first operand of the division operation.</param> |
| | 22779 | | /// <param name="b">The second operand of the division operation.</param> |
| | 22780 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 22781 | | public static T operator /(VolumeRate<T> a, VolumeRate<T> b) |
| | 22782 | | { |
| | 22783 | | return Divide(a, b); |
| | 22784 | | } |
| | 22785 | |
|
| | 22786 | | /// <summary>Divides an VolumeRate measurement by another VolumeRate measurement resulting in a scalar numeric value |
| | 22787 | | /// <param name="b">The second operand of the division operation.</param> |
| | 22788 | | /// <returns>The scalar numeric value result from the division.</returns> |
| | 22789 | | public T Divide(VolumeRate<T> b) |
| | 22790 | | { |
| | 22791 | | return this / b; |
| | 22792 | | } |
| | 22793 | |
|
| | 22794 | |
|
| | 22795 | | #region VolumeRate<T> / Area<T> = Speed<T> |
| | 22796 | |
|
| | 22797 | | /// <summary>Divides VolumeRate by Area resulting in Speed.</summary> |
| | 22798 | | /// <param name="a">The VolumeRate to be divided.</param> |
| | 22799 | | /// <param name="b">The Area to divide by.</param> |
| | 22800 | | /// <returns>The Speed result of the division.</returns> |
| | 22801 | | public static Speed<T> Divide(VolumeRate<T> a, Area<T> b) |
| | 22802 | | { |
| | 22803 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 22804 | | Length.Units LengthUnits2 = a._LengthUnits2 <= b._LengthUnits2 ? a._LengthUnits2 : b._LengthUnits2; |
| | 22805 | |
|
| | 22806 | | T A = a[LengthUnits1, LengthUnits2, a._LengthUnits3, a._TimeUnits4]; |
| | 22807 | | T B = b[LengthUnits1, LengthUnits2]; |
| | 22808 | | T C = Statics.Division(A, B); |
| | 22809 | |
|
| | 22810 | | return new Speed<T>(C |
| | 22811 | | , a._LengthUnits3 |
| | 22812 | | , a._TimeUnits4 |
| | 22813 | | ); |
| | 22814 | | } |
| | 22815 | |
|
| | 22816 | | /// <summary>Divides VolumeRate by Area resulting in Speed.</summary> |
| | 22817 | | /// <param name="a">The VolumeRate to be divided.</param> |
| | 22818 | | /// <param name="b">The Area to divide by.</param> |
| | 22819 | | /// <returns>The Speed result of the division.</returns> |
| | 22820 | | public static Speed<T> operator /(VolumeRate<T> a, Area<T> b) |
| | 22821 | | { |
| | 22822 | | return Divide(a, b); |
| | 22823 | | } |
| | 22824 | |
|
| | 22825 | | /// <summary>Divides VolumeRate by Area resulting in Speed.</summary> |
| | 22826 | | /// <param name="b">The Area to divide by.</param> |
| | 22827 | | /// <returns>The Speed result of the division.</returns> |
| | 22828 | | public Speed<T> Divide(Area<T> b) |
| | 22829 | | { |
| | 22830 | | return this / b; |
| | 22831 | | } |
| | 22832 | |
|
| | 22833 | | #endregion |
| | 22834 | |
|
| | 22835 | |
|
| | 22836 | | #region VolumeRate<T> / Speed<T> = Area<T> |
| | 22837 | |
|
| | 22838 | | /// <summary>Divides VolumeRate by Speed resulting in Area.</summary> |
| | 22839 | | /// <param name="a">The VolumeRate to be divided.</param> |
| | 22840 | | /// <param name="b">The Speed to divide by.</param> |
| | 22841 | | /// <returns>The Area result of the division.</returns> |
| | 22842 | | public static Area<T> Divide(VolumeRate<T> a, Speed<T> b) |
| | 22843 | | { |
| | 22844 | | Length.Units LengthUnits1 = a._LengthUnits1 <= b._LengthUnits1 ? a._LengthUnits1 : b._LengthUnits1; |
| | 22845 | | Time.Units TimeUnits2 = a._TimeUnits4 <= b._TimeUnits2 ? a._TimeUnits4 : b._TimeUnits2; |
| | 22846 | |
|
| | 22847 | | T A = a[LengthUnits1, a._LengthUnits2, a._LengthUnits3, TimeUnits2]; |
| | 22848 | | T B = b[LengthUnits1, TimeUnits2]; |
| | 22849 | | T C = Statics.Division(A, B); |
| | 22850 | |
|
| | 22851 | | return new Area<T>(C |
| | 22852 | | , a._LengthUnits2 |
| | 22853 | | , a._LengthUnits3 |
| | 22854 | | ); |
| | 22855 | | } |
| | 22856 | |
|
| | 22857 | | /// <summary>Divides VolumeRate by Speed resulting in Area.</summary> |
| | 22858 | | /// <param name="a">The VolumeRate to be divided.</param> |
| | 22859 | | /// <param name="b">The Speed to divide by.</param> |
| | 22860 | | /// <returns>The Area result of the division.</returns> |
| | 22861 | | public static Area<T> operator /(VolumeRate<T> a, Speed<T> b) |
| | 22862 | | { |
| | 22863 | | return Divide(a, b); |
| | 22864 | | } |
| | 22865 | |
|
| | 22866 | | /// <summary>Divides VolumeRate by Speed resulting in Area.</summary> |
| | 22867 | | /// <param name="b">The Speed to divide by.</param> |
| | 22868 | | /// <returns>The Area result of the division.</returns> |
| | 22869 | | public Area<T> Divide(Speed<T> b) |
| | 22870 | | { |
| | 22871 | | return this / b; |
| | 22872 | | } |
| | 22873 | |
|
| | 22874 | | #endregion |
| | 22875 | |
|
| | 22876 | | #endregion |
| | 22877 | |
|
| | 22878 | | #region LessThan |
| | 22879 | |
|
| | 22880 | | /// <summary>Determines if an VolumeRate measurement is less than another VolumeRate measurement.</summary> |
| | 22881 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 22882 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 22883 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 22884 | | public static bool LessThan(VolumeRate<T> a, VolumeRate<T> b) |
| | 22885 | | { |
| | 22886 | | return LogicBase(a, b, Statics.LessThan); |
| | 22887 | | } |
| | 22888 | |
|
| | 22889 | | /// <summary>Determines if an VolumeRate measurement is less than another VolumeRate measurement.</summary> |
| | 22890 | | /// <param name="a">The first operand of the less than operation.</param> |
| | 22891 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 22892 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 22893 | | public static bool operator <(VolumeRate<T> a, VolumeRate<T> b) |
| | 22894 | | { |
| | 22895 | | return LessThan(a, b); |
| | 22896 | | } |
| | 22897 | |
|
| | 22898 | | /// <summary>Determines if an VolumeRate measurement is less than another VolumeRate measurement.</summary> |
| | 22899 | | /// <param name="b">The second operand of the less than operation.</param> |
| | 22900 | | /// <returns>True if the first operand is less than the second operand. False if not.</returns> |
| | 22901 | | public bool LessThan(VolumeRate<T> b) |
| | 22902 | | { |
| | 22903 | | return this < b; |
| | 22904 | | } |
| | 22905 | |
|
| | 22906 | | #endregion |
| | 22907 | |
|
| | 22908 | | #region GreaterThan |
| | 22909 | |
|
| | 22910 | | /// <summary>Determines if an VolumeRate measurement is greater than another VolumeRate measurement.</summary> |
| | 22911 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 22912 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 22913 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 22914 | | public static bool GreaterThan(VolumeRate<T> a, VolumeRate<T> b) |
| | 22915 | | { |
| | 22916 | | return LogicBase(a, b, Statics.GreaterThan); |
| | 22917 | | } |
| | 22918 | |
|
| | 22919 | | /// <summary>Determines if an VolumeRate measurement is greater than another VolumeRate measurement.</summary> |
| | 22920 | | /// <param name="a">The first operand of the greater than operation.</param> |
| | 22921 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 22922 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 22923 | | public static bool operator >(VolumeRate<T> a, VolumeRate<T> b) |
| | 22924 | | { |
| | 22925 | | return GreaterThan(a, b); |
| | 22926 | | } |
| | 22927 | |
|
| | 22928 | | /// <summary>Determines if an VolumeRate measurement is greater than another VolumeRate measurement.</summary> |
| | 22929 | | /// <param name="b">The second operand of the greater than operation.</param> |
| | 22930 | | /// <returns>True if the first operand is greater than the second operand. False if not.</returns> |
| | 22931 | | public bool GreaterThan(VolumeRate<T> b) |
| | 22932 | | { |
| | 22933 | | return this > b; |
| | 22934 | | } |
| | 22935 | |
|
| | 22936 | | #endregion |
| | 22937 | |
|
| | 22938 | | #region LessThanOrEqual |
| | 22939 | |
|
| | 22940 | | /// <summary>Determines if an VolumeRate measurement is less than or equal to another VolumeRate measurement.</summa |
| | 22941 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 22942 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 22943 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 22944 | | public static bool LessThanOrEqual(VolumeRate<T> a, VolumeRate<T> b) |
| | 22945 | | { |
| | 22946 | | return LogicBase(a, b, Statics.LessThanOrEqual); |
| | 22947 | | } |
| | 22948 | |
|
| | 22949 | | /// <summary>Determines if an VolumeRate measurement is less than or equal to another VolumeRate measurement.</summa |
| | 22950 | | /// <param name="a">The first operand of the less than or equal to operation.</param> |
| | 22951 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 22952 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 22953 | | public static bool operator <=(VolumeRate<T> a, VolumeRate<T> b) |
| | 22954 | | { |
| | 22955 | | return LessThanOrEqual(a, b); |
| | 22956 | | } |
| | 22957 | |
|
| | 22958 | | /// <summary>Determines if an VolumeRate measurement is less than or equal to another VolumeRate measurement.</summa |
| | 22959 | | /// <param name="b">The second operand of the less than or equal to operation.</param> |
| | 22960 | | /// <returns>True if the first operand is less than or equal to the second operand. False if not.</returns> |
| | 22961 | | public bool LessThanOrEqual(VolumeRate<T> b) |
| | 22962 | | { |
| | 22963 | | return this <= b; |
| | 22964 | | } |
| | 22965 | |
|
| | 22966 | | #endregion |
| | 22967 | |
|
| | 22968 | | #region GreaterThanOrEqual |
| | 22969 | |
|
| | 22970 | | /// <summary>Determines if an VolumeRate measurement is greater than or equal to another VolumeRate measurement.</su |
| | 22971 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 22972 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 22973 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 22974 | | public static bool GreaterThanOrEqual(VolumeRate<T> a, VolumeRate<T> b) |
| | 22975 | | { |
| | 22976 | | return LogicBase(a, b, Statics.GreaterThanOrEqual); |
| | 22977 | | } |
| | 22978 | |
|
| | 22979 | | /// <summary>Determines if an VolumeRate measurement is greater than or equal to another VolumeRate measurement.</su |
| | 22980 | | /// <param name="a">The first operand of the greater than or equal to operation.</param> |
| | 22981 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 22982 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 22983 | | public static bool operator >=(VolumeRate<T> a, VolumeRate<T> b) |
| | 22984 | | { |
| | 22985 | | return GreaterThanOrEqual(a, b); |
| | 22986 | | } |
| | 22987 | |
|
| | 22988 | | /// <summary>Determines if an VolumeRate measurement is greater than or equal to another VolumeRate measurement.</su |
| | 22989 | | /// <param name="b">The second operand of the greater than or equal to operation.</param> |
| | 22990 | | /// <returns>True if the first operand is greater than or equal to the second operand. False if not.</returns> |
| | 22991 | | public bool GreaterThanOrEqual(VolumeRate<T> b) |
| | 22992 | | { |
| | 22993 | | return this >= b; |
| | 22994 | | } |
| | 22995 | |
|
| | 22996 | | #endregion |
| | 22997 | |
|
| | 22998 | | #region Equal |
| | 22999 | |
|
| | 23000 | | /// <summary>Determines if an VolumeRate measurement is equal to another VolumeRate measurement.</summary> |
| | 23001 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 23002 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 23003 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 23004 | | public static bool Equal(VolumeRate<T> a, VolumeRate<T> b) |
| | 23005 | | { |
| | 23006 | | return LogicBase(a, b, Statics.Equate); |
| | 23007 | | } |
| | 23008 | |
|
| | 23009 | | /// <summary>Determines if an VolumeRate measurement is equal to another VolumeRate measurement.</summary> |
| | 23010 | | /// <param name="a">The first operand of the equal to operation.</param> |
| | 23011 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 23012 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 23013 | | public static bool operator ==(VolumeRate<T> a, VolumeRate<T> b) |
| | 23014 | | { |
| | 23015 | | return Equal(a, b); |
| | 23016 | | } |
| | 23017 | |
|
| | 23018 | | /// <summary>Determines if an VolumeRate measurement is equal to another VolumeRate measurement.</summary> |
| | 23019 | | /// <param name="b">The second operand of the equal to operation.</param> |
| | 23020 | | /// <returns>True if the first operand is equal to the second operand. False if not.</returns> |
| | 23021 | | public bool Equal(VolumeRate<T> b) |
| | 23022 | | { |
| | 23023 | | return this == b; |
| | 23024 | | } |
| | 23025 | |
|
| | 23026 | | #endregion |
| | 23027 | |
|
| | 23028 | | #region NotEqual |
| | 23029 | |
|
| | 23030 | | /// <summary>Determines if an VolumeRate measurement is not equal to another VolumeRate measurement.</summary> |
| | 23031 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 23032 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 23033 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 23034 | | public static bool NotEqual(VolumeRate<T> a, VolumeRate<T> b) |
| | 23035 | | { |
| | 23036 | | return LogicBase(a, b, Statics.Inequate); |
| | 23037 | | } |
| | 23038 | |
|
| | 23039 | | /// <summary>Determines if an VolumeRate measurement is not equal to another VolumeRate measurement.</summary> |
| | 23040 | | /// <param name="a">The first operand of the not equal to operation.</param> |
| | 23041 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 23042 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 23043 | | public static bool operator !=(VolumeRate<T> a, VolumeRate<T> b) |
| | 23044 | | { |
| | 23045 | | return NotEqual(a, b); |
| | 23046 | | } |
| | 23047 | |
|
| | 23048 | | /// <summary>Determines if an VolumeRate measurement is not equal to another VolumeRate measurement.</summary> |
| | 23049 | | /// <param name="b">The second operand of the not equal to operation.</param> |
| | 23050 | | /// <returns>True if the first operand is not equal to the second operand. False if not.</returns> |
| | 23051 | | public bool NotEqual(VolumeRate<T> b) |
| | 23052 | | { |
| | 23053 | | return this != b; |
| | 23054 | | } |
| | 23055 | |
|
| | 23056 | | #endregion |
| | 23057 | |
|
| | 23058 | | #endregion |
| | 23059 | |
|
| | 23060 | | #region Overrides |
| | 23061 | |
|
| | 23062 | | /// <summary>Base Equals override that performs a type and value equality check.</summary> |
| | 23063 | | /// <param name="obj">The object to check for equality with.</param> |
| | 23064 | | /// <returns>True if the types and values equal. False if not.</returns> |
| | 23065 | | public override bool Equals(object obj) |
| | 23066 | | { |
| | 23067 | | if (obj is VolumeRate<T>) |
| | 23068 | | { |
| | 23069 | | return this == (VolumeRate<T>)obj; |
| | 23070 | | } |
| | 23071 | | return false; |
| | 23072 | | } |
| | 23073 | |
|
| | 23074 | | /// <summary>Converts the VolumeRate measurement to a string represenation.</summary> |
| | 23075 | | /// <returns>The string representation of the measurement.</returns> |
| | 23076 | | public override string ToString() |
| | 23077 | | { |
| | 23078 | | return _measurement + " " + |
| | 23079 | | _LengthUnits1 + "*" + _LengthUnits2 + "*" + _LengthUnits3 |
| | 23080 | | + "/" + |
| | 23081 | | _TimeUnits4 |
| | 23082 | | ; |
| | 23083 | | } |
| | 23084 | |
|
| | 23085 | | /// <summary>Base hashing function for VolumeRate measurements.</summary> |
| | 23086 | | /// <returns>Computed hash code for this instance.</returns> |
| | 23087 | | public override int GetHashCode() => Hash(_measurement); |
| | 23088 | |
|
| | 23089 | | #endregion |
| | 23090 | | } |
| | 23091 | |
|
| | 23092 | | #endregion |
| | 23093 | |
|
| | 23094 | |
|
| | 23095 | | #region MeasurementUnitsSyntaxTypes |
| | 23096 | |
|
| | 23097 | | #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member |
| | 23098 | |
|
| | 23099 | | public static class MeasurementUnitsSyntaxTypes |
| | 23100 | | { |
| | 23101 | | public struct AccelerationBaseUnits : Measurement.IUnits<AccelerationBaseUnits> |
| | 23102 | | { |
| | 23103 | | public Length.Units _LengthUnits1; |
| | 23104 | | public Time.Units _TimeUnits2; |
| | 23105 | | public Time.Units _TimeUnits3; |
| | 23106 | |
|
| | 23107 | | public AccelerationBaseUnits(Length.Units LengthUnits1, Time.Units TimeUnits2, Time.Units TimeUnits3) |
| | 23108 | | { |
| | 23109 | | _LengthUnits1 = LengthUnits1; |
| | 23110 | | _TimeUnits2 = TimeUnits2; |
| | 23111 | | _TimeUnits3 = TimeUnits3; |
| | 23112 | | } |
| | 23113 | |
|
| | 23114 | | public T Convert<T>(T value, |
| | 23115 | | AccelerationBaseUnits from, |
| | 23116 | | AccelerationBaseUnits to) |
| | 23117 | | { |
| | 23118 | | return Acceleration<T>.Convert(value, from, to); |
| | 23119 | | } |
| | 23120 | |
|
| | 23121 | |
|
| | 23122 | | public static EnergyBaseUnits operator *(AccelerationBaseUnits a, LinearMassBaseUnits b) |
| | 23123 | | { |
| | 23124 | | return new EnergyBaseUnits(b._MassUnits1, a._LengthUnits1, b._LengthUnits2, a._TimeUnits2, a._TimeUnits3); |
| | 23125 | | } |
| | 23126 | |
|
| | 23127 | | public static PowerBaseUnits operator *(AccelerationBaseUnits a, LinearMassFlowBaseUnits b) |
| | 23128 | | { |
| | 23129 | | return new PowerBaseUnits(b._MassUnits1, a._LengthUnits1, b._LengthUnits2, a._TimeUnits2, a._TimeUnits3, b._Time |
| | 23130 | | } |
| | 23131 | |
|
| | 23132 | | public static ForceBaseUnits operator *(AccelerationBaseUnits a, MassUnits b) |
| | 23133 | | { |
| | 23134 | | return new ForceBaseUnits(b._MassUnits1, a._LengthUnits1, a._TimeUnits2, a._TimeUnits3); |
| | 23135 | | } |
| | 23136 | |
|
| | 23137 | |
|
| | 23138 | | } |
| | 23139 | |
|
| | 23140 | | public struct AngularAccelerationBaseUnits : Measurement.IUnits<AngularAccelerationBaseUnits> |
| | 23141 | | { |
| | 23142 | | public Angle.Units _AngleUnits1; |
| | 23143 | | public Time.Units _TimeUnits2; |
| | 23144 | | public Time.Units _TimeUnits3; |
| | 23145 | |
|
| | 23146 | | public AngularAccelerationBaseUnits(Angle.Units AngleUnits1, Time.Units TimeUnits2, Time.Units TimeUnits3) |
| | 23147 | | { |
| | 23148 | | _AngleUnits1 = AngleUnits1; |
| | 23149 | | _TimeUnits2 = TimeUnits2; |
| | 23150 | | _TimeUnits3 = TimeUnits3; |
| | 23151 | | } |
| | 23152 | |
|
| | 23153 | | public T Convert<T>(T value, |
| | 23154 | | AngularAccelerationBaseUnits from, |
| | 23155 | | AngularAccelerationBaseUnits to) |
| | 23156 | | { |
| | 23157 | | return AngularAcceleration<T>.Convert(value, from, to); |
| | 23158 | | } |
| | 23159 | |
|
| | 23160 | |
|
| | 23161 | | } |
| | 23162 | |
|
| | 23163 | | public struct AngleUnits : Measurement.IUnits<AngleUnits> |
| | 23164 | | { |
| | 23165 | | public Angle.Units _AngleUnits1; |
| | 23166 | |
|
| | 23167 | | public AngleUnits(Angle.Units AngleUnits1) |
| | 23168 | | { |
| | 23169 | | _AngleUnits1 = AngleUnits1; |
| | 23170 | | } |
| | 23171 | |
|
| | 23172 | | public T Convert<T>(T value, |
| | 23173 | | AngleUnits from, |
| | 23174 | | AngleUnits to) |
| | 23175 | | { |
| | 23176 | | return Angle<T>.Convert(value, from, to); |
| | 23177 | | } |
| | 23178 | |
|
| | 23179 | |
|
| | 23180 | |
|
| | 23181 | | public static AngularSpeedBaseUnits operator /(AngleUnits a, TimeUnits b) |
| | 23182 | | { |
| | 23183 | | return new AngularSpeedBaseUnits(a._AngleUnits1, b._TimeUnits1); |
| | 23184 | | } |
| | 23185 | |
|
| | 23186 | | public static AngularAccelerationBaseUnits operator /(AngleUnits a, TimeAreaBaseUnits b) |
| | 23187 | | { |
| | 23188 | | return new AngularAccelerationBaseUnits(a._AngleUnits1, b._TimeUnits1, b._TimeUnits2); |
| | 23189 | | } |
| | 23190 | | } |
| | 23191 | |
|
| | 23192 | | public struct AngularSpeedBaseUnits : Measurement.IUnits<AngularSpeedBaseUnits> |
| | 23193 | | { |
| | 23194 | | public Angle.Units _AngleUnits1; |
| | 23195 | | public Time.Units _TimeUnits2; |
| | 23196 | |
|
| | 23197 | | public AngularSpeedBaseUnits(Angle.Units AngleUnits1, Time.Units TimeUnits2) |
| | 23198 | | { |
| | 23199 | | _AngleUnits1 = AngleUnits1; |
| | 23200 | | _TimeUnits2 = TimeUnits2; |
| | 23201 | | } |
| | 23202 | |
|
| | 23203 | | public T Convert<T>(T value, |
| | 23204 | | AngularSpeedBaseUnits from, |
| | 23205 | | AngularSpeedBaseUnits to) |
| | 23206 | | { |
| | 23207 | | return AngularSpeed<T>.Convert(value, from, to); |
| | 23208 | | } |
| | 23209 | |
|
| | 23210 | |
|
| | 23211 | |
|
| | 23212 | | public static AngularAccelerationBaseUnits operator /(AngularSpeedBaseUnits a, TimeUnits b) |
| | 23213 | | { |
| | 23214 | | return new AngularAccelerationBaseUnits(a._AngleUnits1, a._TimeUnits2, b._TimeUnits1); |
| | 23215 | | } |
| | 23216 | | } |
| | 23217 | |
|
| | 23218 | | public struct AreaBaseUnits : Measurement.IUnits<AreaBaseUnits> |
| | 23219 | | { |
| | 23220 | | public Length.Units _LengthUnits1; |
| | 23221 | | public Length.Units _LengthUnits2; |
| | 23222 | |
|
| | 23223 | | public AreaBaseUnits(Length.Units LengthUnits1, Length.Units LengthUnits2) |
| | 23224 | | { |
| | 23225 | | _LengthUnits1 = LengthUnits1; |
| | 23226 | | _LengthUnits2 = LengthUnits2; |
| | 23227 | | } |
| | 23228 | |
|
| | 23229 | | public T Convert<T>(T value, |
| | 23230 | | AreaBaseUnits from, |
| | 23231 | | AreaBaseUnits to) |
| | 23232 | | { |
| | 23233 | | return Area<T>.Convert(value, from, to); |
| | 23234 | | } |
| | 23235 | |
|
| | 23236 | |
|
| | 23237 | |
|
| | 23238 | | public static VolumeBaseUnits operator *(AreaBaseUnits a, LengthUnits b) |
| | 23239 | | { |
| | 23240 | | return new VolumeBaseUnits(a._LengthUnits1, a._LengthUnits2, b._LengthUnits1); |
| | 23241 | | } |
| | 23242 | |
|
| | 23243 | |
|
| | 23244 | |
|
| | 23245 | | public static VolumeRateBaseUnits operator *(AreaBaseUnits a, SpeedBaseUnits b) |
| | 23246 | | { |
| | 23247 | | return new VolumeRateBaseUnits(a._LengthUnits1, a._LengthUnits2, b._LengthUnits1, b._TimeUnits2); |
| | 23248 | | } |
| | 23249 | |
|
| | 23250 | | } |
| | 23251 | |
|
| | 23252 | | public struct AreaDensityBaseUnits : Measurement.IUnits<AreaDensityBaseUnits> |
| | 23253 | | { |
| | 23254 | | public Mass.Units _MassUnits1; |
| | 23255 | | public Length.Units _LengthUnits2; |
| | 23256 | | public Length.Units _LengthUnits3; |
| | 23257 | |
|
| | 23258 | | public AreaDensityBaseUnits(Mass.Units MassUnits1, Length.Units LengthUnits2, Length.Units LengthUnits3) |
| | 23259 | | { |
| | 23260 | | _MassUnits1 = MassUnits1; |
| | 23261 | | _LengthUnits2 = LengthUnits2; |
| | 23262 | | _LengthUnits3 = LengthUnits3; |
| | 23263 | | } |
| | 23264 | |
|
| | 23265 | | public T Convert<T>(T value, |
| | 23266 | | AreaDensityBaseUnits from, |
| | 23267 | | AreaDensityBaseUnits to) |
| | 23268 | | { |
| | 23269 | | return AreaDensity<T>.Convert(value, from, to); |
| | 23270 | | } |
| | 23271 | |
|
| | 23272 | |
|
| | 23273 | |
|
| | 23274 | |
|
| | 23275 | |
|
| | 23276 | |
|
| | 23277 | |
|
| | 23278 | | public static DensityBaseUnits operator /(AreaDensityBaseUnits a, LengthUnits b) |
| | 23279 | | { |
| | 23280 | | return new DensityBaseUnits(a._MassUnits1, a._LengthUnits2, a._LengthUnits3, b._LengthUnits1); |
| | 23281 | | } |
| | 23282 | | } |
| | 23283 | |
|
| | 23284 | | public struct DensityBaseUnits : Measurement.IUnits<DensityBaseUnits> |
| | 23285 | | { |
| | 23286 | | public Mass.Units _MassUnits1; |
| | 23287 | | public Length.Units _LengthUnits2; |
| | 23288 | | public Length.Units _LengthUnits3; |
| | 23289 | | public Length.Units _LengthUnits4; |
| | 23290 | |
|
| | 23291 | | public DensityBaseUnits(Mass.Units MassUnits1, Length.Units LengthUnits2, Length.Units LengthUnits3, Length.Units |
| | 23292 | | { |
| | 23293 | | _MassUnits1 = MassUnits1; |
| | 23294 | | _LengthUnits2 = LengthUnits2; |
| | 23295 | | _LengthUnits3 = LengthUnits3; |
| | 23296 | | _LengthUnits4 = LengthUnits4; |
| | 23297 | | } |
| | 23298 | |
|
| | 23299 | | public T Convert<T>(T value, |
| | 23300 | | DensityBaseUnits from, |
| | 23301 | | DensityBaseUnits to) |
| | 23302 | | { |
| | 23303 | | return Density<T>.Convert(value, from, to); |
| | 23304 | | } |
| | 23305 | |
|
| | 23306 | |
|
| | 23307 | |
|
| | 23308 | |
|
| | 23309 | | } |
| | 23310 | |
|
| | 23311 | | public struct ElectricChargeUnits : Measurement.IUnits<ElectricChargeUnits> |
| | 23312 | | { |
| | 23313 | | public ElectricCharge.Units _ElectricChargeUnits1; |
| | 23314 | |
|
| | 23315 | | public ElectricChargeUnits(ElectricCharge.Units ElectricChargeUnits1) |
| | 23316 | | { |
| | 23317 | | _ElectricChargeUnits1 = ElectricChargeUnits1; |
| | 23318 | | } |
| | 23319 | |
|
| | 23320 | | public T Convert<T>(T value, |
| | 23321 | | ElectricChargeUnits from, |
| | 23322 | | ElectricChargeUnits to) |
| | 23323 | | { |
| | 23324 | | return ElectricCharge<T>.Convert(value, from, to); |
| | 23325 | | } |
| | 23326 | |
|
| | 23327 | |
|
| | 23328 | | public static ElectricCurrentBaseUnits operator /(ElectricChargeUnits a, TimeUnits b) |
| | 23329 | | { |
| | 23330 | | return new ElectricCurrentBaseUnits(a._ElectricChargeUnits1, b._TimeUnits1); |
| | 23331 | | } |
| | 23332 | | } |
| | 23333 | |
|
| | 23334 | | public struct ElectricCurrentBaseUnits : Measurement.IUnits<ElectricCurrentBaseUnits> |
| | 23335 | | { |
| | 23336 | | public ElectricCharge.Units _ElectricChargeUnits1; |
| | 23337 | | public Time.Units _TimeUnits2; |
| | 23338 | |
|
| | 23339 | | public ElectricCurrentBaseUnits(ElectricCharge.Units ElectricChargeUnits1, Time.Units TimeUnits2) |
| | 23340 | | { |
| | 23341 | | _ElectricChargeUnits1 = ElectricChargeUnits1; |
| | 23342 | | _TimeUnits2 = TimeUnits2; |
| | 23343 | | } |
| | 23344 | |
|
| | 23345 | | public T Convert<T>(T value, |
| | 23346 | | ElectricCurrentBaseUnits from, |
| | 23347 | | ElectricCurrentBaseUnits to) |
| | 23348 | | { |
| | 23349 | | return ElectricCurrent<T>.Convert(value, from, to); |
| | 23350 | | } |
| | 23351 | |
|
| | 23352 | | } |
| | 23353 | |
|
| | 23354 | | public struct EnergyBaseUnits : Measurement.IUnits<EnergyBaseUnits> |
| | 23355 | | { |
| | 23356 | | public Mass.Units _MassUnits1; |
| | 23357 | | public Length.Units _LengthUnits2; |
| | 23358 | | public Length.Units _LengthUnits3; |
| | 23359 | | public Time.Units _TimeUnits4; |
| | 23360 | | public Time.Units _TimeUnits5; |
| | 23361 | |
|
| | 23362 | | public EnergyBaseUnits(Mass.Units MassUnits1, Length.Units LengthUnits2, Length.Units LengthUnits3, Time.Units Tim |
| | 23363 | | { |
| | 23364 | | _MassUnits1 = MassUnits1; |
| | 23365 | | _LengthUnits2 = LengthUnits2; |
| | 23366 | | _LengthUnits3 = LengthUnits3; |
| | 23367 | | _TimeUnits4 = TimeUnits4; |
| | 23368 | | _TimeUnits5 = TimeUnits5; |
| | 23369 | | } |
| | 23370 | |
|
| | 23371 | | public T Convert<T>(T value, |
| | 23372 | | EnergyBaseUnits from, |
| | 23373 | | EnergyBaseUnits to) |
| | 23374 | | { |
| | 23375 | | return Energy<T>.Convert(value, from, to); |
| | 23376 | | } |
| | 23377 | |
|
| | 23378 | |
|
| | 23379 | |
|
| | 23380 | |
|
| | 23381 | |
|
| | 23382 | |
|
| | 23383 | |
|
| | 23384 | |
|
| | 23385 | |
|
| | 23386 | | public static PowerBaseUnits operator /(EnergyBaseUnits a, TimeUnits b) |
| | 23387 | | { |
| | 23388 | | return new PowerBaseUnits(a._MassUnits1, a._LengthUnits2, a._LengthUnits3, a._TimeUnits4, a._TimeUnits5, b._Time |
| | 23389 | | } |
| | 23390 | |
|
| | 23391 | | } |
| | 23392 | |
|
| | 23393 | | public struct ForceBaseUnits : Measurement.IUnits<ForceBaseUnits> |
| | 23394 | | { |
| | 23395 | | public Mass.Units _MassUnits1; |
| | 23396 | | public Length.Units _LengthUnits2; |
| | 23397 | | public Time.Units _TimeUnits3; |
| | 23398 | | public Time.Units _TimeUnits4; |
| | 23399 | |
|
| | 23400 | | public ForceBaseUnits(Mass.Units MassUnits1, Length.Units LengthUnits2, Time.Units TimeUnits3, Time.Units TimeUnit |
| | 23401 | | { |
| | 23402 | | _MassUnits1 = MassUnits1; |
| | 23403 | | _LengthUnits2 = LengthUnits2; |
| | 23404 | | _TimeUnits3 = TimeUnits3; |
| | 23405 | | _TimeUnits4 = TimeUnits4; |
| | 23406 | | } |
| | 23407 | |
|
| | 23408 | | public T Convert<T>(T value, |
| | 23409 | | ForceBaseUnits from, |
| | 23410 | | ForceBaseUnits to) |
| | 23411 | | { |
| | 23412 | | return Force<T>.Convert(value, from, to); |
| | 23413 | | } |
| | 23414 | |
|
| | 23415 | | public static EnergyBaseUnits operator *(ForceBaseUnits a, LengthUnits b) |
| | 23416 | | { |
| | 23417 | | return new EnergyBaseUnits(a._MassUnits1, a._LengthUnits2, b._LengthUnits1, a._TimeUnits3, a._TimeUnits4); |
| | 23418 | | } |
| | 23419 | |
|
| | 23420 | | public static PowerBaseUnits operator *(ForceBaseUnits a, SpeedBaseUnits b) |
| | 23421 | | { |
| | 23422 | | return new PowerBaseUnits(a._MassUnits1, a._LengthUnits2, b._LengthUnits1, a._TimeUnits3, a._TimeUnits4, b._Time |
| | 23423 | | } |
| | 23424 | |
|
| | 23425 | |
|
| | 23426 | |
|
| | 23427 | |
|
| | 23428 | |
|
| | 23429 | |
|
| | 23430 | |
|
| | 23431 | |
|
| | 23432 | | } |
| | 23433 | |
|
| | 23434 | | public struct LengthUnits : Measurement.IUnits<LengthUnits> |
| | 23435 | | { |
| | 23436 | | public Length.Units _LengthUnits1; |
| | 23437 | |
|
| | 23438 | | public LengthUnits(Length.Units LengthUnits1) |
| | 23439 | | { |
| | 23440 | | _LengthUnits1 = LengthUnits1; |
| | 23441 | | } |
| | 23442 | |
|
| | 23443 | | public T Convert<T>(T value, |
| | 23444 | | LengthUnits from, |
| | 23445 | | LengthUnits to) |
| | 23446 | | { |
| | 23447 | | return Length<T>.Convert(value, from, to); |
| | 23448 | | } |
| | 23449 | |
|
| | 23450 | | public static VolumeBaseUnits operator *(LengthUnits a, AreaBaseUnits b) |
| | 23451 | | { |
| | 23452 | | return new VolumeBaseUnits(a._LengthUnits1, b._LengthUnits1, b._LengthUnits2); |
| | 23453 | | } |
| | 23454 | |
|
| | 23455 | |
|
| | 23456 | |
|
| | 23457 | | public static EnergyBaseUnits operator *(LengthUnits a, ForceBaseUnits b) |
| | 23458 | | { |
| | 23459 | | return new EnergyBaseUnits(b._MassUnits1, a._LengthUnits1, b._LengthUnits2, b._TimeUnits3, b._TimeUnits4); |
| | 23460 | | } |
| | 23461 | |
|
| | 23462 | | public static AreaBaseUnits operator *(LengthUnits a, LengthUnits b) |
| | 23463 | | { |
| | 23464 | | return new AreaBaseUnits(a._LengthUnits1, b._LengthUnits1); |
| | 23465 | | } |
| | 23466 | |
|
| | 23467 | |
|
| | 23468 | | public static LinearMassBaseUnits operator *(LengthUnits a, MassUnits b) |
| | 23469 | | { |
| | 23470 | | return new LinearMassBaseUnits(b._MassUnits1, a._LengthUnits1); |
| | 23471 | | } |
| | 23472 | |
|
| | 23473 | | public static LinearMassFlowBaseUnits operator *(LengthUnits a, MassRateBaseUnits b) |
| | 23474 | | { |
| | 23475 | | return new LinearMassFlowBaseUnits(b._MassUnits1, a._LengthUnits1, b._TimeUnits2); |
| | 23476 | | } |
| | 23477 | |
|
| | 23478 | |
|
| | 23479 | |
|
| | 23480 | | public static SpeedBaseUnits operator /(LengthUnits a, TimeUnits b) |
| | 23481 | | { |
| | 23482 | | return new SpeedBaseUnits(a._LengthUnits1, b._TimeUnits1); |
| | 23483 | | } |
| | 23484 | |
|
| | 23485 | | public static AccelerationBaseUnits operator /(LengthUnits a, TimeAreaBaseUnits b) |
| | 23486 | | { |
| | 23487 | | return new AccelerationBaseUnits(a._LengthUnits1, b._TimeUnits1, b._TimeUnits2); |
| | 23488 | | } |
| | 23489 | | } |
| | 23490 | |
|
| | 23491 | | public struct LinearDensityBaseUnits : Measurement.IUnits<LinearDensityBaseUnits> |
| | 23492 | | { |
| | 23493 | | public Mass.Units _MassUnits1; |
| | 23494 | | public Length.Units _LengthUnits2; |
| | 23495 | |
|
| | 23496 | | public LinearDensityBaseUnits(Mass.Units MassUnits1, Length.Units LengthUnits2) |
| | 23497 | | { |
| | 23498 | | _MassUnits1 = MassUnits1; |
| | 23499 | | _LengthUnits2 = LengthUnits2; |
| | 23500 | | } |
| | 23501 | |
|
| | 23502 | | public T Convert<T>(T value, |
| | 23503 | | LinearDensityBaseUnits from, |
| | 23504 | | LinearDensityBaseUnits to) |
| | 23505 | | { |
| | 23506 | | return LinearDensity<T>.Convert(value, from, to); |
| | 23507 | | } |
| | 23508 | |
|
| | 23509 | |
|
| | 23510 | |
|
| | 23511 | |
|
| | 23512 | | public static DensityBaseUnits operator /(LinearDensityBaseUnits a, AreaBaseUnits b) |
| | 23513 | | { |
| | 23514 | | return new DensityBaseUnits(a._MassUnits1, a._LengthUnits2, b._LengthUnits1, b._LengthUnits2); |
| | 23515 | | } |
| | 23516 | |
|
| | 23517 | |
|
| | 23518 | |
|
| | 23519 | | public static AreaDensityBaseUnits operator /(LinearDensityBaseUnits a, LengthUnits b) |
| | 23520 | | { |
| | 23521 | | return new AreaDensityBaseUnits(a._MassUnits1, a._LengthUnits2, b._LengthUnits1); |
| | 23522 | | } |
| | 23523 | |
|
| | 23524 | |
|
| | 23525 | | public static PressureBaseUnits operator /(LinearDensityBaseUnits a, TimeAreaBaseUnits b) |
| | 23526 | | { |
| | 23527 | | return new PressureBaseUnits(a._MassUnits1, a._LengthUnits2, b._TimeUnits1, b._TimeUnits2); |
| | 23528 | | } |
| | 23529 | | } |
| | 23530 | |
|
| | 23531 | | public struct LinearMassBaseUnits : Measurement.IUnits<LinearMassBaseUnits> |
| | 23532 | | { |
| | 23533 | | public Mass.Units _MassUnits1; |
| | 23534 | | public Length.Units _LengthUnits2; |
| | 23535 | |
|
| | 23536 | | public LinearMassBaseUnits(Mass.Units MassUnits1, Length.Units LengthUnits2) |
| | 23537 | | { |
| | 23538 | | _MassUnits1 = MassUnits1; |
| | 23539 | | _LengthUnits2 = LengthUnits2; |
| | 23540 | | } |
| | 23541 | |
|
| | 23542 | | public T Convert<T>(T value, |
| | 23543 | | LinearMassBaseUnits from, |
| | 23544 | | LinearMassBaseUnits to) |
| | 23545 | | { |
| | 23546 | | return LinearMass<T>.Convert(value, from, to); |
| | 23547 | | } |
| | 23548 | |
|
| | 23549 | | public static EnergyBaseUnits operator *(LinearMassBaseUnits a, AccelerationBaseUnits b) |
| | 23550 | | { |
| | 23551 | | return new EnergyBaseUnits(a._MassUnits1, a._LengthUnits2, b._LengthUnits1, b._TimeUnits2, b._TimeUnits3); |
| | 23552 | | } |
| | 23553 | |
|
| | 23554 | |
|
| | 23555 | |
|
| | 23556 | |
|
| | 23557 | |
|
| | 23558 | |
|
| | 23559 | |
|
| | 23560 | |
|
| | 23561 | | public static LinearMassFlowBaseUnits operator /(LinearMassBaseUnits a, TimeUnits b) |
| | 23562 | | { |
| | 23563 | | return new LinearMassFlowBaseUnits(a._MassUnits1, a._LengthUnits2, b._TimeUnits1); |
| | 23564 | | } |
| | 23565 | |
|
| | 23566 | | public static ForceBaseUnits operator /(LinearMassBaseUnits a, TimeAreaBaseUnits b) |
| | 23567 | | { |
| | 23568 | | return new ForceBaseUnits(a._MassUnits1, a._LengthUnits2, b._TimeUnits1, b._TimeUnits2); |
| | 23569 | | } |
| | 23570 | |
|
| | 23571 | | } |
| | 23572 | |
|
| | 23573 | | public struct LinearMassFlowBaseUnits : Measurement.IUnits<LinearMassFlowBaseUnits> |
| | 23574 | | { |
| | 23575 | | public Mass.Units _MassUnits1; |
| | 23576 | | public Length.Units _LengthUnits2; |
| | 23577 | | public Time.Units _TimeUnits3; |
| | 23578 | |
|
| | 23579 | | public LinearMassFlowBaseUnits(Mass.Units MassUnits1, Length.Units LengthUnits2, Time.Units TimeUnits3) |
| | 23580 | | { |
| | 23581 | | _MassUnits1 = MassUnits1; |
| | 23582 | | _LengthUnits2 = LengthUnits2; |
| | 23583 | | _TimeUnits3 = TimeUnits3; |
| | 23584 | | } |
| | 23585 | |
|
| | 23586 | | public T Convert<T>(T value, |
| | 23587 | | LinearMassFlowBaseUnits from, |
| | 23588 | | LinearMassFlowBaseUnits to) |
| | 23589 | | { |
| | 23590 | | return LinearMassFlow<T>.Convert(value, from, to); |
| | 23591 | | } |
| | 23592 | |
|
| | 23593 | | public static PowerBaseUnits operator *(LinearMassFlowBaseUnits a, AccelerationBaseUnits b) |
| | 23594 | | { |
| | 23595 | | return new PowerBaseUnits(a._MassUnits1, a._LengthUnits2, b._LengthUnits1, a._TimeUnits3, b._TimeUnits2, b._Time |
| | 23596 | | } |
| | 23597 | |
|
| | 23598 | | public static EnergyBaseUnits operator *(LinearMassFlowBaseUnits a, SpeedBaseUnits b) |
| | 23599 | | { |
| | 23600 | | return new EnergyBaseUnits(a._MassUnits1, a._LengthUnits2, b._LengthUnits1, a._TimeUnits3, b._TimeUnits2); |
| | 23601 | | } |
| | 23602 | |
|
| | 23603 | |
|
| | 23604 | |
|
| | 23605 | |
|
| | 23606 | |
|
| | 23607 | |
|
| | 23608 | |
|
| | 23609 | |
|
| | 23610 | | public static ForceBaseUnits operator /(LinearMassFlowBaseUnits a, TimeUnits b) |
| | 23611 | | { |
| | 23612 | | return new ForceBaseUnits(a._MassUnits1, a._LengthUnits2, a._TimeUnits3, b._TimeUnits1); |
| | 23613 | | } |
| | 23614 | |
|
| | 23615 | | } |
| | 23616 | |
|
| | 23617 | | public struct MassUnits : Measurement.IUnits<MassUnits> |
| | 23618 | | { |
| | 23619 | | public Mass.Units _MassUnits1; |
| | 23620 | |
|
| | 23621 | | public MassUnits(Mass.Units MassUnits1) |
| | 23622 | | { |
| | 23623 | | _MassUnits1 = MassUnits1; |
| | 23624 | | } |
| | 23625 | |
|
| | 23626 | | public T Convert<T>(T value, |
| | 23627 | | MassUnits from, |
| | 23628 | | MassUnits to) |
| | 23629 | | { |
| | 23630 | | return Mass<T>.Convert(value, from, to); |
| | 23631 | | } |
| | 23632 | |
|
| | 23633 | | public static ForceBaseUnits operator *(MassUnits a, AccelerationBaseUnits b) |
| | 23634 | | { |
| | 23635 | | return new ForceBaseUnits(a._MassUnits1, b._LengthUnits1, b._TimeUnits2, b._TimeUnits3); |
| | 23636 | | } |
| | 23637 | |
|
| | 23638 | | public static LinearMassBaseUnits operator *(MassUnits a, LengthUnits b) |
| | 23639 | | { |
| | 23640 | | return new LinearMassBaseUnits(a._MassUnits1, b._LengthUnits1); |
| | 23641 | | } |
| | 23642 | |
|
| | 23643 | | public static LinearMassFlowBaseUnits operator *(MassUnits a, SpeedBaseUnits b) |
| | 23644 | | { |
| | 23645 | | return new LinearMassFlowBaseUnits(a._MassUnits1, b._LengthUnits1, b._TimeUnits2); |
| | 23646 | | } |
| | 23647 | |
|
| | 23648 | | public static AreaDensityBaseUnits operator /(MassUnits a, AreaBaseUnits b) |
| | 23649 | | { |
| | 23650 | | return new AreaDensityBaseUnits(a._MassUnits1, b._LengthUnits1, b._LengthUnits2); |
| | 23651 | | } |
| | 23652 | |
|
| | 23653 | |
|
| | 23654 | |
|
| | 23655 | | public static LinearDensityBaseUnits operator /(MassUnits a, LengthUnits b) |
| | 23656 | | { |
| | 23657 | | return new LinearDensityBaseUnits(a._MassUnits1, b._LengthUnits1); |
| | 23658 | | } |
| | 23659 | |
|
| | 23660 | |
|
| | 23661 | |
|
| | 23662 | | public static MassRateBaseUnits operator /(MassUnits a, TimeUnits b) |
| | 23663 | | { |
| | 23664 | | return new MassRateBaseUnits(a._MassUnits1, b._TimeUnits1); |
| | 23665 | | } |
| | 23666 | |
|
| | 23667 | | public static DensityBaseUnits operator /(MassUnits a, VolumeBaseUnits b) |
| | 23668 | | { |
| | 23669 | | return new DensityBaseUnits(a._MassUnits1, b._LengthUnits1, b._LengthUnits2, b._LengthUnits3); |
| | 23670 | | } |
| | 23671 | | } |
| | 23672 | |
|
| | 23673 | | public struct MassRateBaseUnits : Measurement.IUnits<MassRateBaseUnits> |
| | 23674 | | { |
| | 23675 | | public Mass.Units _MassUnits1; |
| | 23676 | | public Time.Units _TimeUnits2; |
| | 23677 | |
|
| | 23678 | | public MassRateBaseUnits(Mass.Units MassUnits1, Time.Units TimeUnits2) |
| | 23679 | | { |
| | 23680 | | _MassUnits1 = MassUnits1; |
| | 23681 | | _TimeUnits2 = TimeUnits2; |
| | 23682 | | } |
| | 23683 | |
|
| | 23684 | | public T Convert<T>(T value, |
| | 23685 | | MassRateBaseUnits from, |
| | 23686 | | MassRateBaseUnits to) |
| | 23687 | | { |
| | 23688 | | return MassRate<T>.Convert(value, from, to); |
| | 23689 | | } |
| | 23690 | |
|
| | 23691 | | public static LinearMassFlowBaseUnits operator *(MassRateBaseUnits a, LengthUnits b) |
| | 23692 | | { |
| | 23693 | | return new LinearMassFlowBaseUnits(a._MassUnits1, b._LengthUnits1, a._TimeUnits2); |
| | 23694 | | } |
| | 23695 | |
|
| | 23696 | | public static ForceBaseUnits operator *(MassRateBaseUnits a, SpeedBaseUnits b) |
| | 23697 | | { |
| | 23698 | | return new ForceBaseUnits(a._MassUnits1, b._LengthUnits1, a._TimeUnits2, b._TimeUnits2); |
| | 23699 | | } |
| | 23700 | |
|
| | 23701 | |
|
| | 23702 | |
|
| | 23703 | |
|
| | 23704 | |
|
| | 23705 | | } |
| | 23706 | |
|
| | 23707 | | public struct PowerBaseUnits : Measurement.IUnits<PowerBaseUnits> |
| | 23708 | | { |
| | 23709 | | public Mass.Units _MassUnits1; |
| | 23710 | | public Length.Units _LengthUnits2; |
| | 23711 | | public Length.Units _LengthUnits3; |
| | 23712 | | public Time.Units _TimeUnits4; |
| | 23713 | | public Time.Units _TimeUnits5; |
| | 23714 | | public Time.Units _TimeUnits6; |
| | 23715 | |
|
| | 23716 | | public PowerBaseUnits(Mass.Units MassUnits1, Length.Units LengthUnits2, Length.Units LengthUnits3, Time.Units Time |
| | 23717 | | { |
| | 23718 | | _MassUnits1 = MassUnits1; |
| | 23719 | | _LengthUnits2 = LengthUnits2; |
| | 23720 | | _LengthUnits3 = LengthUnits3; |
| | 23721 | | _TimeUnits4 = TimeUnits4; |
| | 23722 | | _TimeUnits5 = TimeUnits5; |
| | 23723 | | _TimeUnits6 = TimeUnits6; |
| | 23724 | | } |
| | 23725 | |
|
| | 23726 | | public T Convert<T>(T value, |
| | 23727 | | PowerBaseUnits from, |
| | 23728 | | PowerBaseUnits to) |
| | 23729 | | { |
| | 23730 | | return Power<T>.Convert(value, from, to); |
| | 23731 | | } |
| | 23732 | |
|
| | 23733 | |
|
| | 23734 | |
|
| | 23735 | |
|
| | 23736 | |
|
| | 23737 | |
|
| | 23738 | |
|
| | 23739 | | } |
| | 23740 | |
|
| | 23741 | | public struct PressureBaseUnits : Measurement.IUnits<PressureBaseUnits> |
| | 23742 | | { |
| | 23743 | | public Mass.Units _MassUnits1; |
| | 23744 | | public Length.Units _LengthUnits2; |
| | 23745 | | public Time.Units _TimeUnits3; |
| | 23746 | | public Time.Units _TimeUnits4; |
| | 23747 | |
|
| | 23748 | | public PressureBaseUnits(Mass.Units MassUnits1, Length.Units LengthUnits2, Time.Units TimeUnits3, Time.Units TimeU |
| | 23749 | | { |
| | 23750 | | _MassUnits1 = MassUnits1; |
| | 23751 | | _LengthUnits2 = LengthUnits2; |
| | 23752 | | _TimeUnits3 = TimeUnits3; |
| | 23753 | | _TimeUnits4 = TimeUnits4; |
| | 23754 | | } |
| | 23755 | |
|
| | 23756 | | public T Convert<T>(T value, |
| | 23757 | | PressureBaseUnits from, |
| | 23758 | | PressureBaseUnits to) |
| | 23759 | | { |
| | 23760 | | return Pressure<T>.Convert(value, from, to); |
| | 23761 | | } |
| | 23762 | |
|
| | 23763 | |
|
| | 23764 | |
|
| | 23765 | |
|
| | 23766 | |
|
| | 23767 | |
|
| | 23768 | | } |
| | 23769 | |
|
| | 23770 | | public struct SpeedBaseUnits : Measurement.IUnits<SpeedBaseUnits> |
| | 23771 | | { |
| | 23772 | | public Length.Units _LengthUnits1; |
| | 23773 | | public Time.Units _TimeUnits2; |
| | 23774 | |
|
| | 23775 | | public SpeedBaseUnits(Length.Units LengthUnits1, Time.Units TimeUnits2) |
| | 23776 | | { |
| | 23777 | | _LengthUnits1 = LengthUnits1; |
| | 23778 | | _TimeUnits2 = TimeUnits2; |
| | 23779 | | } |
| | 23780 | |
|
| | 23781 | | public T Convert<T>(T value, |
| | 23782 | | SpeedBaseUnits from, |
| | 23783 | | SpeedBaseUnits to) |
| | 23784 | | { |
| | 23785 | | return Speed<T>.Convert(value, from, to); |
| | 23786 | | } |
| | 23787 | |
|
| | 23788 | | public static VolumeRateBaseUnits operator *(SpeedBaseUnits a, AreaBaseUnits b) |
| | 23789 | | { |
| | 23790 | | return new VolumeRateBaseUnits(a._LengthUnits1, b._LengthUnits1, b._LengthUnits2, a._TimeUnits2); |
| | 23791 | | } |
| | 23792 | |
|
| | 23793 | | public static PowerBaseUnits operator *(SpeedBaseUnits a, ForceBaseUnits b) |
| | 23794 | | { |
| | 23795 | | return new PowerBaseUnits(b._MassUnits1, a._LengthUnits1, b._LengthUnits2, a._TimeUnits2, b._TimeUnits3, b._Time |
| | 23796 | | } |
| | 23797 | |
|
| | 23798 | |
|
| | 23799 | | public static EnergyBaseUnits operator *(SpeedBaseUnits a, LinearMassFlowBaseUnits b) |
| | 23800 | | { |
| | 23801 | | return new EnergyBaseUnits(b._MassUnits1, a._LengthUnits1, b._LengthUnits2, a._TimeUnits2, b._TimeUnits3); |
| | 23802 | | } |
| | 23803 | |
|
| | 23804 | | public static LinearMassFlowBaseUnits operator *(SpeedBaseUnits a, MassUnits b) |
| | 23805 | | { |
| | 23806 | | return new LinearMassFlowBaseUnits(b._MassUnits1, a._LengthUnits1, a._TimeUnits2); |
| | 23807 | | } |
| | 23808 | |
|
| | 23809 | | public static ForceBaseUnits operator *(SpeedBaseUnits a, MassRateBaseUnits b) |
| | 23810 | | { |
| | 23811 | | return new ForceBaseUnits(b._MassUnits1, a._LengthUnits1, a._TimeUnits2, b._TimeUnits2); |
| | 23812 | | } |
| | 23813 | |
|
| | 23814 | |
|
| | 23815 | |
|
| | 23816 | | public static AccelerationBaseUnits operator /(SpeedBaseUnits a, TimeUnits b) |
| | 23817 | | { |
| | 23818 | | return new AccelerationBaseUnits(a._LengthUnits1, a._TimeUnits2, b._TimeUnits1); |
| | 23819 | | } |
| | 23820 | | } |
| | 23821 | |
|
| | 23822 | | public struct TempuratureUnits : Measurement.IUnits<TempuratureUnits> |
| | 23823 | | { |
| | 23824 | | public Tempurature.Units _TempuratureUnits1; |
| | 23825 | |
|
| | 23826 | | public TempuratureUnits(Tempurature.Units TempuratureUnits1) |
| | 23827 | | { |
| | 23828 | | _TempuratureUnits1 = TempuratureUnits1; |
| | 23829 | | } |
| | 23830 | |
|
| | 23831 | | public T Convert<T>(T value, |
| | 23832 | | TempuratureUnits from, |
| | 23833 | | TempuratureUnits to) |
| | 23834 | | { |
| | 23835 | | return Tempurature<T>.Convert(value, from, to); |
| | 23836 | | } |
| | 23837 | | } |
| | 23838 | |
|
| | 23839 | | public struct TimeUnits : Measurement.IUnits<TimeUnits> |
| | 23840 | | { |
| | 23841 | | public Time.Units _TimeUnits1; |
| | 23842 | |
|
| | 23843 | | public TimeUnits(Time.Units TimeUnits1) |
| | 23844 | | { |
| | 23845 | | _TimeUnits1 = TimeUnits1; |
| | 23846 | | } |
| | 23847 | |
|
| | 23848 | | public T Convert<T>(T value, |
| | 23849 | | TimeUnits from, |
| | 23850 | | TimeUnits to) |
| | 23851 | | { |
| | 23852 | | return Time<T>.Convert(value, from, to); |
| | 23853 | | } |
| | 23854 | |
|
| | 23855 | |
|
| | 23856 | |
|
| | 23857 | |
|
| | 23858 | |
|
| | 23859 | |
|
| | 23860 | |
|
| | 23861 | |
|
| | 23862 | |
|
| | 23863 | |
|
| | 23864 | | public static TimeAreaBaseUnits operator *(TimeUnits a, TimeUnits b) |
| | 23865 | | { |
| | 23866 | | return new TimeAreaBaseUnits(a._TimeUnits1, b._TimeUnits1); |
| | 23867 | | } |
| | 23868 | |
|
| | 23869 | | } |
| | 23870 | |
|
| | 23871 | | public struct TimeAreaBaseUnits : Measurement.IUnits<TimeAreaBaseUnits> |
| | 23872 | | { |
| | 23873 | | public Time.Units _TimeUnits1; |
| | 23874 | | public Time.Units _TimeUnits2; |
| | 23875 | |
|
| | 23876 | | public TimeAreaBaseUnits(Time.Units TimeUnits1, Time.Units TimeUnits2) |
| | 23877 | | { |
| | 23878 | | _TimeUnits1 = TimeUnits1; |
| | 23879 | | _TimeUnits2 = TimeUnits2; |
| | 23880 | | } |
| | 23881 | |
|
| | 23882 | | public T Convert<T>(T value, |
| | 23883 | | TimeAreaBaseUnits from, |
| | 23884 | | TimeAreaBaseUnits to) |
| | 23885 | | { |
| | 23886 | | return TimeArea<T>.Convert(value, from, to); |
| | 23887 | | } |
| | 23888 | |
|
| | 23889 | |
|
| | 23890 | |
|
| | 23891 | |
|
| | 23892 | |
|
| | 23893 | | } |
| | 23894 | |
|
| | 23895 | | public struct VolumeBaseUnits : Measurement.IUnits<VolumeBaseUnits> |
| | 23896 | | { |
| | 23897 | | public Length.Units _LengthUnits1; |
| | 23898 | | public Length.Units _LengthUnits2; |
| | 23899 | | public Length.Units _LengthUnits3; |
| | 23900 | |
|
| | 23901 | | public VolumeBaseUnits(Length.Units LengthUnits1, Length.Units LengthUnits2, Length.Units LengthUnits3) |
| | 23902 | | { |
| | 23903 | | _LengthUnits1 = LengthUnits1; |
| | 23904 | | _LengthUnits2 = LengthUnits2; |
| | 23905 | | _LengthUnits3 = LengthUnits3; |
| | 23906 | | } |
| | 23907 | |
|
| | 23908 | | public T Convert<T>(T value, |
| | 23909 | | VolumeBaseUnits from, |
| | 23910 | | VolumeBaseUnits to) |
| | 23911 | | { |
| | 23912 | | return Volume<T>.Convert(value, from, to); |
| | 23913 | | } |
| | 23914 | |
|
| | 23915 | |
|
| | 23916 | |
|
| | 23917 | |
|
| | 23918 | |
|
| | 23919 | |
|
| | 23920 | | public static VolumeRateBaseUnits operator /(VolumeBaseUnits a, TimeUnits b) |
| | 23921 | | { |
| | 23922 | | return new VolumeRateBaseUnits(a._LengthUnits1, a._LengthUnits2, a._LengthUnits3, b._TimeUnits1); |
| | 23923 | | } |
| | 23924 | |
|
| | 23925 | | } |
| | 23926 | |
|
| | 23927 | | public struct VolumeRateBaseUnits : Measurement.IUnits<VolumeRateBaseUnits> |
| | 23928 | | { |
| | 23929 | | public Length.Units _LengthUnits1; |
| | 23930 | | public Length.Units _LengthUnits2; |
| | 23931 | | public Length.Units _LengthUnits3; |
| | 23932 | | public Time.Units _TimeUnits4; |
| | 23933 | |
|
| | 23934 | | public VolumeRateBaseUnits(Length.Units LengthUnits1, Length.Units LengthUnits2, Length.Units LengthUnits3, Time.U |
| | 23935 | | { |
| | 23936 | | _LengthUnits1 = LengthUnits1; |
| | 23937 | | _LengthUnits2 = LengthUnits2; |
| | 23938 | | _LengthUnits3 = LengthUnits3; |
| | 23939 | | _TimeUnits4 = TimeUnits4; |
| | 23940 | | } |
| | 23941 | |
|
| | 23942 | | public T Convert<T>(T value, |
| | 23943 | | VolumeRateBaseUnits from, |
| | 23944 | | VolumeRateBaseUnits to) |
| | 23945 | | { |
| | 23946 | | return VolumeRate<T>.Convert(value, from, to); |
| | 23947 | | } |
| | 23948 | |
|
| | 23949 | |
|
| | 23950 | |
|
| | 23951 | |
|
| | 23952 | |
|
| | 23953 | |
|
| | 23954 | | } |
| | 23955 | |
|
| | 23956 | | } |
| | 23957 | |
|
| | 23958 | | #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member |
| | 23959 | |
|
| | 23960 | | #endregion |
| | 23961 | | } |