diff --git a/CLAUDE.md b/CLAUDE.md index 381cfa5..ba867ab 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -249,6 +249,37 @@ is mandatory, not incidental: several literals are in exponent form (`6.62607015 and the `Parse(string, IFormatProvider)` overload resolves to `NumberStyles.Number` for some numeric types, which rejects an exponent. +### Conversion factors and square roots at the storage type's precision + +Unit conversion factors and metric magnitudes reach a storage type the same way constants do. +`ConversionsGenerator` and `MagnitudesGenerator` still emit `double` constants, which back the +public `IUnit.ToBaseFactor` and `ToBaseOffset` properties, and alongside them a `Values` holder +that calls `StorageLiteral.Parse` or `StorageLiteral.Divide` once per closed generic type. The +generated `From{Unit}` factories multiply by `Values`, and each generated unit implements +`IUnit.ToBaseFactorAs()` and `ToBaseOffsetAs()` explicitly from it, which is what +`ToBase`/`FromBase` and every `In(unit)` read. Before this, every factor went through +`T.CreateChecked(double)`, so a `decimal` quantity converted with the 15 significant digits that +conversion keeps. + +- A value in `conversions.json` is a decimal literal or an exact fraction of two, `"5/9"`. Write a + repeating ratio as the fraction, not as its rounded decimal, and anything built on π as a long + literal. SEM009 reports a value that is neither. +- An integer storage type, or one that cannot parse the literal, falls back to the old + `T.CreateChecked(double)`, so `int` quantities convert exactly as they did. +- `ToBaseFactorAs()` and `ToBaseOffsetAs()` are default-implemented on `IUnit`, so a unit + written outside the library needs nothing new. They are not named `Get…`, because CA1721 rejects + a `GetToBaseFactor` method next to the `ToBaseFactor` property. + +Vector `Length()` and `Distance()` call `StorageMath.Sqrt`. The binary floating point and integer +primitives take the `Math.Sqrt` round trip the generated code always inlined, so their results are +unchanged. Any other type is seeded from that root and refined with Newton steps in its own +arithmetic, so a `decimal` length has 28 significant digits. The logarithmic scales and the +hand-written audio types still compute through `double`. + +`StorageConversionTests` runs the same conversions, relationships and vector lengths over +`double` and `decimal`, exactly where the answer terminates and to a relative tolerance where it +does not. Adding a storage type is one derived class. + ### Operators and physics relationships Cross-dimensional relationships are also declared in `dimensions.json` (`integrals`, `derivatives`, `dotProducts`, `crossProducts`). The generator emits operators like: @@ -337,6 +368,7 @@ var converted = sourceString.As(); - **SEM006** — a metadata file a generator declared in `MetadataFileNames` was not supplied as an `AdditionalFile`. Previously this produced no output and no explanation, which is indistinguishable from a generator that simply had nothing to emit. - **SEM007** — a metadata file could not be parsed. Replaces the base generator's `CONV001` in category `SourceGenerator`, and covers the path that used to swallow the exception, where a malformed `units.json` silently produced factories with no scale factor. - **SEM008** — a relationship's declared result does not follow from the dimensions of its operands, or its value is signed and the declared result is a magnitude. The check comes from `Semantics.Vocabulary`, shared with the C++ projection; before that this side checked the names (SEM001) and the forms (SEM003) and then emitted the operator, so `Sensitivity * Pressure -> ElectricPotential` shipped as a working C# operator computing the wrong physics — which is what found that bug, and it is now fixed. **No operator is generated** for a refused relationship, in any of the directions C# spells a product in — that followed from making the vocabulary drive emission rather than only check it, and the removal is documented in `docs/migration-guide-5.0.md`. Suppressed in `Semantics.Quantities.csproj` because ktsu.Sdk builds warnings as errors and the four below are outstanding; `UnkeepableRelationshipTests` pins the set, and asserts that none of them is in the compiled surface, so a fifth fails there rather than disappearing into the suppression. + - **SEM009**: a factor's `value` in `conversions.json` is neither a decimal literal nor a fraction of two with a non-zero denominator. An error, and no constant is generated for it, because every unit using the factor would otherwise fail to compile far from the metadata line that caused it. - Descriptors are allocated from `SemanticsDiagnostics`, which is the one place to add a new one. `AnalyzerReleaseTrackingTests` fails if the identifier is missing from `AnalyzerReleases.Unshipped.md`, so RS2008 no longer surfaces only after a push. - See `docs/physics-generator.md` for the full schema and an end-to-end "add a dimension" walk-through. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.ConversionsGenerator/ConversionConstants.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.ConversionsGenerator/ConversionConstants.g.cs index c08e3c1..c65064f 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.ConversionsGenerator/ConversionConstants.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.ConversionsGenerator/ConversionConstants.g.cs @@ -3,6 +3,8 @@ namespace ktsu.Semantics.Quantities.Units; +using System.Numerics; + /// /// Conversion constants used by generated unit definitions. /// Values sourced from conversions.json metadata. @@ -93,20 +95,20 @@ internal static class ConversionConstants /// Celsius to Kelvin temperature offset: 273.15 K (exact by definition) internal const double CelsiusToKelvinOffset = 273.15; - /// Fahrenheit-to-Kelvin degree scale factor: 5/9 (exact) - internal const double FahrenheitScale = 0.5555555555555556; + /// Fahrenheit-to-Kelvin degree scale factor: 5/9 K/°F (exact, stored as a fraction) + internal const double FahrenheitScale = 5d / 9d; - /// Fahrenheit to Kelvin affine offset: 459.67 × 5/9 ≈ 255.372 K (exact) - internal const double FahrenheitToKelvinOffset = 255.37222222222223; + /// Fahrenheit to Kelvin affine offset: 459.67 × 5/9 = 45967/180 ≈ 255.372 K (exact, stored as a fraction) + internal const double FahrenheitToKelvinOffset = 45967d / 180d; /// Degree to radian conversion: π/180 rad/° (exact) internal const double DegreeToRadians = 0.017453292519943295769236907684886127134428718885417254560971914401710091146034494436822415696345097379101040706699150667990539631694451077627806983; - /// Gradian to radian conversion: π/200 rad/grad (exact) - internal const double GradianToRadians = 0.015707963267948966; + /// Gradian to radian conversion: π/200 rad/grad (π to 150 significant digits, taken as DegreeToRadians × 180) + internal const double GradianToRadians = 0.0157079632679489661923132169163975144209858469968755291048747229615390820314310449931401741267105876411909366360292356011914856685250059698650262847; - /// Revolution to radian conversion: 2π rad/rev (exact) - internal const double RevolutionToRadians = 6.283185307179586; + /// Revolution to radian conversion: 2π rad/rev (π to 150 significant digits, taken as DegreeToRadians × 180) + internal const double RevolutionToRadians = 6.28318530717958647692528676655900576839433879875021164194988918461563281257241799725606965068423505647637465441169424047659426741000238794601051388; /// Calorie to joule conversion: 4.184 J/cal (exact, thermochemical calorie) internal const double CalorieToJoules = 4.184; @@ -114,8 +116,8 @@ internal static class ConversionConstants /// Kilowatt-hour to joule conversion: 3600000 J/kWh (exact) internal const double KilowattHourToJoules = 3600000; - /// Mechanical horsepower to watt conversion: 745.6998715822702 W/hp (exact) - internal const double HorsepowerToWatts = 745.6998715822702; + /// Mechanical horsepower to watt conversion: 550 ft⋅lbf/s = 550 × 0.3048 × 4.4482216152605 = 745.69987158227022 W/hp (exact) + internal const double HorsepowerToWatts = 745.69987158227022; /// Electron volt to joule conversion: 1.602176634e-19 J/eV (exact, based on elementary charge) internal const double ElectronVoltToJoules = 1.602176634e-19; @@ -138,11 +140,11 @@ internal static class ConversionConstants /// Atmosphere to pascal conversion: 101325 Pa/atm (exact by definition) internal const double AtmosphereToPascals = 101325; - /// PSI to pascal conversion: 6894.757293168361 Pa/psi (exact) - internal const double PsiToPascals = 6894.757293168361; + /// PSI to pascal conversion: 4.4482216152605 N / 0.0254² m² = 8896443230521/1290320000 Pa/psi, written to 150 significant digits (a literal rather than the fraction, because float storage rounds that numerator before dividing) + internal const double PsiToPascals = 6894.75729316836133672267344534689069378138756277512555025110050220100440200880401760803521607043214086428172856345712691425382850765701531403062806126; - /// Torr to pascal conversion: 101325/760 ≈ 133.322 Pa/Torr (exact) - internal const double TorrToPascals = 133.32236842105263; + /// Torr to pascal conversion: 101325/760 = 20265/152 Pa/Torr (exact, stored as a fraction) + internal const double TorrToPascals = 20265d / 152d; /// Square foot to square meter conversion: 0.09290304 m²/ft² (exact) internal const double SquareFootToSquareMeters = 0.09290304; @@ -168,8 +170,8 @@ internal static class ConversionConstants /// Acre to square meter: 4046.8564224 m²/ac (exact) internal const double AcreToSquareMeters = 4046.8564224; - /// Kilometers per hour to meters per second conversion: 0.2777777777777778 m/s per km/h (exact) - internal const double KilometerPerHourToMeterPerSecond = 0.2777777777777778; + /// Kilometers per hour to meters per second conversion: 1000/3600 = 5/18 m/s per km/h (exact, stored as a fraction) + internal const double KilometerPerHourToMeterPerSecond = 5d / 18d; /// Miles per hour to meters per second conversion: 0.44704 m/s per mph (exact) internal const double MilePerHourToMeterPerSecond = 0.44704; @@ -177,11 +179,11 @@ internal static class ConversionConstants /// Feet per second to meters per second: 0.3048 m/s per ft/s (exact) internal const double FootPerSecondToMeterPerSecond = 0.3048; - /// Knot to meters per second: 1852/3600 ≈ 0.514444 m/s per kn (exact) - internal const double KnotToMeterPerSecond = 0.5144444444444445; + /// Knot to meters per second: 1852/3600 = 463/900 m/s per kn (exact, stored as a fraction) + internal const double KnotToMeterPerSecond = 463d / 900d; - /// RPM to rad/s conversion: π/30 rad/s per rpm (exact) - internal const double RevolutionPerMinuteToRadianPerSecond = 0.10471975511965977; + /// RPM to rad/s conversion: 2π/60 = π/30 rad/s per rpm (π to 150 significant digits, taken as DegreeToRadians × 180) + internal const double RevolutionPerMinuteToRadianPerSecond = 0.104719755119659774615421446109316762806572313312503527365831486410260546876206966620934494178070584274606244240194904007943237790166706465766841898; /// Pound-foot to Newton-meter conversion: 1.3558179483314004 N⋅m per lb⋅ft (exact) internal const double PoundFootToNewtonMeters = 1.3558179483314004; @@ -231,8 +233,8 @@ internal static class ConversionConstants /// Calorie per mole to joule per mole: 4.184 J/mol per cal/mol (exact, thermochemical) internal const double CaloriePerMoleToJoulePerMole = 4.184; - /// Enzyme unit (1 μmol/min) to katal: 1/6e7 ≈ 1.6667e-8 kat/U (exact) - internal const double EnzymeUnitToKatals = 1.6666666666666667e-8; + /// Enzyme unit (1 μmol/min) to katal: 1e-6/60 = 1/60000000 kat/U (exact, stored as a fraction) + internal const double EnzymeUnitToKatals = 1d / 60000000d; /// Standard gravity to meters per second squared: 9.80665 m/s² per g (exact by definition) internal const double StandardGravityToMeterPerSecondSquared = 9.80665; @@ -255,11 +257,11 @@ internal static class ConversionConstants /// Roentgen to coulomb per kilogram: 2.58e-4 C/kg per R (exact by definition) internal const double RoentgenToCoulombsPerKilogram = 2.58e-4; - /// Foot-candle to lux conversion: 1/0.09290304 ≈ 10.7639 lx/fc (exact) - internal const double FootCandleToLux = 10.763910416709722; + /// Foot-candle to lux conversion: 1 lm/ft² = 1/0.09290304 = 100000000/9290304 lx/fc (exact, stored as a fraction) + internal const double FootCandleToLux = 100000000d / 9290304d; - /// Foot-lambert to candela per square meter: 1/(π·0.09290304) ≈ 3.4263 cd/m² per fL (exact) - internal const double FootLambertToCandelaPerSquareMeter = 3.4262590996353905; + /// Foot-lambert to candela per square meter: 1/(π × 0.09290304) cd/m² per fL (π to 150 significant digits, taken as DegreeToRadians × 180) + internal const double FootLambertToCandelaPerSquareMeter = 3.42625909963539052691674596165021859423458362052428959800814578422615229026362399099348746319287426200971476339509417994666710818534309005070458689906; /// Percent to ratio: 0.01 (exact by definition) internal const double PercentToRatio = 0.01; @@ -272,5 +274,276 @@ internal static class ConversionConstants /// Percent by weight to mass-fraction ratio: 0.01 (exact by definition) internal const double PercentByWeightToRatio = 0.01; + + /// + /// Caches each conversion constant materialised into at that type's own precision. + /// + internal static class Values + where T : struct, INumber + { + /// Foot to meter conversion: 0.3048 m/ft (exact by definition) + internal static readonly T FeetToMeters = StorageLiteral.Parse("0.3048", ConversionConstants.FeetToMeters); + + /// Inch to meter conversion: 0.0254 m/in (exact by definition) + internal static readonly T InchesToMeters = StorageLiteral.Parse("0.0254", ConversionConstants.InchesToMeters); + + /// Yard to meter conversion: 0.9144 m/yd (exact by definition) + internal static readonly T YardToMeters = StorageLiteral.Parse("0.9144", ConversionConstants.YardToMeters); + + /// Mile to meter conversion: 1609.344 m/mi (exact by definition) + internal static readonly T MileToMeters = StorageLiteral.Parse("1609.344", ConversionConstants.MileToMeters); + + /// Angstrom to meter conversion: 1e-10 m/Å (exact by definition) + internal static readonly T AngstromToMeters = StorageLiteral.Parse("1e-10", ConversionConstants.AngstromToMeters); + + /// Nautical mile to meter conversion: 1852 m/nmi (exact by definition) + internal static readonly T NauticalMileToMeters = StorageLiteral.Parse("1852", ConversionConstants.NauticalMileToMeters); + + /// Pound mass to kilogram: 0.453592 kg/lb (exact) + internal static readonly T PoundMassToKilogram = StorageLiteral.Parse("0.453592", ConversionConstants.PoundMassToKilogram); + + /// Pound to kilogram conversion: 0.45359237 kg/lb (exact by definition) + internal static readonly T PoundToKilograms = StorageLiteral.Parse("0.45359237", ConversionConstants.PoundToKilograms); + + /// Ounce to kilogram conversion: 0.028349523125 kg/oz (exact) + internal static readonly T OunceToKilograms = StorageLiteral.Parse("0.028349523125", ConversionConstants.OunceToKilograms); + + /// Metric ton to kilogram conversion: 1000 kg/t (exact by definition) + internal static readonly T TonToKilograms = StorageLiteral.Parse("1000", ConversionConstants.TonToKilograms); + + /// Stone to kilogram conversion: 6.35029318 kg/st (14 lb, exact) + internal static readonly T StoneToKilograms = StorageLiteral.Parse("6.35029318", ConversionConstants.StoneToKilograms); + + /// Short ton to kilogram conversion: 907.18474 kg/ton (2000 lb, exact) + internal static readonly T ShortTonToKilograms = StorageLiteral.Parse("907.18474", ConversionConstants.ShortTonToKilograms); + + /// Atomic mass unit to kilogram: 1.66053906660e-27 kg/u (2018 CODATA) + internal static readonly T AtomicMassUnitToKilograms = StorageLiteral.Parse("1.66053906660e-27", ConversionConstants.AtomicMassUnitToKilograms); + + /// Liter to cubic meter conversion: 0.001 m³/L (exact by definition) + internal static readonly T LiterToCubicMeters = StorageLiteral.Parse("0.001", ConversionConstants.LiterToCubicMeters); + + /// US gallon to cubic meter conversion: 0.003785411784 m³/gal (exact) + internal static readonly T GallonToCubicMeters = StorageLiteral.Parse("0.003785411784", ConversionConstants.GallonToCubicMeters); + + /// Cubic centimeter to cubic meter: 1e-6 m³/cm³ (exact by definition) + internal static readonly T CubicCentimeterToCubicMeters = StorageLiteral.Parse("1e-6", ConversionConstants.CubicCentimeterToCubicMeters); + + /// Cubic foot to cubic meter: 0.028316846592 m³/ft³ (exact) + internal static readonly T CubicFootToCubicMeters = StorageLiteral.Parse("0.028316846592", ConversionConstants.CubicFootToCubicMeters); + + /// Cubic inch to cubic meter: 1.6387064e-5 m³/in³ (exact) + internal static readonly T CubicInchToCubicMeters = StorageLiteral.Parse("1.6387064e-5", ConversionConstants.CubicInchToCubicMeters); + + /// Imperial gallon to cubic meter: 0.00454609 m³/imp gal (exact by definition) + internal static readonly T ImperialGallonToCubicMeters = StorageLiteral.Parse("0.00454609", ConversionConstants.ImperialGallonToCubicMeters); + + /// US liquid quart to cubic meter: 0.000946352946 m³/qt (exact) + internal static readonly T USQuartToCubicMeters = StorageLiteral.Parse("0.000946352946", ConversionConstants.USQuartToCubicMeters); + + /// US liquid pint to cubic meter: 0.000473176473 m³/pt (exact) + internal static readonly T USPintToCubicMeters = StorageLiteral.Parse("0.000473176473", ConversionConstants.USPintToCubicMeters); + + /// US fluid ounce to cubic meter: 2.95735295625e-5 m³/fl oz (exact) + internal static readonly T USFluidOunceToCubicMeters = StorageLiteral.Parse("2.95735295625e-5", ConversionConstants.USFluidOunceToCubicMeters); + + /// Minute to second conversion: 60 s/min (exact) + internal static readonly T MinuteToSeconds = StorageLiteral.Parse("60", ConversionConstants.MinuteToSeconds); + + /// Hour to second conversion: 3600 s/h (exact) + internal static readonly T HourToSeconds = StorageLiteral.Parse("3600", ConversionConstants.HourToSeconds); + + /// Day to second conversion: 86400 s/day (exact) + internal static readonly T DayToSeconds = StorageLiteral.Parse("86400", ConversionConstants.DayToSeconds); + + /// Year to second conversion: 31557600 s/year (365.25 days, exact) + internal static readonly T YearToSeconds = StorageLiteral.Parse("31557600", ConversionConstants.YearToSeconds); + + /// Week to second conversion: 604800 s/wk (exact) + internal static readonly T WeekToSeconds = StorageLiteral.Parse("604800", ConversionConstants.WeekToSeconds); + + /// Celsius to Kelvin temperature offset: 273.15 K (exact by definition) + internal static readonly T CelsiusToKelvinOffset = StorageLiteral.Parse("273.15", ConversionConstants.CelsiusToKelvinOffset); + + /// Fahrenheit-to-Kelvin degree scale factor: 5/9 K/°F (exact, stored as a fraction) + internal static readonly T FahrenheitScale = StorageLiteral.Divide("5", "9", ConversionConstants.FahrenheitScale); + + /// Fahrenheit to Kelvin affine offset: 459.67 × 5/9 = 45967/180 ≈ 255.372 K (exact, stored as a fraction) + internal static readonly T FahrenheitToKelvinOffset = StorageLiteral.Divide("45967", "180", ConversionConstants.FahrenheitToKelvinOffset); + + /// Degree to radian conversion: π/180 rad/° (exact) + internal static readonly T DegreeToRadians = StorageLiteral.Parse("0.017453292519943295769236907684886127134428718885417254560971914401710091146034494436822415696345097379101040706699150667990539631694451077627806983", ConversionConstants.DegreeToRadians); + + /// Gradian to radian conversion: π/200 rad/grad (π to 150 significant digits, taken as DegreeToRadians × 180) + internal static readonly T GradianToRadians = StorageLiteral.Parse("0.0157079632679489661923132169163975144209858469968755291048747229615390820314310449931401741267105876411909366360292356011914856685250059698650262847", ConversionConstants.GradianToRadians); + + /// Revolution to radian conversion: 2π rad/rev (π to 150 significant digits, taken as DegreeToRadians × 180) + internal static readonly T RevolutionToRadians = StorageLiteral.Parse("6.28318530717958647692528676655900576839433879875021164194988918461563281257241799725606965068423505647637465441169424047659426741000238794601051388", ConversionConstants.RevolutionToRadians); + + /// Calorie to joule conversion: 4.184 J/cal (exact, thermochemical calorie) + internal static readonly T CalorieToJoules = StorageLiteral.Parse("4.184", ConversionConstants.CalorieToJoules); + + /// Kilowatt-hour to joule conversion: 3600000 J/kWh (exact) + internal static readonly T KilowattHourToJoules = StorageLiteral.Parse("3600000", ConversionConstants.KilowattHourToJoules); + + /// Mechanical horsepower to watt conversion: 550 ft⋅lbf/s = 550 × 0.3048 × 4.4482216152605 = 745.69987158227022 W/hp (exact) + internal static readonly T HorsepowerToWatts = StorageLiteral.Parse("745.69987158227022", ConversionConstants.HorsepowerToWatts); + + /// Electron volt to joule conversion: 1.602176634e-19 J/eV (exact, based on elementary charge) + internal static readonly T ElectronVoltToJoules = StorageLiteral.Parse("1.602176634e-19", ConversionConstants.ElectronVoltToJoules); + + /// Kilocalorie to joule conversion: 4184 J/kcal (exact, thermochemical) + internal static readonly T KilocalorieToJoules = StorageLiteral.Parse("4184", ConversionConstants.KilocalorieToJoules); + + /// Watt-hour to joule conversion: 3600 J/Wh (exact) + internal static readonly T WattHourToJoules = StorageLiteral.Parse("3600", ConversionConstants.WattHourToJoules); + + /// Erg to joule conversion: 1e-7 J/erg (exact by definition) + internal static readonly T ErgToJoules = StorageLiteral.Parse("1e-7", ConversionConstants.ErgToJoules); + + /// British thermal unit (IT) to joule conversion: 1055.05585262 J/BTU (exact) + internal static readonly T BtuToJoules = StorageLiteral.Parse("1055.05585262", ConversionConstants.BtuToJoules); + + /// Bar to pascal conversion: 100000 Pa/bar (exact by definition) + internal static readonly T BarToPascals = StorageLiteral.Parse("100000", ConversionConstants.BarToPascals); + + /// Atmosphere to pascal conversion: 101325 Pa/atm (exact by definition) + internal static readonly T AtmosphereToPascals = StorageLiteral.Parse("101325", ConversionConstants.AtmosphereToPascals); + + /// PSI to pascal conversion: 4.4482216152605 N / 0.0254² m² = 8896443230521/1290320000 Pa/psi, written to 150 significant digits (a literal rather than the fraction, because float storage rounds that numerator before dividing) + internal static readonly T PsiToPascals = StorageLiteral.Parse("6894.75729316836133672267344534689069378138756277512555025110050220100440200880401760803521607043214086428172856345712691425382850765701531403062806126", ConversionConstants.PsiToPascals); + + /// Torr to pascal conversion: 101325/760 = 20265/152 Pa/Torr (exact, stored as a fraction) + internal static readonly T TorrToPascals = StorageLiteral.Divide("20265", "152", ConversionConstants.TorrToPascals); + + /// Square foot to square meter conversion: 0.09290304 m²/ft² (exact) + internal static readonly T SquareFootToSquareMeters = StorageLiteral.Parse("0.09290304", ConversionConstants.SquareFootToSquareMeters); + + /// Square inch to square meter conversion: 0.00064516 m²/in² (exact) + internal static readonly T SquareInchToSquareMeters = StorageLiteral.Parse("0.00064516", ConversionConstants.SquareInchToSquareMeters); + + /// Barn to square meter conversion: 1e-28 m² (exact by definition) + internal static readonly T BarnToSquareMeters = StorageLiteral.Parse("1e-28", ConversionConstants.BarnToSquareMeters); + + /// Square kilometer to square meter: 1e6 m²/km² (exact by definition) + internal static readonly T SquareKilometerToSquareMeters = StorageLiteral.Parse("1e6", ConversionConstants.SquareKilometerToSquareMeters); + + /// Square centimeter to square meter: 1e-4 m²/cm² (exact by definition) + internal static readonly T SquareCentimeterToSquareMeters = StorageLiteral.Parse("1e-4", ConversionConstants.SquareCentimeterToSquareMeters); + + /// Square mile to square meter: 2589988.110336 m²/mi² (exact) + internal static readonly T SquareMileToSquareMeters = StorageLiteral.Parse("2589988.110336", ConversionConstants.SquareMileToSquareMeters); + + /// Hectare to square meter: 10000 m²/ha (exact by definition) + internal static readonly T HectareToSquareMeters = StorageLiteral.Parse("10000", ConversionConstants.HectareToSquareMeters); + + /// Acre to square meter: 4046.8564224 m²/ac (exact) + internal static readonly T AcreToSquareMeters = StorageLiteral.Parse("4046.8564224", ConversionConstants.AcreToSquareMeters); + + /// Kilometers per hour to meters per second conversion: 1000/3600 = 5/18 m/s per km/h (exact, stored as a fraction) + internal static readonly T KilometerPerHourToMeterPerSecond = StorageLiteral.Divide("5", "18", ConversionConstants.KilometerPerHourToMeterPerSecond); + + /// Miles per hour to meters per second conversion: 0.44704 m/s per mph (exact) + internal static readonly T MilePerHourToMeterPerSecond = StorageLiteral.Parse("0.44704", ConversionConstants.MilePerHourToMeterPerSecond); + + /// Feet per second to meters per second: 0.3048 m/s per ft/s (exact) + internal static readonly T FootPerSecondToMeterPerSecond = StorageLiteral.Parse("0.3048", ConversionConstants.FootPerSecondToMeterPerSecond); + + /// Knot to meters per second: 1852/3600 = 463/900 m/s per kn (exact, stored as a fraction) + internal static readonly T KnotToMeterPerSecond = StorageLiteral.Divide("463", "900", ConversionConstants.KnotToMeterPerSecond); + + /// RPM to rad/s conversion: 2π/60 = π/30 rad/s per rpm (π to 150 significant digits, taken as DegreeToRadians × 180) + internal static readonly T RevolutionPerMinuteToRadianPerSecond = StorageLiteral.Parse("0.104719755119659774615421446109316762806572313312503527365831486410260546876206966620934494178070584274606244240194904007943237790166706465766841898", ConversionConstants.RevolutionPerMinuteToRadianPerSecond); + + /// Pound-foot to Newton-meter conversion: 1.3558179483314004 N⋅m per lb⋅ft (exact) + internal static readonly T PoundFootToNewtonMeters = StorageLiteral.Parse("1.3558179483314004", ConversionConstants.PoundFootToNewtonMeters); + + /// Molar to cubic meter concentration conversion: 1000.0 mol/m³ per mol/L (exact) + internal static readonly T MolarToCubicMeter = StorageLiteral.Parse("1000.0", ConversionConstants.MolarToCubicMeter); + + /// Millimolar to mole per cubic meter: 1 mol/m³ per mM (exact) + internal static readonly T MillimolarToMolePerCubicMeter = StorageLiteral.Parse("1.0", ConversionConstants.MillimolarToMolePerCubicMeter); + + /// Micromolar to mole per cubic meter: 0.001 mol/m³ per μM (exact) + internal static readonly T MicromolarToMolePerCubicMeter = StorageLiteral.Parse("0.001", ConversionConstants.MicromolarToMolePerCubicMeter); + + /// Stokes to square meter per second: 1e-4 m²/s per St (exact by definition) + internal static readonly T StokesToSquareMeterPerSecond = StorageLiteral.Parse("1e-4", ConversionConstants.StokesToSquareMeterPerSecond); + + /// Poise to pascal second: 0.1 Pa·s per P (exact by definition) + internal static readonly T PoiseToPascalSecond = StorageLiteral.Parse("0.1", ConversionConstants.PoiseToPascalSecond); + + /// Liter per second to cubic meter per second: 0.001 m³/s per L/s (exact by definition) + internal static readonly T LiterPerSecondToCubicMeterPerSecond = StorageLiteral.Parse("0.001", ConversionConstants.LiterPerSecondToCubicMeterPerSecond); + + /// Centipoise to pascal second: 0.001 Pa·s per cP (exact by definition) + internal static readonly T CentipoiseToPascalSecond = StorageLiteral.Parse("0.001", ConversionConstants.CentipoiseToPascalSecond); + + /// Dyne per centimeter to newton per meter: 0.001 N/m per dyn/cm (exact) + internal static readonly T DynePerCentimeterToNewtonPerMeter = StorageLiteral.Parse("0.001", ConversionConstants.DynePerCentimeterToNewtonPerMeter); + + /// Gram per cubic centimeter to kilogram per cubic meter: 1000 kg/m³ per g/cm³ (exact) + internal static readonly T GramPerCubicCentimeterToKilogramPerCubicMeter = StorageLiteral.Parse("1000", ConversionConstants.GramPerCubicCentimeterToKilogramPerCubicMeter); + + /// Gram per liter to kilogram per cubic meter: 1 kg/m³ per g/L (exact) + internal static readonly T GramPerLiterToKilogramPerCubicMeter = StorageLiteral.Parse("1.0", ConversionConstants.GramPerLiterToKilogramPerCubicMeter); + + /// Gauss to Tesla: 1e-4 T per G (exact by definition) + internal static readonly T GaussToTesla = StorageLiteral.Parse("1e-4", ConversionConstants.GaussToTesla); + + /// Ampere-hour to coulomb conversion: 3600 C/Ah (exact) + internal static readonly T AmpereHourToCoulombs = StorageLiteral.Parse("3600", ConversionConstants.AmpereHourToCoulombs); + + /// Gram per mole to kilogram per mole: 0.001 kg/mol per g/mol (exact by definition) + internal static readonly T GramPerMoleToKilogramPerMole = StorageLiteral.Parse("0.001", ConversionConstants.GramPerMoleToKilogramPerMole); + + /// Kilojoule per mole to joule per mole: 1000 J/mol per kJ/mol (exact by definition) + internal static readonly T KilojoulePerMoleToJoulePerMole = StorageLiteral.Parse("1000", ConversionConstants.KilojoulePerMoleToJoulePerMole); + + /// Calorie per mole to joule per mole: 4.184 J/mol per cal/mol (exact, thermochemical) + internal static readonly T CaloriePerMoleToJoulePerMole = StorageLiteral.Parse("4.184", ConversionConstants.CaloriePerMoleToJoulePerMole); + + /// Enzyme unit (1 μmol/min) to katal: 1e-6/60 = 1/60000000 kat/U (exact, stored as a fraction) + internal static readonly T EnzymeUnitToKatals = StorageLiteral.Divide("1", "60000000", ConversionConstants.EnzymeUnitToKatals); + + /// Standard gravity to meters per second squared: 9.80665 m/s² per g (exact by definition) + internal static readonly T StandardGravityToMeterPerSecondSquared = StorageLiteral.Parse("9.80665", ConversionConstants.StandardGravityToMeterPerSecondSquared); + + /// Dyne to newton conversion: 1e-5 N/dyn (exact by definition) + internal static readonly T DyneToNewtons = StorageLiteral.Parse("1e-5", ConversionConstants.DyneToNewtons); + + /// Pound-force to newton conversion: 4.4482216152605 N/lbf (exact) + internal static readonly T PoundForceToNewtons = StorageLiteral.Parse("4.4482216152605", ConversionConstants.PoundForceToNewtons); + + /// Curie to becquerel conversion: 3.7e10 Bq/Ci (exact by definition) + internal static readonly T CurieToBecquerels = StorageLiteral.Parse("3.7e10", ConversionConstants.CurieToBecquerels); + + /// Rad to gray conversion: 0.01 Gy/rad (exact by definition) + internal static readonly T RadToGrays = StorageLiteral.Parse("0.01", ConversionConstants.RadToGrays); + + /// Rem to sievert conversion: 0.01 Sv/rem (exact by definition) + internal static readonly T RemToSieverts = StorageLiteral.Parse("0.01", ConversionConstants.RemToSieverts); + + /// Roentgen to coulomb per kilogram: 2.58e-4 C/kg per R (exact by definition) + internal static readonly T RoentgenToCoulombsPerKilogram = StorageLiteral.Parse("2.58e-4", ConversionConstants.RoentgenToCoulombsPerKilogram); + + /// Foot-candle to lux conversion: 1 lm/ft² = 1/0.09290304 = 100000000/9290304 lx/fc (exact, stored as a fraction) + internal static readonly T FootCandleToLux = StorageLiteral.Divide("100000000", "9290304", ConversionConstants.FootCandleToLux); + + /// Foot-lambert to candela per square meter: 1/(π × 0.09290304) cd/m² per fL (π to 150 significant digits, taken as DegreeToRadians × 180) + internal static readonly T FootLambertToCandelaPerSquareMeter = StorageLiteral.Parse("3.42625909963539052691674596165021859423458362052428959800814578422615229026362399099348746319287426200971476339509417994666710818534309005070458689906", ConversionConstants.FootLambertToCandelaPerSquareMeter); + + /// Percent to ratio: 0.01 (exact by definition) + internal static readonly T PercentToRatio = StorageLiteral.Parse("0.01", ConversionConstants.PercentToRatio); + + /// Parts per million to ratio: 1e-6 (exact by definition) + internal static readonly T PartPerMillionToRatio = StorageLiteral.Parse("1e-6", ConversionConstants.PartPerMillionToRatio); + + /// Parts per billion to ratio: 1e-9 (exact by definition) + internal static readonly T PartPerBillionToRatio = StorageLiteral.Parse("1e-9", ConversionConstants.PartPerBillionToRatio); + + /// Percent by weight to mass-fraction ratio: 0.01 (exact by definition) + internal static readonly T PercentByWeightToRatio = StorageLiteral.Parse("0.01", ConversionConstants.PercentByWeightToRatio); + } } diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.MagnitudesGenerator/MetricMagnitudes.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.MagnitudesGenerator/MetricMagnitudes.g.cs index 9fc0fd2..c100586 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.MagnitudesGenerator/MetricMagnitudes.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.MagnitudesGenerator/MetricMagnitudes.g.cs @@ -3,6 +3,8 @@ namespace ktsu.Semantics.Quantities; +using System.Numerics; + /// /// Metric magnitude constants for unit scaling. /// @@ -70,5 +72,75 @@ public static class MetricMagnitudes /// Yocto magnitude (y): 10^-24 public const double Yocto = 1e-24; + + /// + /// Caches each magnitude materialised into at that type's own precision. + /// + internal static class Values + where T : struct, INumber + { + /// Yotta magnitude (Y): 10^24 + internal static readonly T Yotta = StorageLiteral.Parse("1e24", MetricMagnitudes.Yotta); + + /// Zetta magnitude (Z): 10^21 + internal static readonly T Zetta = StorageLiteral.Parse("1e21", MetricMagnitudes.Zetta); + + /// Exa magnitude (E): 10^18 + internal static readonly T Exa = StorageLiteral.Parse("1e18", MetricMagnitudes.Exa); + + /// Peta magnitude (P): 10^15 + internal static readonly T Peta = StorageLiteral.Parse("1e15", MetricMagnitudes.Peta); + + /// Tera magnitude (T): 10^12 + internal static readonly T Tera = StorageLiteral.Parse("1e12", MetricMagnitudes.Tera); + + /// Giga magnitude (G): 10^9 + internal static readonly T Giga = StorageLiteral.Parse("1e9", MetricMagnitudes.Giga); + + /// Mega magnitude (M): 10^6 + internal static readonly T Mega = StorageLiteral.Parse("1e6", MetricMagnitudes.Mega); + + /// Kilo magnitude (k): 10^3 + internal static readonly T Kilo = StorageLiteral.Parse("1e3", MetricMagnitudes.Kilo); + + /// Hecto magnitude (h): 10^2 + internal static readonly T Hecto = StorageLiteral.Parse("1e2", MetricMagnitudes.Hecto); + + /// Deka magnitude (da): 10^1 + internal static readonly T Deka = StorageLiteral.Parse("1e1", MetricMagnitudes.Deka); + + /// Unity magnitude (): 10^0 + internal static readonly T Unity = StorageLiteral.Parse("1.0", MetricMagnitudes.Unity); + + /// Deci magnitude (d): 10^-1 + internal static readonly T Deci = StorageLiteral.Parse("1e-1", MetricMagnitudes.Deci); + + /// Centi magnitude (c): 10^-2 + internal static readonly T Centi = StorageLiteral.Parse("1e-2", MetricMagnitudes.Centi); + + /// Milli magnitude (m): 10^-3 + internal static readonly T Milli = StorageLiteral.Parse("1e-3", MetricMagnitudes.Milli); + + /// Micro magnitude (μ): 10^-6 + internal static readonly T Micro = StorageLiteral.Parse("1e-6", MetricMagnitudes.Micro); + + /// Nano magnitude (n): 10^-9 + internal static readonly T Nano = StorageLiteral.Parse("1e-9", MetricMagnitudes.Nano); + + /// Pico magnitude (p): 10^-12 + internal static readonly T Pico = StorageLiteral.Parse("1e-12", MetricMagnitudes.Pico); + + /// Femto magnitude (f): 10^-15 + internal static readonly T Femto = StorageLiteral.Parse("1e-15", MetricMagnitudes.Femto); + + /// Atto magnitude (a): 10^-18 + internal static readonly T Atto = StorageLiteral.Parse("1e-18", MetricMagnitudes.Atto); + + /// Zepto magnitude (z): 10^-21 + internal static readonly T Zepto = StorageLiteral.Parse("1e-21", MetricMagnitudes.Zepto); + + /// Yocto magnitude (y): 10^-24 + internal static readonly T Yocto = StorageLiteral.Parse("1e-24", MetricMagnitudes.Yocto); + } } diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.PrecisionGenerator/StorageTypes.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.PrecisionGenerator/StorageTypes.g.cs index 4a90803..b91c01b 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.PrecisionGenerator/StorageTypes.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.PrecisionGenerator/StorageTypes.g.cs @@ -11,6 +11,9 @@ namespace ktsu.Semantics.Quantities; /// public static class StorageTypes { + /// The decimal storage type. + public static readonly Type DECIMAL = typeof(decimal); + /// The double storage type. public static readonly Type DOUBLE = typeof(double); @@ -18,9 +21,9 @@ public static class StorageTypes public static readonly Type FLOAT = typeof(float); /// Gets all available storage types. - public static readonly IReadOnlyList All = new List { DOUBLE, FLOAT }; + public static readonly IReadOnlyList All = new List { DECIMAL, DOUBLE, FLOAT }; /// Gets the names of all available storage types. - public static readonly IReadOnlyList Names = new List { "double", "float" }; + public static readonly IReadOnlyList Names = new List { "decimal", "double", "float" }; } diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AbsorbedDose.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AbsorbedDose.g.cs index 5fc5c1e..cfd64f6 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AbsorbedDose.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AbsorbedDose.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Rad. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static AbsorbedDose FromRad(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.RadToGrays)), nameof(value))); + public static AbsorbedDose FromRad(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.RadToGrays), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Acceleration1D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Acceleration1D.g.cs index 52ab0bb..1b64150 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Acceleration1D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Acceleration1D.g.cs @@ -109,7 +109,7 @@ namespace ktsu.Semantics.Quantities; /// /// The value in StandardGravity. /// A new instance. - public static Acceleration1D FromStandardGravity(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.StandardGravityToMeterPerSecondSquared))); + public static Acceleration1D FromStandardGravity(T value) => Create((value * Units.ConversionConstants.Values.StandardGravityToMeterPerSecondSquared)); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Acceleration2D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Acceleration2D.g.cs index 65b5bfb..8e49004 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Acceleration2D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Acceleration2D.g.cs @@ -41,8 +41,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -57,8 +56,7 @@ public T Distance(Acceleration2D other) T dX = X - other.X; T dY = Y - other.Y; T sum = (dX * dX) + (dY * dY); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Acceleration3D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Acceleration3D.g.cs index eaa4ed3..fba75b8 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Acceleration3D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Acceleration3D.g.cs @@ -47,8 +47,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -70,8 +69,7 @@ public T Distance(Acceleration3D other) T dY = Y - other.Y; T dZ = Z - other.Z; T sum = (dX * dX) + (dY * dY) + (dZ * dZ); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Acceleration4D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Acceleration4D.g.cs index 9706f11..16eec22 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Acceleration4D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Acceleration4D.g.cs @@ -53,8 +53,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z) + (W * W); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -71,8 +70,7 @@ public T Distance(Acceleration4D other) T dZ = Z - other.Z; T dW = W - other.W; T sum = (dX * dX) + (dY * dY) + (dZ * dZ) + (dW * dW); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AccelerationMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AccelerationMagnitude.g.cs index afc475a..c855e54 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AccelerationMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AccelerationMagnitude.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in StandardGravity. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static AccelerationMagnitude FromStandardGravity(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.StandardGravityToMeterPerSecondSquared)), nameof(value))); + public static AccelerationMagnitude FromStandardGravity(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.StandardGravityToMeterPerSecondSquared), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ActivationEnergy.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ActivationEnergy.g.cs index be969b4..dc62d47 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ActivationEnergy.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ActivationEnergy.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in KilojoulePerMole. /// A new ActivationEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static ActivationEnergy FromKilojoulePerMole(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilojoulePerMoleToJoulePerMole)), nameof(value))); + public static ActivationEnergy FromKilojoulePerMole(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilojoulePerMoleToJoulePerMole), nameof(value))); /// /// Creates a new ActivationEnergy from a value in CaloriePerMole. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in CaloriePerMole. /// A new ActivationEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static ActivationEnergy FromCaloriePerMole(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CaloriePerMoleToJoulePerMole)), nameof(value))); + public static ActivationEnergy FromCaloriePerMole(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.CaloriePerMoleToJoulePerMole), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Airspeed.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Airspeed.g.cs index 2e816a7..2ad923a 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Airspeed.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Airspeed.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in KilometerPerHour. /// A new Airspeed instance. /// Thrown when the resulting magnitude would be negative. - public static Airspeed FromKilometerPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilometerPerHourToMeterPerSecond)), nameof(value))); + public static Airspeed FromKilometerPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilometerPerHourToMeterPerSecond), nameof(value))); /// /// Creates a new Airspeed from a value in MilePerHour. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in MilePerHour. /// A new Airspeed instance. /// Thrown when the resulting magnitude would be negative. - public static Airspeed FromMilePerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MilePerHourToMeterPerSecond)), nameof(value))); + public static Airspeed FromMilePerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MilePerHourToMeterPerSecond), nameof(value))); /// /// Creates a new Airspeed from a value in FootPerSecond. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in FootPerSecond. /// A new Airspeed instance. /// Thrown when the resulting magnitude would be negative. - public static Airspeed FromFootPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FootPerSecondToMeterPerSecond)), nameof(value))); + public static Airspeed FromFootPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.FootPerSecondToMeterPerSecond), nameof(value))); /// /// Creates a new Airspeed from a value in Knot. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Knot. /// A new Airspeed instance. /// Thrown when the resulting magnitude would be negative. - public static Airspeed FromKnot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KnotToMeterPerSecond)), nameof(value))); + public static Airspeed FromKnot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KnotToMeterPerSecond), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Altitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Altitude.g.cs index d233136..07fd0f4 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Altitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Altitude.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilometer. /// A new Altitude instance. /// Thrown when the resulting magnitude would be negative. - public static Altitude FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Altitude FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new Altitude from a value in Centimeter. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Centimeter. /// A new Altitude instance. /// Thrown when the resulting magnitude would be negative. - public static Altitude FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Centi)), nameof(value))); + public static Altitude FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Centi), nameof(value))); /// /// Creates a new Altitude from a value in Millimeter. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Millimeter. /// A new Altitude instance. /// Thrown when the resulting magnitude would be negative. - public static Altitude FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static Altitude FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new Altitude from a value in Micrometer. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Micrometer. /// A new Altitude instance. /// Thrown when the resulting magnitude would be negative. - public static Altitude FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); + public static Altitude FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Micro), nameof(value))); /// /// Creates a new Altitude from a value in Nanometer. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Nanometer. /// A new Altitude instance. /// Thrown when the resulting magnitude would be negative. - public static Altitude FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); + public static Altitude FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Nano), nameof(value))); /// /// Creates a new Altitude from a value in Angstrom. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Angstrom. /// A new Altitude instance. /// Thrown when the resulting magnitude would be negative. - public static Altitude FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters)), nameof(value))); + public static Altitude FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AngstromToMeters), nameof(value))); /// /// Creates a new Altitude from a value in Foot. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Foot. /// A new Altitude instance. /// Thrown when the resulting magnitude would be negative. - public static Altitude FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters)), nameof(value))); + public static Altitude FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.FeetToMeters), nameof(value))); /// /// Creates a new Altitude from a value in Inch. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Inch. /// A new Altitude instance. /// Thrown when the resulting magnitude would be negative. - public static Altitude FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters)), nameof(value))); + public static Altitude FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.InchesToMeters), nameof(value))); /// /// Creates a new Altitude from a value in Yard. @@ -172,7 +172,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Yard. /// A new Altitude instance. /// Thrown when the resulting magnitude would be negative. - public static Altitude FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YardToMeters)), nameof(value))); + public static Altitude FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.YardToMeters), nameof(value))); /// /// Creates a new Altitude from a value in Mile. @@ -180,7 +180,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Mile. /// A new Altitude instance. /// Thrown when the resulting magnitude would be negative. - public static Altitude FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MileToMeters)), nameof(value))); + public static Altitude FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MileToMeters), nameof(value))); /// /// Creates a new Altitude from a value in NauticalMile. @@ -188,7 +188,7 @@ namespace ktsu.Semantics.Quantities; /// The value in NauticalMile. /// A new Altitude instance. /// Thrown when the resulting magnitude would be negative. - public static Altitude FromNauticalMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.NauticalMileToMeters)), nameof(value))); + public static Altitude FromNauticalMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.NauticalMileToMeters), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AmountOfSubstance.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AmountOfSubstance.g.cs index a849b46..2a88d95 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AmountOfSubstance.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AmountOfSubstance.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilomole. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static AmountOfSubstance FromKilomole(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static AmountOfSubstance FromKilomole(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new from a value in Millimole. @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Millimole. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static AmountOfSubstance FromMillimole(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static AmountOfSubstance FromMillimole(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Angle.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Angle.g.cs index b7485ca..987159b 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Angle.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Angle.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Degree. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Angle FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians)), nameof(value))); + public static Angle FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DegreeToRadians), nameof(value))); /// /// Creates a new from a value in Gradian. @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Gradian. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Angle FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GradianToRadians)), nameof(value))); + public static Angle FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.GradianToRadians), nameof(value))); /// /// Creates a new from a value in Revolution. @@ -123,7 +123,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Revolution. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Angle FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.RevolutionToRadians)), nameof(value))); + public static Angle FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.RevolutionToRadians), nameof(value))); /// /// Creates a new from a value in Milliradian. @@ -131,7 +131,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Milliradian. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Angle FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static Angle FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularAcceleration3D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularAcceleration3D.g.cs index 4c3bd13..64e3bf4 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularAcceleration3D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularAcceleration3D.g.cs @@ -47,8 +47,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -70,8 +69,7 @@ public T Distance(AngularAcceleration3D other) T dY = Y - other.Y; T dZ = Z - other.Z; T sum = (dX * dX) + (dY * dY) + (dZ * dZ); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularDisplacement3D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularDisplacement3D.g.cs index 59f79fe..12e7acf 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularDisplacement3D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularDisplacement3D.g.cs @@ -47,8 +47,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -70,8 +69,7 @@ public T Distance(AngularDisplacement3D other) T dY = Y - other.Y; T dZ = Z - other.Z; T sum = (dX * dX) + (dY * dY) + (dZ * dZ); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularJerk3D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularJerk3D.g.cs index 40ceb03..4ecd6d6 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularJerk3D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularJerk3D.g.cs @@ -47,8 +47,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -70,8 +69,7 @@ public T Distance(AngularJerk3D other) T dY = Y - other.Y; T dZ = Z - other.Z; T sum = (dX * dX) + (dY * dY) + (dZ * dZ); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularMomentum3D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularMomentum3D.g.cs index bd2920c..b39ba02 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularMomentum3D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularMomentum3D.g.cs @@ -47,8 +47,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -70,8 +69,7 @@ public T Distance(AngularMomentum3D other) T dY = Y - other.Y; T dZ = Z - other.Z; T sum = (dX * dX) + (dY * dY) + (dZ * dZ); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularSpeed.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularSpeed.g.cs index e4e3aba..9fc2934 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularSpeed.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularSpeed.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in RevolutionPerMinute. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static AngularSpeed FromRevolutionPerMinute(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.RevolutionPerMinuteToRadianPerSecond)), nameof(value))); + public static AngularSpeed FromRevolutionPerMinute(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.RevolutionPerMinuteToRadianPerSecond), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularVelocity1D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularVelocity1D.g.cs index 6913d2a..314aba9 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularVelocity1D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularVelocity1D.g.cs @@ -109,7 +109,7 @@ namespace ktsu.Semantics.Quantities; /// /// The value in RevolutionPerMinute. /// A new instance. - public static AngularVelocity1D FromRevolutionPerMinute(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.RevolutionPerMinuteToRadianPerSecond))); + public static AngularVelocity1D FromRevolutionPerMinute(T value) => Create((value * Units.ConversionConstants.Values.RevolutionPerMinuteToRadianPerSecond)); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularVelocity3D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularVelocity3D.g.cs index 738bfac..51a6381 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularVelocity3D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AngularVelocity3D.g.cs @@ -47,8 +47,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -70,8 +69,7 @@ public T Distance(AngularVelocity3D other) T dY = Y - other.Y; T dZ = Z - other.Z; T sum = (dX * dX) + (dY * dY) + (dZ * dZ); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ApertureAngle.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ApertureAngle.g.cs index e17ade2..2a2778a 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ApertureAngle.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ApertureAngle.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Degree. /// A new ApertureAngle instance. /// Thrown when the resulting magnitude would be negative. - public static ApertureAngle FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians)), nameof(value))); + public static ApertureAngle FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DegreeToRadians), nameof(value))); /// /// Creates a new ApertureAngle from a value in Gradian. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Gradian. /// A new ApertureAngle instance. /// Thrown when the resulting magnitude would be negative. - public static ApertureAngle FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GradianToRadians)), nameof(value))); + public static ApertureAngle FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.GradianToRadians), nameof(value))); /// /// Creates a new ApertureAngle from a value in Revolution. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Revolution. /// A new ApertureAngle instance. /// Thrown when the resulting magnitude would be negative. - public static ApertureAngle FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.RevolutionToRadians)), nameof(value))); + public static ApertureAngle FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.RevolutionToRadians), nameof(value))); /// /// Creates a new ApertureAngle from a value in Milliradian. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Milliradian. /// A new ApertureAngle instance. /// Thrown when the resulting magnitude would be negative. - public static ApertureAngle FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static ApertureAngle FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Area.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Area.g.cs index d99878d..0bca1df 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Area.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Area.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in SquareKilometer. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Area FromSquareKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.SquareKilometerToSquareMeters)), nameof(value))); + public static Area FromSquareKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.SquareKilometerToSquareMeters), nameof(value))); /// /// Creates a new from a value in SquareCentimeter. @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in SquareCentimeter. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Area FromSquareCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.SquareCentimeterToSquareMeters)), nameof(value))); + public static Area FromSquareCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.SquareCentimeterToSquareMeters), nameof(value))); /// /// Creates a new from a value in SquareFoot. @@ -123,7 +123,7 @@ namespace ktsu.Semantics.Quantities; /// The value in SquareFoot. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Area FromSquareFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.SquareFootToSquareMeters)), nameof(value))); + public static Area FromSquareFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.SquareFootToSquareMeters), nameof(value))); /// /// Creates a new from a value in SquareInch. @@ -131,7 +131,7 @@ namespace ktsu.Semantics.Quantities; /// The value in SquareInch. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Area FromSquareInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.SquareInchToSquareMeters)), nameof(value))); + public static Area FromSquareInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.SquareInchToSquareMeters), nameof(value))); /// /// Creates a new from a value in SquareMile. @@ -139,7 +139,7 @@ namespace ktsu.Semantics.Quantities; /// The value in SquareMile. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Area FromSquareMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.SquareMileToSquareMeters)), nameof(value))); + public static Area FromSquareMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.SquareMileToSquareMeters), nameof(value))); /// /// Creates a new from a value in Hectare. @@ -147,7 +147,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Hectare. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Area FromHectare(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.HectareToSquareMeters)), nameof(value))); + public static Area FromHectare(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.HectareToSquareMeters), nameof(value))); /// /// Creates a new from a value in Acre. @@ -155,7 +155,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Acre. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Area FromAcre(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AcreToSquareMeters)), nameof(value))); + public static Area FromAcre(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AcreToSquareMeters), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AtmosphericPressure.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AtmosphericPressure.g.cs index 5e95165..d165c15 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AtmosphericPressure.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AtmosphericPressure.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilopascal. /// A new AtmosphericPressure instance. /// Thrown when the resulting magnitude would be negative. - public static AtmosphericPressure FromKilopascal(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static AtmosphericPressure FromKilopascal(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new AtmosphericPressure from a value in Bar. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Bar. /// A new AtmosphericPressure instance. /// Thrown when the resulting magnitude would be negative. - public static AtmosphericPressure FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.BarToPascals)), nameof(value))); + public static AtmosphericPressure FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.BarToPascals), nameof(value))); /// /// Creates a new AtmosphericPressure from a value in Atmosphere. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Atmosphere. /// A new AtmosphericPressure instance. /// Thrown when the resulting magnitude would be negative. - public static AtmosphericPressure FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AtmosphereToPascals)), nameof(value))); + public static AtmosphericPressure FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AtmosphereToPascals), nameof(value))); /// /// Creates a new AtmosphericPressure from a value in Psi. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Psi. /// A new AtmosphericPressure instance. /// Thrown when the resulting magnitude would be negative. - public static AtmosphericPressure FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PsiToPascals)), nameof(value))); + public static AtmosphericPressure FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PsiToPascals), nameof(value))); /// /// Creates a new AtmosphericPressure from a value in Torr. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Torr. /// A new AtmosphericPressure instance. /// Thrown when the resulting magnitude would be negative. - public static AtmosphericPressure FromTorr(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.TorrToPascals)), nameof(value))); + public static AtmosphericPressure FromTorr(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.TorrToPascals), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AtomicMass.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AtomicMass.g.cs index 9f47522..a8589c4 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AtomicMass.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/AtomicMass.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Gram. /// A new AtomicMass instance. /// Thrown when the resulting magnitude would be negative. - public static AtomicMass FromGram(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static AtomicMass FromGram(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new AtomicMass from a value in Ton. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Ton. /// A new AtomicMass instance. /// Thrown when the resulting magnitude would be negative. - public static AtomicMass FromTon(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.TonToKilograms)), nameof(value))); + public static AtomicMass FromTon(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.TonToKilograms), nameof(value))); /// /// Creates a new AtomicMass from a value in Pound. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Pound. /// A new AtomicMass instance. /// Thrown when the resulting magnitude would be negative. - public static AtomicMass FromPound(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PoundToKilograms)), nameof(value))); + public static AtomicMass FromPound(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PoundToKilograms), nameof(value))); /// /// Creates a new AtomicMass from a value in Ounce. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Ounce. /// A new AtomicMass instance. /// Thrown when the resulting magnitude would be negative. - public static AtomicMass FromOunce(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.OunceToKilograms)), nameof(value))); + public static AtomicMass FromOunce(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.OunceToKilograms), nameof(value))); /// /// Creates a new AtomicMass from a value in Stone. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Stone. /// A new AtomicMass instance. /// Thrown when the resulting magnitude would be negative. - public static AtomicMass FromStone(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.StoneToKilograms)), nameof(value))); + public static AtomicMass FromStone(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.StoneToKilograms), nameof(value))); /// /// Creates a new AtomicMass from a value in ShortTon. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in ShortTon. /// A new AtomicMass instance. /// Thrown when the resulting magnitude would be negative. - public static AtomicMass FromShortTon(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.ShortTonToKilograms)), nameof(value))); + public static AtomicMass FromShortTon(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.ShortTonToKilograms), nameof(value))); /// /// Creates a new AtomicMass from a value in AtomicMassUnit. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in AtomicMassUnit. /// A new AtomicMass instance. /// Thrown when the resulting magnitude would be negative. - public static AtomicMass FromAtomicMassUnit(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AtomicMassUnitToKilograms)), nameof(value))); + public static AtomicMass FromAtomicMassUnit(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AtomicMassUnitToKilograms), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Bandwidth.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Bandwidth.g.cs index f4038bf..aa0aefb 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Bandwidth.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Bandwidth.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilohertz. /// A new Bandwidth instance. /// Thrown when the resulting magnitude would be negative. - public static Bandwidth FromKilohertz(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Bandwidth FromKilohertz(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new Bandwidth from a value in Megahertz. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Megahertz. /// A new Bandwidth instance. /// Thrown when the resulting magnitude would be negative. - public static Bandwidth FromMegahertz(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Mega)), nameof(value))); + public static Bandwidth FromMegahertz(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Mega), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Bearing.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Bearing.g.cs index 7cf87aa..c9f710b 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Bearing.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Bearing.g.cs @@ -110,28 +110,28 @@ namespace ktsu.Semantics.Quantities; /// /// The value in Degree. /// A new Bearing instance. - public static Bearing FromDegree(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians))); + public static Bearing FromDegree(T value) => Create((value * Units.ConversionConstants.Values.DegreeToRadians)); /// /// Creates a new Bearing from a value in Gradian. /// /// The value in Gradian. /// A new Bearing instance. - public static Bearing FromGradian(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.GradianToRadians))); + public static Bearing FromGradian(T value) => Create((value * Units.ConversionConstants.Values.GradianToRadians)); /// /// Creates a new Bearing from a value in Revolution. /// /// The value in Revolution. /// A new Bearing instance. - public static Bearing FromRevolution(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.RevolutionToRadians))); + public static Bearing FromRevolution(T value) => Create((value * Units.ConversionConstants.Values.RevolutionToRadians)); /// /// Creates a new Bearing from a value in Milliradian. /// /// The value in Milliradian. /// A new Bearing instance. - public static Bearing FromMilliradian(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Milli))); + public static Bearing FromMilliradian(T value) => Create((value * MetricMagnitudes.Values.Milli)); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/BulkModulus.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/BulkModulus.g.cs index 8ca9ab6..db2819d 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/BulkModulus.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/BulkModulus.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilopascal. /// A new BulkModulus instance. /// Thrown when the resulting magnitude would be negative. - public static BulkModulus FromKilopascal(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static BulkModulus FromKilopascal(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new BulkModulus from a value in Bar. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Bar. /// A new BulkModulus instance. /// Thrown when the resulting magnitude would be negative. - public static BulkModulus FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.BarToPascals)), nameof(value))); + public static BulkModulus FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.BarToPascals), nameof(value))); /// /// Creates a new BulkModulus from a value in Atmosphere. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Atmosphere. /// A new BulkModulus instance. /// Thrown when the resulting magnitude would be negative. - public static BulkModulus FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AtmosphereToPascals)), nameof(value))); + public static BulkModulus FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AtmosphereToPascals), nameof(value))); /// /// Creates a new BulkModulus from a value in Psi. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Psi. /// A new BulkModulus instance. /// Thrown when the resulting magnitude would be negative. - public static BulkModulus FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PsiToPascals)), nameof(value))); + public static BulkModulus FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PsiToPascals), nameof(value))); /// /// Creates a new BulkModulus from a value in Torr. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Torr. /// A new BulkModulus instance. /// Thrown when the resulting magnitude would be negative. - public static BulkModulus FromTorr(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.TorrToPascals)), nameof(value))); + public static BulkModulus FromTorr(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.TorrToPascals), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Capacitance.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Capacitance.g.cs index b05ed0f..f3b5e9f 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Capacitance.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Capacitance.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Microfarad. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Capacitance FromMicrofarad(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); + public static Capacitance FromMicrofarad(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Micro), nameof(value))); /// /// Creates a new from a value in Nanofarad. @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Nanofarad. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Capacitance FromNanofarad(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); + public static Capacitance FromNanofarad(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Nano), nameof(value))); /// /// Creates a new from a value in Picofarad. @@ -123,7 +123,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Picofarad. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Capacitance FromPicofarad(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Pico)), nameof(value))); + public static Capacitance FromPicofarad(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Pico), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Capacity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Capacity.g.cs index 392c87b..e4399a7 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Capacity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Capacity.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Liter. /// A new Capacity instance. /// Thrown when the resulting magnitude would be negative. - public static Capacity FromLiter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.LiterToCubicMeters)), nameof(value))); + public static Capacity FromLiter(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.LiterToCubicMeters), nameof(value))); /// /// Creates a new Capacity from a value in Milliliter. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Milliliter. /// A new Capacity instance. /// Thrown when the resulting magnitude would be negative. - public static Capacity FromMilliliter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static Capacity FromMilliliter(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new Capacity from a value in CubicCentimeter. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in CubicCentimeter. /// A new Capacity instance. /// Thrown when the resulting magnitude would be negative. - public static Capacity FromCubicCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CubicCentimeterToCubicMeters)), nameof(value))); + public static Capacity FromCubicCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.CubicCentimeterToCubicMeters), nameof(value))); /// /// Creates a new Capacity from a value in CubicFoot. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in CubicFoot. /// A new Capacity instance. /// Thrown when the resulting magnitude would be negative. - public static Capacity FromCubicFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CubicFootToCubicMeters)), nameof(value))); + public static Capacity FromCubicFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.CubicFootToCubicMeters), nameof(value))); /// /// Creates a new Capacity from a value in CubicInch. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in CubicInch. /// A new Capacity instance. /// Thrown when the resulting magnitude would be negative. - public static Capacity FromCubicInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CubicInchToCubicMeters)), nameof(value))); + public static Capacity FromCubicInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.CubicInchToCubicMeters), nameof(value))); /// /// Creates a new Capacity from a value in Gallon. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Gallon. /// A new Capacity instance. /// Thrown when the resulting magnitude would be negative. - public static Capacity FromGallon(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GallonToCubicMeters)), nameof(value))); + public static Capacity FromGallon(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.GallonToCubicMeters), nameof(value))); /// /// Creates a new Capacity from a value in ImperialGallon. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in ImperialGallon. /// A new Capacity instance. /// Thrown when the resulting magnitude would be negative. - public static Capacity FromImperialGallon(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.ImperialGallonToCubicMeters)), nameof(value))); + public static Capacity FromImperialGallon(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.ImperialGallonToCubicMeters), nameof(value))); /// /// Creates a new Capacity from a value in USQuart. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in USQuart. /// A new Capacity instance. /// Thrown when the resulting magnitude would be negative. - public static Capacity FromUSQuart(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.USQuartToCubicMeters)), nameof(value))); + public static Capacity FromUSQuart(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.USQuartToCubicMeters), nameof(value))); /// /// Creates a new Capacity from a value in USPint. @@ -172,7 +172,7 @@ namespace ktsu.Semantics.Quantities; /// The value in USPint. /// A new Capacity instance. /// Thrown when the resulting magnitude would be negative. - public static Capacity FromUSPint(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.USPintToCubicMeters)), nameof(value))); + public static Capacity FromUSPint(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.USPintToCubicMeters), nameof(value))); /// /// Creates a new Capacity from a value in USFluidOunce. @@ -180,7 +180,7 @@ namespace ktsu.Semantics.Quantities; /// The value in USFluidOunce. /// A new Capacity instance. /// Thrown when the resulting magnitude would be negative. - public static Capacity FromUSFluidOunce(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.USFluidOunceToCubicMeters)), nameof(value))); + public static Capacity FromUSFluidOunce(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.USFluidOunceToCubicMeters), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CatalyticActivity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CatalyticActivity.g.cs index 6136966..7bccb41 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CatalyticActivity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CatalyticActivity.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in EnzymeUnit. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static CatalyticActivity FromEnzymeUnit(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.EnzymeUnitToKatals)), nameof(value))); + public static CatalyticActivity FromEnzymeUnit(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.EnzymeUnitToKatals), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Charge.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Charge.g.cs index 48148c1..255a67d 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Charge.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Charge.g.cs @@ -109,7 +109,7 @@ namespace ktsu.Semantics.Quantities; /// /// The value in AmpereHour. /// A new instance. - public static Charge FromAmpereHour(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.AmpereHourToCoulombs))); + public static Charge FromAmpereHour(T value) => Create((value * Units.ConversionConstants.Values.AmpereHourToCoulombs)); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ChargeMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ChargeMagnitude.g.cs index 39c1125..279136c 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ChargeMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ChargeMagnitude.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in AmpereHour. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static ChargeMagnitude FromAmpereHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AmpereHourToCoulombs)), nameof(value))); + public static ChargeMagnitude FromAmpereHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AmpereHourToCoulombs), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ClockSpeed.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ClockSpeed.g.cs index 60b8261..75eb268 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ClockSpeed.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ClockSpeed.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilohertz. /// A new ClockSpeed instance. /// Thrown when the resulting magnitude would be negative. - public static ClockSpeed FromKilohertz(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static ClockSpeed FromKilohertz(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new ClockSpeed from a value in Megahertz. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Megahertz. /// A new ClockSpeed instance. /// Thrown when the resulting magnitude would be negative. - public static ClockSpeed FromMegahertz(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Mega)), nameof(value))); + public static ClockSpeed FromMegahertz(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Mega), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Concentration.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Concentration.g.cs index 3568814..2e37a81 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Concentration.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Concentration.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Molar. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Concentration FromMolar(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MolarToCubicMeter)), nameof(value))); + public static Concentration FromMolar(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MolarToCubicMeter), nameof(value))); /// /// Creates a new from a value in Millimolar. @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Millimolar. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Concentration FromMillimolar(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MillimolarToMolePerCubicMeter)), nameof(value))); + public static Concentration FromMillimolar(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MillimolarToMolePerCubicMeter), nameof(value))); /// /// Creates a new from a value in Micromolar. @@ -123,7 +123,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Micromolar. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Concentration FromMicromolar(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MicromolarToMolePerCubicMeter)), nameof(value))); + public static Concentration FromMicromolar(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MicromolarToMolePerCubicMeter), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CrossSectionalArea.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CrossSectionalArea.g.cs index e869750..4989e0f 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CrossSectionalArea.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CrossSectionalArea.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in SquareKilometer. /// A new CrossSectionalArea instance. /// Thrown when the resulting magnitude would be negative. - public static CrossSectionalArea FromSquareKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.SquareKilometerToSquareMeters)), nameof(value))); + public static CrossSectionalArea FromSquareKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.SquareKilometerToSquareMeters), nameof(value))); /// /// Creates a new CrossSectionalArea from a value in SquareCentimeter. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in SquareCentimeter. /// A new CrossSectionalArea instance. /// Thrown when the resulting magnitude would be negative. - public static CrossSectionalArea FromSquareCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.SquareCentimeterToSquareMeters)), nameof(value))); + public static CrossSectionalArea FromSquareCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.SquareCentimeterToSquareMeters), nameof(value))); /// /// Creates a new CrossSectionalArea from a value in SquareFoot. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in SquareFoot. /// A new CrossSectionalArea instance. /// Thrown when the resulting magnitude would be negative. - public static CrossSectionalArea FromSquareFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.SquareFootToSquareMeters)), nameof(value))); + public static CrossSectionalArea FromSquareFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.SquareFootToSquareMeters), nameof(value))); /// /// Creates a new CrossSectionalArea from a value in SquareInch. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in SquareInch. /// A new CrossSectionalArea instance. /// Thrown when the resulting magnitude would be negative. - public static CrossSectionalArea FromSquareInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.SquareInchToSquareMeters)), nameof(value))); + public static CrossSectionalArea FromSquareInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.SquareInchToSquareMeters), nameof(value))); /// /// Creates a new CrossSectionalArea from a value in SquareMile. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in SquareMile. /// A new CrossSectionalArea instance. /// Thrown when the resulting magnitude would be negative. - public static CrossSectionalArea FromSquareMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.SquareMileToSquareMeters)), nameof(value))); + public static CrossSectionalArea FromSquareMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.SquareMileToSquareMeters), nameof(value))); /// /// Creates a new CrossSectionalArea from a value in Hectare. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Hectare. /// A new CrossSectionalArea instance. /// Thrown when the resulting magnitude would be negative. - public static CrossSectionalArea FromHectare(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.HectareToSquareMeters)), nameof(value))); + public static CrossSectionalArea FromHectare(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.HectareToSquareMeters), nameof(value))); /// /// Creates a new CrossSectionalArea from a value in Acre. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Acre. /// A new CrossSectionalArea instance. /// Thrown when the resulting magnitude would be negative. - public static CrossSectionalArea FromAcre(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AcreToSquareMeters)), nameof(value))); + public static CrossSectionalArea FromAcre(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AcreToSquareMeters), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Current1D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Current1D.g.cs index c1febe3..41a22b0 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Current1D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Current1D.g.cs @@ -109,14 +109,14 @@ namespace ktsu.Semantics.Quantities; /// /// The value in Milliampere. /// A new instance. - public static Current1D FromMilliampere(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Milli))); + public static Current1D FromMilliampere(T value) => Create((value * MetricMagnitudes.Values.Milli)); /// /// Creates a new from a value in Kiloampere. /// /// The value in Kiloampere. /// A new instance. - public static Current1D FromKiloampere(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Kilo))); + public static Current1D FromKiloampere(T value) => Create((value * MetricMagnitudes.Values.Kilo)); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Current3D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Current3D.g.cs index e7a998b..ba4134a 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Current3D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Current3D.g.cs @@ -47,8 +47,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -70,8 +69,7 @@ public T Distance(Current3D other) T dY = Y - other.Y; T dZ = Z - other.Z; T sum = (dX * dX) + (dY * dY) + (dZ * dZ); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CurrentMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CurrentMagnitude.g.cs index 07b392c..69a84c6 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CurrentMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/CurrentMagnitude.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Milliampere. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static CurrentMagnitude FromMilliampere(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static CurrentMagnitude FromMilliampere(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new from a value in Kiloampere. @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kiloampere. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static CurrentMagnitude FromKiloampere(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static CurrentMagnitude FromKiloampere(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/DecayTime.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/DecayTime.g.cs index db2afa3..3c2e0ff 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/DecayTime.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/DecayTime.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Millisecond. /// A new DecayTime instance. /// Thrown when the resulting magnitude would be negative. - public static DecayTime FromMillisecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static DecayTime FromMillisecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new DecayTime from a value in Microsecond. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Microsecond. /// A new DecayTime instance. /// Thrown when the resulting magnitude would be negative. - public static DecayTime FromMicrosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); + public static DecayTime FromMicrosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Micro), nameof(value))); /// /// Creates a new DecayTime from a value in Minute. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Minute. /// A new DecayTime instance. /// Thrown when the resulting magnitude would be negative. - public static DecayTime FromMinute(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MinuteToSeconds)), nameof(value))); + public static DecayTime FromMinute(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MinuteToSeconds), nameof(value))); /// /// Creates a new DecayTime from a value in Hour. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Hour. /// A new DecayTime instance. /// Thrown when the resulting magnitude would be negative. - public static DecayTime FromHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.HourToSeconds)), nameof(value))); + public static DecayTime FromHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.HourToSeconds), nameof(value))); /// /// Creates a new DecayTime from a value in Day. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Day. /// A new DecayTime instance. /// Thrown when the resulting magnitude would be negative. - public static DecayTime FromDay(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DayToSeconds)), nameof(value))); + public static DecayTime FromDay(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DayToSeconds), nameof(value))); /// /// Creates a new DecayTime from a value in Year. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Year. /// A new DecayTime instance. /// Thrown when the resulting magnitude would be negative. - public static DecayTime FromYear(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YearToSeconds)), nameof(value))); + public static DecayTime FromYear(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.YearToSeconds), nameof(value))); /// /// Creates a new DecayTime from a value in Week. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Week. /// A new DecayTime instance. /// Thrown when the resulting magnitude would be negative. - public static DecayTime FromWeek(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.WeekToSeconds)), nameof(value))); + public static DecayTime FromWeek(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.WeekToSeconds), nameof(value))); /// /// Creates a new DecayTime from a value in Nanosecond. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Nanosecond. /// A new DecayTime instance. /// Thrown when the resulting magnitude would be negative. - public static DecayTime FromNanosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); + public static DecayTime FromNanosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Nano), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Density.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Density.g.cs index f69d5ee..cce24a6 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Density.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Density.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in GramPerCubicCentimeter. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Density FromGramPerCubicCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GramPerCubicCentimeterToKilogramPerCubicMeter)), nameof(value))); + public static Density FromGramPerCubicCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.GramPerCubicCentimeterToKilogramPerCubicMeter), nameof(value))); /// /// Creates a new from a value in GramPerLiter. @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in GramPerLiter. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Density FromGramPerLiter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GramPerLiterToKilogramPerCubicMeter)), nameof(value))); + public static Density FromGramPerLiter(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.GramPerLiterToKilogramPerCubicMeter), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Depth.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Depth.g.cs index 081c932..5a6a27c 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Depth.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Depth.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilometer. /// A new Depth instance. /// Thrown when the resulting magnitude would be negative. - public static Depth FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Depth FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new Depth from a value in Centimeter. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Centimeter. /// A new Depth instance. /// Thrown when the resulting magnitude would be negative. - public static Depth FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Centi)), nameof(value))); + public static Depth FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Centi), nameof(value))); /// /// Creates a new Depth from a value in Millimeter. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Millimeter. /// A new Depth instance. /// Thrown when the resulting magnitude would be negative. - public static Depth FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static Depth FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new Depth from a value in Micrometer. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Micrometer. /// A new Depth instance. /// Thrown when the resulting magnitude would be negative. - public static Depth FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); + public static Depth FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Micro), nameof(value))); /// /// Creates a new Depth from a value in Nanometer. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Nanometer. /// A new Depth instance. /// Thrown when the resulting magnitude would be negative. - public static Depth FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); + public static Depth FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Nano), nameof(value))); /// /// Creates a new Depth from a value in Angstrom. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Angstrom. /// A new Depth instance. /// Thrown when the resulting magnitude would be negative. - public static Depth FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters)), nameof(value))); + public static Depth FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AngstromToMeters), nameof(value))); /// /// Creates a new Depth from a value in Foot. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Foot. /// A new Depth instance. /// Thrown when the resulting magnitude would be negative. - public static Depth FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters)), nameof(value))); + public static Depth FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.FeetToMeters), nameof(value))); /// /// Creates a new Depth from a value in Inch. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Inch. /// A new Depth instance. /// Thrown when the resulting magnitude would be negative. - public static Depth FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters)), nameof(value))); + public static Depth FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.InchesToMeters), nameof(value))); /// /// Creates a new Depth from a value in Yard. @@ -172,7 +172,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Yard. /// A new Depth instance. /// Thrown when the resulting magnitude would be negative. - public static Depth FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YardToMeters)), nameof(value))); + public static Depth FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.YardToMeters), nameof(value))); /// /// Creates a new Depth from a value in Mile. @@ -180,7 +180,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Mile. /// A new Depth instance. /// Thrown when the resulting magnitude would be negative. - public static Depth FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MileToMeters)), nameof(value))); + public static Depth FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MileToMeters), nameof(value))); /// /// Creates a new Depth from a value in NauticalMile. @@ -188,7 +188,7 @@ namespace ktsu.Semantics.Quantities; /// The value in NauticalMile. /// A new Depth instance. /// Thrown when the resulting magnitude would be negative. - public static Depth FromNauticalMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.NauticalMileToMeters)), nameof(value))); + public static Depth FromNauticalMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.NauticalMileToMeters), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Diameter.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Diameter.g.cs index 8ec9507..3645ac9 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Diameter.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Diameter.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilometer. /// A new Diameter instance. /// Thrown when the resulting magnitude would be negative. - public static Diameter FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Diameter FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new Diameter from a value in Centimeter. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Centimeter. /// A new Diameter instance. /// Thrown when the resulting magnitude would be negative. - public static Diameter FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Centi)), nameof(value))); + public static Diameter FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Centi), nameof(value))); /// /// Creates a new Diameter from a value in Millimeter. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Millimeter. /// A new Diameter instance. /// Thrown when the resulting magnitude would be negative. - public static Diameter FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static Diameter FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new Diameter from a value in Micrometer. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Micrometer. /// A new Diameter instance. /// Thrown when the resulting magnitude would be negative. - public static Diameter FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); + public static Diameter FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Micro), nameof(value))); /// /// Creates a new Diameter from a value in Nanometer. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Nanometer. /// A new Diameter instance. /// Thrown when the resulting magnitude would be negative. - public static Diameter FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); + public static Diameter FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Nano), nameof(value))); /// /// Creates a new Diameter from a value in Angstrom. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Angstrom. /// A new Diameter instance. /// Thrown when the resulting magnitude would be negative. - public static Diameter FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters)), nameof(value))); + public static Diameter FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AngstromToMeters), nameof(value))); /// /// Creates a new Diameter from a value in Foot. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Foot. /// A new Diameter instance. /// Thrown when the resulting magnitude would be negative. - public static Diameter FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters)), nameof(value))); + public static Diameter FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.FeetToMeters), nameof(value))); /// /// Creates a new Diameter from a value in Inch. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Inch. /// A new Diameter instance. /// Thrown when the resulting magnitude would be negative. - public static Diameter FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters)), nameof(value))); + public static Diameter FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.InchesToMeters), nameof(value))); /// /// Creates a new Diameter from a value in Yard. @@ -172,7 +172,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Yard. /// A new Diameter instance. /// Thrown when the resulting magnitude would be negative. - public static Diameter FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YardToMeters)), nameof(value))); + public static Diameter FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.YardToMeters), nameof(value))); /// /// Creates a new Diameter from a value in Mile. @@ -180,7 +180,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Mile. /// A new Diameter instance. /// Thrown when the resulting magnitude would be negative. - public static Diameter FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MileToMeters)), nameof(value))); + public static Diameter FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MileToMeters), nameof(value))); /// /// Creates a new Diameter from a value in NauticalMile. @@ -188,7 +188,7 @@ namespace ktsu.Semantics.Quantities; /// The value in NauticalMile. /// A new Diameter instance. /// Thrown when the resulting magnitude would be negative. - public static Diameter FromNauticalMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.NauticalMileToMeters)), nameof(value))); + public static Diameter FromNauticalMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.NauticalMileToMeters), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Displacement1D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Displacement1D.g.cs index a689a9b..2d4dbaf 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Displacement1D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Displacement1D.g.cs @@ -109,77 +109,77 @@ namespace ktsu.Semantics.Quantities; /// /// The value in Kilometer. /// A new instance. - public static Displacement1D FromKilometer(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Kilo))); + public static Displacement1D FromKilometer(T value) => Create((value * MetricMagnitudes.Values.Kilo)); /// /// Creates a new from a value in Centimeter. /// /// The value in Centimeter. /// A new instance. - public static Displacement1D FromCentimeter(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Centi))); + public static Displacement1D FromCentimeter(T value) => Create((value * MetricMagnitudes.Values.Centi)); /// /// Creates a new from a value in Millimeter. /// /// The value in Millimeter. /// A new instance. - public static Displacement1D FromMillimeter(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Milli))); + public static Displacement1D FromMillimeter(T value) => Create((value * MetricMagnitudes.Values.Milli)); /// /// Creates a new from a value in Micrometer. /// /// The value in Micrometer. /// A new instance. - public static Displacement1D FromMicrometer(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Micro))); + public static Displacement1D FromMicrometer(T value) => Create((value * MetricMagnitudes.Values.Micro)); /// /// Creates a new from a value in Nanometer. /// /// The value in Nanometer. /// A new instance. - public static Displacement1D FromNanometer(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Nano))); + public static Displacement1D FromNanometer(T value) => Create((value * MetricMagnitudes.Values.Nano)); /// /// Creates a new from a value in Angstrom. /// /// The value in Angstrom. /// A new instance. - public static Displacement1D FromAngstrom(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters))); + public static Displacement1D FromAngstrom(T value) => Create((value * Units.ConversionConstants.Values.AngstromToMeters)); /// /// Creates a new from a value in Foot. /// /// The value in Foot. /// A new instance. - public static Displacement1D FromFoot(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters))); + public static Displacement1D FromFoot(T value) => Create((value * Units.ConversionConstants.Values.FeetToMeters)); /// /// Creates a new from a value in Inch. /// /// The value in Inch. /// A new instance. - public static Displacement1D FromInch(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters))); + public static Displacement1D FromInch(T value) => Create((value * Units.ConversionConstants.Values.InchesToMeters)); /// /// Creates a new from a value in Yard. /// /// The value in Yard. /// A new instance. - public static Displacement1D FromYard(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.YardToMeters))); + public static Displacement1D FromYard(T value) => Create((value * Units.ConversionConstants.Values.YardToMeters)); /// /// Creates a new from a value in Mile. /// /// The value in Mile. /// A new instance. - public static Displacement1D FromMile(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.MileToMeters))); + public static Displacement1D FromMile(T value) => Create((value * Units.ConversionConstants.Values.MileToMeters)); /// /// Creates a new from a value in NauticalMile. /// /// The value in NauticalMile. /// A new instance. - public static Displacement1D FromNauticalMile(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.NauticalMileToMeters))); + public static Displacement1D FromNauticalMile(T value) => Create((value * Units.ConversionConstants.Values.NauticalMileToMeters)); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Displacement2D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Displacement2D.g.cs index 1933e36..8287e98 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Displacement2D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Displacement2D.g.cs @@ -41,8 +41,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -57,8 +56,7 @@ public T Distance(Displacement2D other) T dX = X - other.X; T dY = Y - other.Y; T sum = (dX * dX) + (dY * dY); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Displacement3D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Displacement3D.g.cs index d81bf12..d15dadb 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Displacement3D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Displacement3D.g.cs @@ -47,8 +47,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -70,8 +69,7 @@ public T Distance(Displacement3D other) T dY = Y - other.Y; T dZ = Z - other.Z; T sum = (dX * dX) + (dY * dY) + (dZ * dZ); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Displacement4D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Displacement4D.g.cs index f3e7919..e4d46e6 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Displacement4D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Displacement4D.g.cs @@ -53,8 +53,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z) + (W * W); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -71,8 +70,7 @@ public T Distance(Displacement4D other) T dZ = Z - other.Z; T dW = W - other.W; T sum = (dX * dX) + (dY * dY) + (dZ * dZ) + (dW * dW); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Distance.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Distance.g.cs index 720e445..8c33534 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Distance.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Distance.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilometer. /// A new Distance instance. /// Thrown when the resulting magnitude would be negative. - public static Distance FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Distance FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new Distance from a value in Centimeter. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Centimeter. /// A new Distance instance. /// Thrown when the resulting magnitude would be negative. - public static Distance FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Centi)), nameof(value))); + public static Distance FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Centi), nameof(value))); /// /// Creates a new Distance from a value in Millimeter. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Millimeter. /// A new Distance instance. /// Thrown when the resulting magnitude would be negative. - public static Distance FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static Distance FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new Distance from a value in Micrometer. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Micrometer. /// A new Distance instance. /// Thrown when the resulting magnitude would be negative. - public static Distance FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); + public static Distance FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Micro), nameof(value))); /// /// Creates a new Distance from a value in Nanometer. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Nanometer. /// A new Distance instance. /// Thrown when the resulting magnitude would be negative. - public static Distance FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); + public static Distance FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Nano), nameof(value))); /// /// Creates a new Distance from a value in Angstrom. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Angstrom. /// A new Distance instance. /// Thrown when the resulting magnitude would be negative. - public static Distance FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters)), nameof(value))); + public static Distance FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AngstromToMeters), nameof(value))); /// /// Creates a new Distance from a value in Foot. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Foot. /// A new Distance instance. /// Thrown when the resulting magnitude would be negative. - public static Distance FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters)), nameof(value))); + public static Distance FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.FeetToMeters), nameof(value))); /// /// Creates a new Distance from a value in Inch. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Inch. /// A new Distance instance. /// Thrown when the resulting magnitude would be negative. - public static Distance FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters)), nameof(value))); + public static Distance FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.InchesToMeters), nameof(value))); /// /// Creates a new Distance from a value in Yard. @@ -172,7 +172,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Yard. /// A new Distance instance. /// Thrown when the resulting magnitude would be negative. - public static Distance FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YardToMeters)), nameof(value))); + public static Distance FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.YardToMeters), nameof(value))); /// /// Creates a new Distance from a value in Mile. @@ -180,7 +180,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Mile. /// A new Distance instance. /// Thrown when the resulting magnitude would be negative. - public static Distance FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MileToMeters)), nameof(value))); + public static Distance FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MileToMeters), nameof(value))); /// /// Creates a new Distance from a value in NauticalMile. @@ -188,7 +188,7 @@ namespace ktsu.Semantics.Quantities; /// The value in NauticalMile. /// A new Distance instance. /// Thrown when the resulting magnitude would be negative. - public static Distance FromNauticalMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.NauticalMileToMeters)), nameof(value))); + public static Distance FromNauticalMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.NauticalMileToMeters), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Drag.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Drag.g.cs index 0726839..9974b9c 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Drag.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Drag.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilonewton. /// A new Drag instance. /// Thrown when the resulting magnitude would be negative. - public static Drag FromKilonewton(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Drag FromKilonewton(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new Drag from a value in Dyne. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Dyne. /// A new Drag instance. /// Thrown when the resulting magnitude would be negative. - public static Drag FromDyne(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DyneToNewtons)), nameof(value))); + public static Drag FromDyne(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DyneToNewtons), nameof(value))); /// /// Creates a new Drag from a value in PoundForce. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PoundForce. /// A new Drag instance. /// Thrown when the resulting magnitude would be negative. - public static Drag FromPoundForce(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PoundForceToNewtons)), nameof(value))); + public static Drag FromPoundForce(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PoundForceToNewtons), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Duration.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Duration.g.cs index 8179d3d..64ed9ec 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Duration.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Duration.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Millisecond. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Duration FromMillisecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static Duration FromMillisecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new from a value in Microsecond. @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Microsecond. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Duration FromMicrosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); + public static Duration FromMicrosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Micro), nameof(value))); /// /// Creates a new from a value in Minute. @@ -123,7 +123,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Minute. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Duration FromMinute(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MinuteToSeconds)), nameof(value))); + public static Duration FromMinute(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MinuteToSeconds), nameof(value))); /// /// Creates a new from a value in Hour. @@ -131,7 +131,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Hour. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Duration FromHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.HourToSeconds)), nameof(value))); + public static Duration FromHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.HourToSeconds), nameof(value))); /// /// Creates a new from a value in Day. @@ -139,7 +139,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Day. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Duration FromDay(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DayToSeconds)), nameof(value))); + public static Duration FromDay(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DayToSeconds), nameof(value))); /// /// Creates a new from a value in Year. @@ -147,7 +147,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Year. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Duration FromYear(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YearToSeconds)), nameof(value))); + public static Duration FromYear(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.YearToSeconds), nameof(value))); /// /// Creates a new from a value in Week. @@ -155,7 +155,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Week. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Duration FromWeek(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.WeekToSeconds)), nameof(value))); + public static Duration FromWeek(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.WeekToSeconds), nameof(value))); /// /// Creates a new from a value in Nanosecond. @@ -163,7 +163,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Nanosecond. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Duration FromNanosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); + public static Duration FromNanosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Nano), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/DynamicViscosity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/DynamicViscosity.g.cs index 58b43a8..cf2de8b 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/DynamicViscosity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/DynamicViscosity.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Poise. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static DynamicViscosity FromPoise(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PoiseToPascalSecond)), nameof(value))); + public static DynamicViscosity FromPoise(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PoiseToPascalSecond), nameof(value))); /// /// Creates a new from a value in Centipoise. @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Centipoise. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static DynamicViscosity FromCentipoise(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CentipoiseToPascalSecond)), nameof(value))); + public static DynamicViscosity FromCentipoise(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.CentipoiseToPascalSecond), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EMF.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EMF.g.cs index c456f3a..41f9764 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EMF.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EMF.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilovolt. /// A new EMF instance. /// Thrown when the resulting magnitude would be negative. - public static EMF FromKilovolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static EMF FromKilovolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricField2D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricField2D.g.cs index 38b0d09..56853c8 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricField2D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricField2D.g.cs @@ -41,8 +41,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -57,8 +56,7 @@ public T Distance(ElectricField2D other) T dX = X - other.X; T dY = Y - other.Y; T sum = (dX * dX) + (dY * dY); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricField3D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricField3D.g.cs index 1a0058d..c5917fc 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricField3D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ElectricField3D.g.cs @@ -47,8 +47,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -70,8 +69,7 @@ public T Distance(ElectricField3D other) T dY = Y - other.Y; T dZ = Z - other.Z; T sum = (dX * dX) + (dY * dY) + (dZ * dZ); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Energy.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Energy.g.cs index 2765923..a8a5068 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Energy.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Energy.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilojoule. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Energy FromKilojoule(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Energy FromKilojoule(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new from a value in ElectronVolt. @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in ElectronVolt. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Energy FromElectronVolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.ElectronVoltToJoules)), nameof(value))); + public static Energy FromElectronVolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.ElectronVoltToJoules), nameof(value))); /// /// Creates a new from a value in Calorie. @@ -123,7 +123,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Calorie. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Energy FromCalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CalorieToJoules)), nameof(value))); + public static Energy FromCalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.CalorieToJoules), nameof(value))); /// /// Creates a new from a value in Kilocalorie. @@ -131,7 +131,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilocalorie. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Energy FromKilocalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilocalorieToJoules)), nameof(value))); + public static Energy FromKilocalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilocalorieToJoules), nameof(value))); /// /// Creates a new from a value in KilowattHour. @@ -139,7 +139,7 @@ namespace ktsu.Semantics.Quantities; /// The value in KilowattHour. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Energy FromKilowattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilowattHourToJoules)), nameof(value))); + public static Energy FromKilowattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilowattHourToJoules), nameof(value))); /// /// Creates a new from a value in WattHour. @@ -147,7 +147,7 @@ namespace ktsu.Semantics.Quantities; /// The value in WattHour. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Energy FromWattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.WattHourToJoules)), nameof(value))); + public static Energy FromWattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.WattHourToJoules), nameof(value))); /// /// Creates a new from a value in Erg. @@ -155,7 +155,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Erg. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Energy FromErg(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.ErgToJoules)), nameof(value))); + public static Energy FromErg(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.ErgToJoules), nameof(value))); /// /// Creates a new from a value in Btu. @@ -163,7 +163,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Btu. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Energy FromBtu(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.BtuToJoules)), nameof(value))); + public static Energy FromBtu(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.BtuToJoules), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EnzymeActivity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EnzymeActivity.g.cs index 7e07dce..ba136da 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EnzymeActivity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EnzymeActivity.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in EnzymeUnit. /// A new EnzymeActivity instance. /// Thrown when the resulting magnitude would be negative. - public static EnzymeActivity FromEnzymeUnit(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.EnzymeUnitToKatals)), nameof(value))); + public static EnzymeActivity FromEnzymeUnit(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.EnzymeUnitToKatals), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EquivalentDose.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EquivalentDose.g.cs index 9c1ecdd..ccc5217 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EquivalentDose.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/EquivalentDose.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Rem. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static EquivalentDose FromRem(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.RemToSieverts)), nameof(value))); + public static EquivalentDose FromRem(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.RemToSieverts), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Exposure.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Exposure.g.cs index 981e5c8..b8d83bc 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Exposure.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Exposure.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Roentgen. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Exposure FromRoentgen(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.RoentgenToCoulombsPerKilogram)), nameof(value))); + public static Exposure FromRoentgen(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.RoentgenToCoulombsPerKilogram), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/FieldOfView.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/FieldOfView.g.cs index 9b92e59..7185c06 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/FieldOfView.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/FieldOfView.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Degree. /// A new FieldOfView instance. /// Thrown when the resulting magnitude would be negative. - public static FieldOfView FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians)), nameof(value))); + public static FieldOfView FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DegreeToRadians), nameof(value))); /// /// Creates a new FieldOfView from a value in Gradian. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Gradian. /// A new FieldOfView instance. /// Thrown when the resulting magnitude would be negative. - public static FieldOfView FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GradianToRadians)), nameof(value))); + public static FieldOfView FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.GradianToRadians), nameof(value))); /// /// Creates a new FieldOfView from a value in Revolution. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Revolution. /// A new FieldOfView instance. /// Thrown when the resulting magnitude would be negative. - public static FieldOfView FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.RevolutionToRadians)), nameof(value))); + public static FieldOfView FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.RevolutionToRadians), nameof(value))); /// /// Creates a new FieldOfView from a value in Milliradian. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Milliradian. /// A new FieldOfView instance. /// Thrown when the resulting magnitude would be negative. - public static FieldOfView FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static FieldOfView FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/FlowSpeed.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/FlowSpeed.g.cs index ae8ffd7..b0f357c 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/FlowSpeed.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/FlowSpeed.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in KilometerPerHour. /// A new FlowSpeed instance. /// Thrown when the resulting magnitude would be negative. - public static FlowSpeed FromKilometerPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilometerPerHourToMeterPerSecond)), nameof(value))); + public static FlowSpeed FromKilometerPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilometerPerHourToMeterPerSecond), nameof(value))); /// /// Creates a new FlowSpeed from a value in MilePerHour. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in MilePerHour. /// A new FlowSpeed instance. /// Thrown when the resulting magnitude would be negative. - public static FlowSpeed FromMilePerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MilePerHourToMeterPerSecond)), nameof(value))); + public static FlowSpeed FromMilePerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MilePerHourToMeterPerSecond), nameof(value))); /// /// Creates a new FlowSpeed from a value in FootPerSecond. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in FootPerSecond. /// A new FlowSpeed instance. /// Thrown when the resulting magnitude would be negative. - public static FlowSpeed FromFootPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FootPerSecondToMeterPerSecond)), nameof(value))); + public static FlowSpeed FromFootPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.FootPerSecondToMeterPerSecond), nameof(value))); /// /// Creates a new FlowSpeed from a value in Knot. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Knot. /// A new FlowSpeed instance. /// Thrown when the resulting magnitude would be negative. - public static FlowSpeed FromKnot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KnotToMeterPerSecond)), nameof(value))); + public static FlowSpeed FromKnot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KnotToMeterPerSecond), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Force1D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Force1D.g.cs index 98807f3..334a464 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Force1D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Force1D.g.cs @@ -109,21 +109,21 @@ namespace ktsu.Semantics.Quantities; /// /// The value in Kilonewton. /// A new instance. - public static Force1D FromKilonewton(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Kilo))); + public static Force1D FromKilonewton(T value) => Create((value * MetricMagnitudes.Values.Kilo)); /// /// Creates a new from a value in Dyne. /// /// The value in Dyne. /// A new instance. - public static Force1D FromDyne(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.DyneToNewtons))); + public static Force1D FromDyne(T value) => Create((value * Units.ConversionConstants.Values.DyneToNewtons)); /// /// Creates a new from a value in PoundForce. /// /// The value in PoundForce. /// A new instance. - public static Force1D FromPoundForce(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.PoundForceToNewtons))); + public static Force1D FromPoundForce(T value) => Create((value * Units.ConversionConstants.Values.PoundForceToNewtons)); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Force2D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Force2D.g.cs index f1d9d84..be8dd64 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Force2D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Force2D.g.cs @@ -41,8 +41,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -57,8 +56,7 @@ public T Distance(Force2D other) T dX = X - other.X; T dY = Y - other.Y; T sum = (dX * dX) + (dY * dY); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Force3D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Force3D.g.cs index b9fd1d5..c237666 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Force3D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Force3D.g.cs @@ -47,8 +47,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -70,8 +69,7 @@ public T Distance(Force3D other) T dY = Y - other.Y; T dZ = Z - other.Z; T sum = (dX * dX) + (dY * dY) + (dZ * dZ); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Force4D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Force4D.g.cs index 4d3f574..d28325d 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Force4D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Force4D.g.cs @@ -53,8 +53,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z) + (W * W); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -71,8 +70,7 @@ public T Distance(Force4D other) T dZ = Z - other.Z; T dW = W - other.W; T sum = (dX * dX) + (dY * dY) + (dZ * dZ) + (dW * dW); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ForceMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ForceMagnitude.g.cs index 28e7d64..5ba29a5 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ForceMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ForceMagnitude.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilonewton. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static ForceMagnitude FromKilonewton(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static ForceMagnitude FromKilonewton(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new from a value in Dyne. @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Dyne. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static ForceMagnitude FromDyne(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DyneToNewtons)), nameof(value))); + public static ForceMagnitude FromDyne(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DyneToNewtons), nameof(value))); /// /// Creates a new from a value in PoundForce. @@ -123,7 +123,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PoundForce. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static ForceMagnitude FromPoundForce(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PoundForceToNewtons)), nameof(value))); + public static ForceMagnitude FromPoundForce(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PoundForceToNewtons), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Frequency.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Frequency.g.cs index c5007d0..3e1eb9c 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Frequency.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Frequency.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilohertz. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Frequency FromKilohertz(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Frequency FromKilohertz(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new from a value in Megahertz. @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Megahertz. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Frequency FromMegahertz(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Mega)), nameof(value))); + public static Frequency FromMegahertz(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Mega), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Friction.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Friction.g.cs index 48c3a1d..600ea70 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Friction.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Friction.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilonewton. /// A new Friction instance. /// Thrown when the resulting magnitude would be negative. - public static Friction FromKilonewton(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Friction FromKilonewton(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new Friction from a value in Dyne. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Dyne. /// A new Friction instance. /// Thrown when the resulting magnitude would be negative. - public static Friction FromDyne(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DyneToNewtons)), nameof(value))); + public static Friction FromDyne(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DyneToNewtons), nameof(value))); /// /// Creates a new Friction from a value in PoundForce. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PoundForce. /// A new Friction instance. /// Thrown when the resulting magnitude would be negative. - public static Friction FromPoundForce(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PoundForceToNewtons)), nameof(value))); + public static Friction FromPoundForce(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PoundForceToNewtons), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Gain.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Gain.g.cs index 3c01798..82218ac 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Gain.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Gain.g.cs @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Degree. /// A new Gain instance. /// Thrown when the resulting magnitude would be negative. - public static Gain FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians)), nameof(value))); + public static Gain FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DegreeToRadians), nameof(value))); /// /// Creates a new Gain from a value in Gradian. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Gradian. /// A new Gain instance. /// Thrown when the resulting magnitude would be negative. - public static Gain FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GradianToRadians)), nameof(value))); + public static Gain FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.GradianToRadians), nameof(value))); /// /// Creates a new Gain from a value in Revolution. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Revolution. /// A new Gain instance. /// Thrown when the resulting magnitude would be negative. - public static Gain FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.RevolutionToRadians)), nameof(value))); + public static Gain FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.RevolutionToRadians), nameof(value))); /// /// Creates a new Gain from a value in Milliradian. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Milliradian. /// A new Gain instance. /// Thrown when the resulting magnitude would be negative. - public static Gain FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static Gain FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new Gain from a value in Percent. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Percent. /// A new Gain instance. /// Thrown when the resulting magnitude would be negative. - public static Gain FromPercent(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PercentToRatio)), nameof(value))); + public static Gain FromPercent(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PercentToRatio), nameof(value))); /// /// Creates a new Gain from a value in PartPerMillion. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PartPerMillion. /// A new Gain instance. /// Thrown when the resulting magnitude would be negative. - public static Gain FromPartPerMillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PartPerMillionToRatio)), nameof(value))); + public static Gain FromPartPerMillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PartPerMillionToRatio), nameof(value))); /// /// Creates a new Gain from a value in PartPerBillion. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PartPerBillion. /// A new Gain instance. /// Thrown when the resulting magnitude would be negative. - public static Gain FromPartPerBillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PartPerBillionToRatio)), nameof(value))); + public static Gain FromPartPerBillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PartPerBillionToRatio), nameof(value))); /// /// Creates a new Gain from a value in PercentByWeight. @@ -172,7 +172,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PercentByWeight. /// A new Gain instance. /// Thrown when the resulting magnitude would be negative. - public static Gain FromPercentByWeight(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PercentByWeightToRatio)), nameof(value))); + public static Gain FromPercentByWeight(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PercentByWeightToRatio), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GaugePressure.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GaugePressure.g.cs index 216b091..87c6c67 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GaugePressure.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GaugePressure.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilopascal. /// A new GaugePressure instance. /// Thrown when the resulting magnitude would be negative. - public static GaugePressure FromKilopascal(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static GaugePressure FromKilopascal(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new GaugePressure from a value in Bar. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Bar. /// A new GaugePressure instance. /// Thrown when the resulting magnitude would be negative. - public static GaugePressure FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.BarToPascals)), nameof(value))); + public static GaugePressure FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.BarToPascals), nameof(value))); /// /// Creates a new GaugePressure from a value in Atmosphere. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Atmosphere. /// A new GaugePressure instance. /// Thrown when the resulting magnitude would be negative. - public static GaugePressure FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AtmosphereToPascals)), nameof(value))); + public static GaugePressure FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AtmosphereToPascals), nameof(value))); /// /// Creates a new GaugePressure from a value in Psi. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Psi. /// A new GaugePressure instance. /// Thrown when the resulting magnitude would be negative. - public static GaugePressure FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PsiToPascals)), nameof(value))); + public static GaugePressure FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PsiToPascals), nameof(value))); /// /// Creates a new GaugePressure from a value in Torr. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Torr. /// A new GaugePressure instance. /// Thrown when the resulting magnitude would be negative. - public static GaugePressure FromTorr(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.TorrToPascals)), nameof(value))); + public static GaugePressure FromTorr(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.TorrToPascals), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GravitationalAcceleration.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GravitationalAcceleration.g.cs index 1571749..24fc0af 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GravitationalAcceleration.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GravitationalAcceleration.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in StandardGravity. /// A new GravitationalAcceleration instance. /// Thrown when the resulting magnitude would be negative. - public static GravitationalAcceleration FromStandardGravity(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.StandardGravityToMeterPerSecondSquared)), nameof(value))); + public static GravitationalAcceleration FromStandardGravity(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.StandardGravityToMeterPerSecondSquared), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GravitationalField3D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GravitationalField3D.g.cs index 9b06832..c75574a 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GravitationalField3D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GravitationalField3D.g.cs @@ -44,8 +44,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -67,8 +66,7 @@ public T Distance(GravitationalField3D other) T dY = Y - other.Y; T dZ = Z - other.Z; T sum = (dX * dX) + (dY * dY) + (dZ * dZ); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GroundSpeed.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GroundSpeed.g.cs index a1a5f57..ce45a50 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GroundSpeed.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GroundSpeed.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in KilometerPerHour. /// A new GroundSpeed instance. /// Thrown when the resulting magnitude would be negative. - public static GroundSpeed FromKilometerPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilometerPerHourToMeterPerSecond)), nameof(value))); + public static GroundSpeed FromKilometerPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilometerPerHourToMeterPerSecond), nameof(value))); /// /// Creates a new GroundSpeed from a value in MilePerHour. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in MilePerHour. /// A new GroundSpeed instance. /// Thrown when the resulting magnitude would be negative. - public static GroundSpeed FromMilePerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MilePerHourToMeterPerSecond)), nameof(value))); + public static GroundSpeed FromMilePerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MilePerHourToMeterPerSecond), nameof(value))); /// /// Creates a new GroundSpeed from a value in FootPerSecond. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in FootPerSecond. /// A new GroundSpeed instance. /// Thrown when the resulting magnitude would be negative. - public static GroundSpeed FromFootPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FootPerSecondToMeterPerSecond)), nameof(value))); + public static GroundSpeed FromFootPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.FootPerSecondToMeterPerSecond), nameof(value))); /// /// Creates a new GroundSpeed from a value in Knot. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Knot. /// A new GroundSpeed instance. /// Thrown when the resulting magnitude would be negative. - public static GroundSpeed FromKnot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KnotToMeterPerSecond)), nameof(value))); + public static GroundSpeed FromKnot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KnotToMeterPerSecond), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GroupVelocity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GroupVelocity.g.cs index 27e7b39..c457d4b 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GroupVelocity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/GroupVelocity.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in KilometerPerHour. /// A new GroupVelocity instance. /// Thrown when the resulting magnitude would be negative. - public static GroupVelocity FromKilometerPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilometerPerHourToMeterPerSecond)), nameof(value))); + public static GroupVelocity FromKilometerPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilometerPerHourToMeterPerSecond), nameof(value))); /// /// Creates a new GroupVelocity from a value in MilePerHour. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in MilePerHour. /// A new GroupVelocity instance. /// Thrown when the resulting magnitude would be negative. - public static GroupVelocity FromMilePerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MilePerHourToMeterPerSecond)), nameof(value))); + public static GroupVelocity FromMilePerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MilePerHourToMeterPerSecond), nameof(value))); /// /// Creates a new GroupVelocity from a value in FootPerSecond. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in FootPerSecond. /// A new GroupVelocity instance. /// Thrown when the resulting magnitude would be negative. - public static GroupVelocity FromFootPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FootPerSecondToMeterPerSecond)), nameof(value))); + public static GroupVelocity FromFootPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.FootPerSecondToMeterPerSecond), nameof(value))); /// /// Creates a new GroupVelocity from a value in Knot. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Knot. /// A new GroupVelocity instance. /// Thrown when the resulting magnitude would be negative. - public static GroupVelocity FromKnot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KnotToMeterPerSecond)), nameof(value))); + public static GroupVelocity FromKnot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KnotToMeterPerSecond), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HalfLife.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HalfLife.g.cs index 5a9bb37..4562b12 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HalfLife.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HalfLife.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Millisecond. /// A new HalfLife instance. /// Thrown when the resulting magnitude would be negative. - public static HalfLife FromMillisecond(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static HalfLife FromMillisecond(T value) => Create(Vector0Guards.EnsurePositive((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new HalfLife from a value in Microsecond. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Microsecond. /// A new HalfLife instance. /// Thrown when the resulting magnitude would be negative. - public static HalfLife FromMicrosecond(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); + public static HalfLife FromMicrosecond(T value) => Create(Vector0Guards.EnsurePositive((value * MetricMagnitudes.Values.Micro), nameof(value))); /// /// Creates a new HalfLife from a value in Minute. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Minute. /// A new HalfLife instance. /// Thrown when the resulting magnitude would be negative. - public static HalfLife FromMinute(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(Units.ConversionConstants.MinuteToSeconds)), nameof(value))); + public static HalfLife FromMinute(T value) => Create(Vector0Guards.EnsurePositive((value * Units.ConversionConstants.Values.MinuteToSeconds), nameof(value))); /// /// Creates a new HalfLife from a value in Hour. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Hour. /// A new HalfLife instance. /// Thrown when the resulting magnitude would be negative. - public static HalfLife FromHour(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(Units.ConversionConstants.HourToSeconds)), nameof(value))); + public static HalfLife FromHour(T value) => Create(Vector0Guards.EnsurePositive((value * Units.ConversionConstants.Values.HourToSeconds), nameof(value))); /// /// Creates a new HalfLife from a value in Day. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Day. /// A new HalfLife instance. /// Thrown when the resulting magnitude would be negative. - public static HalfLife FromDay(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(Units.ConversionConstants.DayToSeconds)), nameof(value))); + public static HalfLife FromDay(T value) => Create(Vector0Guards.EnsurePositive((value * Units.ConversionConstants.Values.DayToSeconds), nameof(value))); /// /// Creates a new HalfLife from a value in Year. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Year. /// A new HalfLife instance. /// Thrown when the resulting magnitude would be negative. - public static HalfLife FromYear(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(Units.ConversionConstants.YearToSeconds)), nameof(value))); + public static HalfLife FromYear(T value) => Create(Vector0Guards.EnsurePositive((value * Units.ConversionConstants.Values.YearToSeconds), nameof(value))); /// /// Creates a new HalfLife from a value in Week. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Week. /// A new HalfLife instance. /// Thrown when the resulting magnitude would be negative. - public static HalfLife FromWeek(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(Units.ConversionConstants.WeekToSeconds)), nameof(value))); + public static HalfLife FromWeek(T value) => Create(Vector0Guards.EnsurePositive((value * Units.ConversionConstants.Values.WeekToSeconds), nameof(value))); /// /// Creates a new HalfLife from a value in Nanosecond. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Nanosecond. /// A new HalfLife instance. /// Thrown when the resulting magnitude would be negative. - public static HalfLife FromNanosecond(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); + public static HalfLife FromNanosecond(T value) => Create(Vector0Guards.EnsurePositive((value * MetricMagnitudes.Values.Nano), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Heading.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Heading.g.cs index 1cde47f..2b71481 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Heading.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Heading.g.cs @@ -110,28 +110,28 @@ namespace ktsu.Semantics.Quantities; /// /// The value in Degree. /// A new Heading instance. - public static Heading FromDegree(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians))); + public static Heading FromDegree(T value) => Create((value * Units.ConversionConstants.Values.DegreeToRadians)); /// /// Creates a new Heading from a value in Gradian. /// /// The value in Gradian. /// A new Heading instance. - public static Heading FromGradian(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.GradianToRadians))); + public static Heading FromGradian(T value) => Create((value * Units.ConversionConstants.Values.GradianToRadians)); /// /// Creates a new Heading from a value in Revolution. /// /// The value in Revolution. /// A new Heading instance. - public static Heading FromRevolution(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.RevolutionToRadians))); + public static Heading FromRevolution(T value) => Create((value * Units.ConversionConstants.Values.RevolutionToRadians)); /// /// Creates a new Heading from a value in Milliradian. /// /// The value in Milliradian. /// A new Heading instance. - public static Heading FromMilliradian(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Milli))); + public static Heading FromMilliradian(T value) => Create((value * MetricMagnitudes.Values.Milli)); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Heat.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Heat.g.cs index 4db7494..b37f1e2 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Heat.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Heat.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilojoule. /// A new Heat instance. /// Thrown when the resulting magnitude would be negative. - public static Heat FromKilojoule(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Heat FromKilojoule(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new Heat from a value in ElectronVolt. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in ElectronVolt. /// A new Heat instance. /// Thrown when the resulting magnitude would be negative. - public static Heat FromElectronVolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.ElectronVoltToJoules)), nameof(value))); + public static Heat FromElectronVolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.ElectronVoltToJoules), nameof(value))); /// /// Creates a new Heat from a value in Calorie. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Calorie. /// A new Heat instance. /// Thrown when the resulting magnitude would be negative. - public static Heat FromCalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CalorieToJoules)), nameof(value))); + public static Heat FromCalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.CalorieToJoules), nameof(value))); /// /// Creates a new Heat from a value in Kilocalorie. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilocalorie. /// A new Heat instance. /// Thrown when the resulting magnitude would be negative. - public static Heat FromKilocalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilocalorieToJoules)), nameof(value))); + public static Heat FromKilocalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilocalorieToJoules), nameof(value))); /// /// Creates a new Heat from a value in KilowattHour. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in KilowattHour. /// A new Heat instance. /// Thrown when the resulting magnitude would be negative. - public static Heat FromKilowattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilowattHourToJoules)), nameof(value))); + public static Heat FromKilowattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilowattHourToJoules), nameof(value))); /// /// Creates a new Heat from a value in WattHour. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in WattHour. /// A new Heat instance. /// Thrown when the resulting magnitude would be negative. - public static Heat FromWattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.WattHourToJoules)), nameof(value))); + public static Heat FromWattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.WattHourToJoules), nameof(value))); /// /// Creates a new Heat from a value in Erg. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Erg. /// A new Heat instance. /// Thrown when the resulting magnitude would be negative. - public static Heat FromErg(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.ErgToJoules)), nameof(value))); + public static Heat FromErg(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.ErgToJoules), nameof(value))); /// /// Creates a new Heat from a value in Btu. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Btu. /// A new Heat instance. /// Thrown when the resulting magnitude would be negative. - public static Heat FromBtu(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.BtuToJoules)), nameof(value))); + public static Heat FromBtu(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.BtuToJoules), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HeatFlowRate.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HeatFlowRate.g.cs index 6723adf..3d2b57f 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HeatFlowRate.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/HeatFlowRate.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilowatt. /// A new HeatFlowRate instance. /// Thrown when the resulting magnitude would be negative. - public static HeatFlowRate FromKilowatt(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static HeatFlowRate FromKilowatt(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new HeatFlowRate from a value in Megawatt. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Megawatt. /// A new HeatFlowRate instance. /// Thrown when the resulting magnitude would be negative. - public static HeatFlowRate FromMegawatt(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Mega)), nameof(value))); + public static HeatFlowRate FromMegawatt(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Mega), nameof(value))); /// /// Creates a new HeatFlowRate from a value in Horsepower. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Horsepower. /// A new HeatFlowRate instance. /// Thrown when the resulting magnitude would be negative. - public static HeatFlowRate FromHorsepower(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.HorsepowerToWatts)), nameof(value))); + public static HeatFlowRate FromHorsepower(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.HorsepowerToWatts), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Height.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Height.g.cs index b64cd8f..2481055 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Height.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Height.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilometer. /// A new Height instance. /// Thrown when the resulting magnitude would be negative. - public static Height FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Height FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new Height from a value in Centimeter. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Centimeter. /// A new Height instance. /// Thrown when the resulting magnitude would be negative. - public static Height FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Centi)), nameof(value))); + public static Height FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Centi), nameof(value))); /// /// Creates a new Height from a value in Millimeter. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Millimeter. /// A new Height instance. /// Thrown when the resulting magnitude would be negative. - public static Height FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static Height FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new Height from a value in Micrometer. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Micrometer. /// A new Height instance. /// Thrown when the resulting magnitude would be negative. - public static Height FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); + public static Height FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Micro), nameof(value))); /// /// Creates a new Height from a value in Nanometer. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Nanometer. /// A new Height instance. /// Thrown when the resulting magnitude would be negative. - public static Height FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); + public static Height FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Nano), nameof(value))); /// /// Creates a new Height from a value in Angstrom. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Angstrom. /// A new Height instance. /// Thrown when the resulting magnitude would be negative. - public static Height FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters)), nameof(value))); + public static Height FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AngstromToMeters), nameof(value))); /// /// Creates a new Height from a value in Foot. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Foot. /// A new Height instance. /// Thrown when the resulting magnitude would be negative. - public static Height FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters)), nameof(value))); + public static Height FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.FeetToMeters), nameof(value))); /// /// Creates a new Height from a value in Inch. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Inch. /// A new Height instance. /// Thrown when the resulting magnitude would be negative. - public static Height FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters)), nameof(value))); + public static Height FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.InchesToMeters), nameof(value))); /// /// Creates a new Height from a value in Yard. @@ -172,7 +172,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Yard. /// A new Height instance. /// Thrown when the resulting magnitude would be negative. - public static Height FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YardToMeters)), nameof(value))); + public static Height FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.YardToMeters), nameof(value))); /// /// Creates a new Height from a value in Mile. @@ -180,7 +180,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Mile. /// A new Height instance. /// Thrown when the resulting magnitude would be negative. - public static Height FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MileToMeters)), nameof(value))); + public static Height FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MileToMeters), nameof(value))); /// /// Creates a new Height from a value in NauticalMile. @@ -188,7 +188,7 @@ namespace ktsu.Semantics.Quantities; /// The value in NauticalMile. /// A new Height instance. /// Thrown when the resulting magnitude would be negative. - public static Height FromNauticalMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.NauticalMileToMeters)), nameof(value))); + public static Height FromNauticalMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.NauticalMileToMeters), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Illuminance.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Illuminance.g.cs index bdaaae9..dc25f3e 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Illuminance.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Illuminance.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in FootCandle. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Illuminance FromFootCandle(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FootCandleToLux)), nameof(value))); + public static Illuminance FromFootCandle(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.FootCandleToLux), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Impedance.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Impedance.g.cs index 77505c7..be29ecd 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Impedance.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Impedance.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilohm. /// A new Impedance instance. /// Thrown when the resulting magnitude would be negative. - public static Impedance FromKilohm(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Impedance FromKilohm(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new Impedance from a value in Megohm. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Megohm. /// A new Impedance instance. /// Thrown when the resulting magnitude would be negative. - public static Impedance FromMegohm(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Mega)), nameof(value))); + public static Impedance FromMegohm(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Mega), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Jerk2D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Jerk2D.g.cs index c3deb62..af1c480 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Jerk2D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Jerk2D.g.cs @@ -41,8 +41,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -57,8 +56,7 @@ public T Distance(Jerk2D other) T dX = X - other.X; T dY = Y - other.Y; T sum = (dX * dX) + (dY * dY); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Jerk3D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Jerk3D.g.cs index e5da5a2..05e6672 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Jerk3D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Jerk3D.g.cs @@ -47,8 +47,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -70,8 +69,7 @@ public T Distance(Jerk3D other) T dY = Y - other.Y; T dZ = Z - other.Z; T sum = (dX * dX) + (dY * dY) + (dZ * dZ); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Jerk4D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Jerk4D.g.cs index 4eb43e0..0c8ebc6 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Jerk4D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Jerk4D.g.cs @@ -53,8 +53,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z) + (W * W); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -71,8 +70,7 @@ public T Distance(Jerk4D other) T dZ = Z - other.Z; T dW = W - other.W; T sum = (dX * dX) + (dY * dY) + (dZ * dZ) + (dW * dW); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/KinematicViscosity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/KinematicViscosity.g.cs index 199479d..9c99f45 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/KinematicViscosity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/KinematicViscosity.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Stokes. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static KinematicViscosity FromStokes(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.StokesToSquareMeterPerSecond)), nameof(value))); + public static KinematicViscosity FromStokes(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.StokesToSquareMeterPerSecond), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/KineticEnergy.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/KineticEnergy.g.cs index 4127e73..9ba3b07 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/KineticEnergy.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/KineticEnergy.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilojoule. /// A new KineticEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static KineticEnergy FromKilojoule(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static KineticEnergy FromKilojoule(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new KineticEnergy from a value in ElectronVolt. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in ElectronVolt. /// A new KineticEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static KineticEnergy FromElectronVolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.ElectronVoltToJoules)), nameof(value))); + public static KineticEnergy FromElectronVolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.ElectronVoltToJoules), nameof(value))); /// /// Creates a new KineticEnergy from a value in Calorie. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Calorie. /// A new KineticEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static KineticEnergy FromCalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CalorieToJoules)), nameof(value))); + public static KineticEnergy FromCalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.CalorieToJoules), nameof(value))); /// /// Creates a new KineticEnergy from a value in Kilocalorie. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilocalorie. /// A new KineticEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static KineticEnergy FromKilocalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilocalorieToJoules)), nameof(value))); + public static KineticEnergy FromKilocalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilocalorieToJoules), nameof(value))); /// /// Creates a new KineticEnergy from a value in KilowattHour. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in KilowattHour. /// A new KineticEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static KineticEnergy FromKilowattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilowattHourToJoules)), nameof(value))); + public static KineticEnergy FromKilowattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilowattHourToJoules), nameof(value))); /// /// Creates a new KineticEnergy from a value in WattHour. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in WattHour. /// A new KineticEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static KineticEnergy FromWattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.WattHourToJoules)), nameof(value))); + public static KineticEnergy FromWattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.WattHourToJoules), nameof(value))); /// /// Creates a new KineticEnergy from a value in Erg. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Erg. /// A new KineticEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static KineticEnergy FromErg(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.ErgToJoules)), nameof(value))); + public static KineticEnergy FromErg(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.ErgToJoules), nameof(value))); /// /// Creates a new KineticEnergy from a value in Btu. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Btu. /// A new KineticEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static KineticEnergy FromBtu(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.BtuToJoules)), nameof(value))); + public static KineticEnergy FromBtu(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.BtuToJoules), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Latency.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Latency.g.cs index 0db0bed..567d9b3 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Latency.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Latency.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Millisecond. /// A new Latency instance. /// Thrown when the resulting magnitude would be negative. - public static Latency FromMillisecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static Latency FromMillisecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new Latency from a value in Microsecond. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Microsecond. /// A new Latency instance. /// Thrown when the resulting magnitude would be negative. - public static Latency FromMicrosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); + public static Latency FromMicrosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Micro), nameof(value))); /// /// Creates a new Latency from a value in Minute. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Minute. /// A new Latency instance. /// Thrown when the resulting magnitude would be negative. - public static Latency FromMinute(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MinuteToSeconds)), nameof(value))); + public static Latency FromMinute(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MinuteToSeconds), nameof(value))); /// /// Creates a new Latency from a value in Hour. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Hour. /// A new Latency instance. /// Thrown when the resulting magnitude would be negative. - public static Latency FromHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.HourToSeconds)), nameof(value))); + public static Latency FromHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.HourToSeconds), nameof(value))); /// /// Creates a new Latency from a value in Day. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Day. /// A new Latency instance. /// Thrown when the resulting magnitude would be negative. - public static Latency FromDay(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DayToSeconds)), nameof(value))); + public static Latency FromDay(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DayToSeconds), nameof(value))); /// /// Creates a new Latency from a value in Year. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Year. /// A new Latency instance. /// Thrown when the resulting magnitude would be negative. - public static Latency FromYear(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YearToSeconds)), nameof(value))); + public static Latency FromYear(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.YearToSeconds), nameof(value))); /// /// Creates a new Latency from a value in Week. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Week. /// A new Latency instance. /// Thrown when the resulting magnitude would be negative. - public static Latency FromWeek(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.WeekToSeconds)), nameof(value))); + public static Latency FromWeek(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.WeekToSeconds), nameof(value))); /// /// Creates a new Latency from a value in Nanosecond. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Nanosecond. /// A new Latency instance. /// Thrown when the resulting magnitude would be negative. - public static Latency FromNanosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); + public static Latency FromNanosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Nano), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Length.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Length.g.cs index 8f01cb6..8bf3813 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Length.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Length.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilometer. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Length FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Length FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new from a value in Centimeter. @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Centimeter. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Length FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Centi)), nameof(value))); + public static Length FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Centi), nameof(value))); /// /// Creates a new from a value in Millimeter. @@ -123,7 +123,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Millimeter. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Length FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static Length FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new from a value in Micrometer. @@ -131,7 +131,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Micrometer. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Length FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); + public static Length FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Micro), nameof(value))); /// /// Creates a new from a value in Nanometer. @@ -139,7 +139,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Nanometer. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Length FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); + public static Length FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Nano), nameof(value))); /// /// Creates a new from a value in Angstrom. @@ -147,7 +147,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Angstrom. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Length FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters)), nameof(value))); + public static Length FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AngstromToMeters), nameof(value))); /// /// Creates a new from a value in Foot. @@ -155,7 +155,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Foot. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Length FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters)), nameof(value))); + public static Length FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.FeetToMeters), nameof(value))); /// /// Creates a new from a value in Inch. @@ -163,7 +163,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Inch. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Length FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters)), nameof(value))); + public static Length FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.InchesToMeters), nameof(value))); /// /// Creates a new from a value in Yard. @@ -171,7 +171,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Yard. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Length FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YardToMeters)), nameof(value))); + public static Length FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.YardToMeters), nameof(value))); /// /// Creates a new from a value in Mile. @@ -179,7 +179,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Mile. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Length FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MileToMeters)), nameof(value))); + public static Length FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MileToMeters), nameof(value))); /// /// Creates a new from a value in NauticalMile. @@ -187,7 +187,7 @@ namespace ktsu.Semantics.Quantities; /// The value in NauticalMile. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Length FromNauticalMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.NauticalMileToMeters)), nameof(value))); + public static Length FromNauticalMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.NauticalMileToMeters), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Lift.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Lift.g.cs index ec1d7cf..b555559 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Lift.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Lift.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilonewton. /// A new Lift instance. /// Thrown when the resulting magnitude would be negative. - public static Lift FromKilonewton(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Lift FromKilonewton(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new Lift from a value in Dyne. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Dyne. /// A new Lift instance. /// Thrown when the resulting magnitude would be negative. - public static Lift FromDyne(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DyneToNewtons)), nameof(value))); + public static Lift FromDyne(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DyneToNewtons), nameof(value))); /// /// Creates a new Lift from a value in PoundForce. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PoundForce. /// A new Lift instance. /// Thrown when the resulting magnitude would be negative. - public static Lift FromPoundForce(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PoundForceToNewtons)), nameof(value))); + public static Lift FromPoundForce(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PoundForceToNewtons), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Luminance.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Luminance.g.cs index f66a712..1eb153e 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Luminance.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Luminance.g.cs @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in FootLambert. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Luminance FromFootLambert(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FootLambertToCandelaPerSquareMeter)), nameof(value))); + public static Luminance FromFootLambert(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.FootLambertToCandelaPerSquareMeter), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/LuminousIntensity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/LuminousIntensity.g.cs index 7049ca6..54a0022 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/LuminousIntensity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/LuminousIntensity.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Millicandela. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static LuminousIntensity FromMillicandela(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static LuminousIntensity FromMillicandela(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MachNumber.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MachNumber.g.cs index 6f6a7da..82cb3d8 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MachNumber.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MachNumber.g.cs @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Degree. /// A new MachNumber instance. /// Thrown when the resulting magnitude would be negative. - public static MachNumber FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians)), nameof(value))); + public static MachNumber FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DegreeToRadians), nameof(value))); /// /// Creates a new MachNumber from a value in Gradian. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Gradian. /// A new MachNumber instance. /// Thrown when the resulting magnitude would be negative. - public static MachNumber FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GradianToRadians)), nameof(value))); + public static MachNumber FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.GradianToRadians), nameof(value))); /// /// Creates a new MachNumber from a value in Revolution. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Revolution. /// A new MachNumber instance. /// Thrown when the resulting magnitude would be negative. - public static MachNumber FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.RevolutionToRadians)), nameof(value))); + public static MachNumber FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.RevolutionToRadians), nameof(value))); /// /// Creates a new MachNumber from a value in Milliradian. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Milliradian. /// A new MachNumber instance. /// Thrown when the resulting magnitude would be negative. - public static MachNumber FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static MachNumber FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new MachNumber from a value in Percent. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Percent. /// A new MachNumber instance. /// Thrown when the resulting magnitude would be negative. - public static MachNumber FromPercent(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PercentToRatio)), nameof(value))); + public static MachNumber FromPercent(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PercentToRatio), nameof(value))); /// /// Creates a new MachNumber from a value in PartPerMillion. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PartPerMillion. /// A new MachNumber instance. /// Thrown when the resulting magnitude would be negative. - public static MachNumber FromPartPerMillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PartPerMillionToRatio)), nameof(value))); + public static MachNumber FromPartPerMillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PartPerMillionToRatio), nameof(value))); /// /// Creates a new MachNumber from a value in PartPerBillion. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PartPerBillion. /// A new MachNumber instance. /// Thrown when the resulting magnitude would be negative. - public static MachNumber FromPartPerBillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PartPerBillionToRatio)), nameof(value))); + public static MachNumber FromPartPerBillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PartPerBillionToRatio), nameof(value))); /// /// Creates a new MachNumber from a value in PercentByWeight. @@ -172,7 +172,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PercentByWeight. /// A new MachNumber instance. /// Thrown when the resulting magnitude would be negative. - public static MachNumber FromPercentByWeight(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PercentByWeightToRatio)), nameof(value))); + public static MachNumber FromPercentByWeight(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PercentByWeightToRatio), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MagneticFluxDensity3D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MagneticFluxDensity3D.g.cs index f5d7bb0..21dd5ee 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MagneticFluxDensity3D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MagneticFluxDensity3D.g.cs @@ -47,8 +47,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -70,8 +69,7 @@ public T Distance(MagneticFluxDensity3D other) T dY = Y - other.Y; T dZ = Z - other.Z; T sum = (dX * dX) + (dY * dY) + (dZ * dZ); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MagneticFluxDensityMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MagneticFluxDensityMagnitude.g.cs index 24b7878..36a85ef 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MagneticFluxDensityMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MagneticFluxDensityMagnitude.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Gauss. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static MagneticFluxDensityMagnitude FromGauss(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GaussToTesla)), nameof(value))); + public static MagneticFluxDensityMagnitude FromGauss(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.GaussToTesla), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Mass.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Mass.g.cs index eda6e44..bf48132 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Mass.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Mass.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Gram. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Mass FromGram(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static Mass FromGram(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new from a value in Ton. @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Ton. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Mass FromTon(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.TonToKilograms)), nameof(value))); + public static Mass FromTon(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.TonToKilograms), nameof(value))); /// /// Creates a new from a value in Pound. @@ -123,7 +123,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Pound. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Mass FromPound(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PoundToKilograms)), nameof(value))); + public static Mass FromPound(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PoundToKilograms), nameof(value))); /// /// Creates a new from a value in Ounce. @@ -131,7 +131,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Ounce. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Mass FromOunce(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.OunceToKilograms)), nameof(value))); + public static Mass FromOunce(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.OunceToKilograms), nameof(value))); /// /// Creates a new from a value in Stone. @@ -139,7 +139,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Stone. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Mass FromStone(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.StoneToKilograms)), nameof(value))); + public static Mass FromStone(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.StoneToKilograms), nameof(value))); /// /// Creates a new from a value in ShortTon. @@ -147,7 +147,7 @@ namespace ktsu.Semantics.Quantities; /// The value in ShortTon. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Mass FromShortTon(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.ShortTonToKilograms)), nameof(value))); + public static Mass FromShortTon(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.ShortTonToKilograms), nameof(value))); /// /// Creates a new from a value in AtomicMassUnit. @@ -155,7 +155,7 @@ namespace ktsu.Semantics.Quantities; /// The value in AtomicMassUnit. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Mass FromAtomicMassUnit(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AtomicMassUnitToKilograms)), nameof(value))); + public static Mass FromAtomicMassUnit(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AtomicMassUnitToKilograms), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarEnergy.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarEnergy.g.cs index c65f398..04cc658 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarEnergy.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarEnergy.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in KilojoulePerMole. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static MolarEnergy FromKilojoulePerMole(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilojoulePerMoleToJoulePerMole)), nameof(value))); + public static MolarEnergy FromKilojoulePerMole(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilojoulePerMoleToJoulePerMole), nameof(value))); /// /// Creates a new from a value in CaloriePerMole. @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in CaloriePerMole. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static MolarEnergy FromCaloriePerMole(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CaloriePerMoleToJoulePerMole)), nameof(value))); + public static MolarEnergy FromCaloriePerMole(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.CaloriePerMoleToJoulePerMole), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarEnthalpy.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarEnthalpy.g.cs index abf47f0..164eb57 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarEnthalpy.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarEnthalpy.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in KilojoulePerMole. /// A new MolarEnthalpy instance. /// Thrown when the resulting magnitude would be negative. - public static MolarEnthalpy FromKilojoulePerMole(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilojoulePerMoleToJoulePerMole)), nameof(value))); + public static MolarEnthalpy FromKilojoulePerMole(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilojoulePerMoleToJoulePerMole), nameof(value))); /// /// Creates a new MolarEnthalpy from a value in CaloriePerMole. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in CaloriePerMole. /// A new MolarEnthalpy instance. /// Thrown when the resulting magnitude would be negative. - public static MolarEnthalpy FromCaloriePerMole(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CaloriePerMoleToJoulePerMole)), nameof(value))); + public static MolarEnthalpy FromCaloriePerMole(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.CaloriePerMoleToJoulePerMole), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarMass.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarMass.g.cs index eb0b684..bcc3c83 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarMass.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/MolarMass.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in GramPerMole. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static MolarMass FromGramPerMole(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GramPerMoleToKilogramPerMole)), nameof(value))); + public static MolarMass FromGramPerMole(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.GramPerMoleToKilogramPerMole), nameof(value))); /// /// Creates a new from a value in Dalton. @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Dalton. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static MolarMass FromDalton(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GramPerMoleToKilogramPerMole)), nameof(value))); + public static MolarMass FromDalton(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.GramPerMoleToKilogramPerMole), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Momentum2D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Momentum2D.g.cs index 1e54744..f213d65 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Momentum2D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Momentum2D.g.cs @@ -41,8 +41,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -57,8 +56,7 @@ public T Distance(Momentum2D other) T dX = X - other.X; T dY = Y - other.Y; T sum = (dX * dX) + (dY * dY); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Momentum3D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Momentum3D.g.cs index 50014ce..61bdd25 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Momentum3D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Momentum3D.g.cs @@ -47,8 +47,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -70,8 +69,7 @@ public T Distance(Momentum3D other) T dY = Y - other.Y; T dZ = Z - other.Z; T sum = (dX * dX) + (dY * dY) + (dZ * dZ); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Momentum4D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Momentum4D.g.cs index 7eb818f..ef4cbe8 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Momentum4D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Momentum4D.g.cs @@ -53,8 +53,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z) + (W * W); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -71,8 +70,7 @@ public T Distance(Momentum4D other) T dZ = Z - other.Z; T dW = W - other.W; T sum = (dX * dX) + (dY * dY) + (dZ * dZ) + (dW * dW); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NoiseReductionCoefficient.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NoiseReductionCoefficient.g.cs index c8aef8c..1ac146f 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NoiseReductionCoefficient.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NoiseReductionCoefficient.g.cs @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Degree. /// A new NoiseReductionCoefficient instance. /// Thrown when the resulting magnitude would be negative. - public static NoiseReductionCoefficient FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians)), nameof(value))); + public static NoiseReductionCoefficient FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DegreeToRadians), nameof(value))); /// /// Creates a new NoiseReductionCoefficient from a value in Gradian. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Gradian. /// A new NoiseReductionCoefficient instance. /// Thrown when the resulting magnitude would be negative. - public static NoiseReductionCoefficient FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GradianToRadians)), nameof(value))); + public static NoiseReductionCoefficient FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.GradianToRadians), nameof(value))); /// /// Creates a new NoiseReductionCoefficient from a value in Revolution. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Revolution. /// A new NoiseReductionCoefficient instance. /// Thrown when the resulting magnitude would be negative. - public static NoiseReductionCoefficient FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.RevolutionToRadians)), nameof(value))); + public static NoiseReductionCoefficient FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.RevolutionToRadians), nameof(value))); /// /// Creates a new NoiseReductionCoefficient from a value in Milliradian. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Milliradian. /// A new NoiseReductionCoefficient instance. /// Thrown when the resulting magnitude would be negative. - public static NoiseReductionCoefficient FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static NoiseReductionCoefficient FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new NoiseReductionCoefficient from a value in Percent. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Percent. /// A new NoiseReductionCoefficient instance. /// Thrown when the resulting magnitude would be negative. - public static NoiseReductionCoefficient FromPercent(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PercentToRatio)), nameof(value))); + public static NoiseReductionCoefficient FromPercent(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PercentToRatio), nameof(value))); /// /// Creates a new NoiseReductionCoefficient from a value in PartPerMillion. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PartPerMillion. /// A new NoiseReductionCoefficient instance. /// Thrown when the resulting magnitude would be negative. - public static NoiseReductionCoefficient FromPartPerMillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PartPerMillionToRatio)), nameof(value))); + public static NoiseReductionCoefficient FromPartPerMillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PartPerMillionToRatio), nameof(value))); /// /// Creates a new NoiseReductionCoefficient from a value in PartPerBillion. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PartPerBillion. /// A new NoiseReductionCoefficient instance. /// Thrown when the resulting magnitude would be negative. - public static NoiseReductionCoefficient FromPartPerBillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PartPerBillionToRatio)), nameof(value))); + public static NoiseReductionCoefficient FromPartPerBillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PartPerBillionToRatio), nameof(value))); /// /// Creates a new NoiseReductionCoefficient from a value in PercentByWeight. @@ -172,7 +172,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PercentByWeight. /// A new NoiseReductionCoefficient instance. /// Thrown when the resulting magnitude would be negative. - public static NoiseReductionCoefficient FromPercentByWeight(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PercentByWeightToRatio)), nameof(value))); + public static NoiseReductionCoefficient FromPercentByWeight(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PercentByWeightToRatio), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NormalForce.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NormalForce.g.cs index 6a76fbd..5ddc7c2 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NormalForce.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NormalForce.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilonewton. /// A new NormalForce instance. /// Thrown when the resulting magnitude would be negative. - public static NormalForce FromKilonewton(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static NormalForce FromKilonewton(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new NormalForce from a value in Dyne. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Dyne. /// A new NormalForce instance. /// Thrown when the resulting magnitude would be negative. - public static NormalForce FromDyne(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DyneToNewtons)), nameof(value))); + public static NormalForce FromDyne(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DyneToNewtons), nameof(value))); /// /// Creates a new NormalForce from a value in PoundForce. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PoundForce. /// A new NormalForce instance. /// Thrown when the resulting magnitude would be negative. - public static NormalForce FromPoundForce(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PoundForceToNewtons)), nameof(value))); + public static NormalForce FromPoundForce(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PoundForceToNewtons), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NuclearCrossSection.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NuclearCrossSection.g.cs index a884fb4..6438f27 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NuclearCrossSection.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/NuclearCrossSection.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Barn. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static NuclearCrossSection FromBarn(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.BarnToSquareMeters)), nameof(value))); + public static NuclearCrossSection FromBarn(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.BarnToSquareMeters), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Offset.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Offset.g.cs index 56d3a08..fc00a0b 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Offset.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Offset.g.cs @@ -110,77 +110,77 @@ namespace ktsu.Semantics.Quantities; /// /// The value in Kilometer. /// A new Offset instance. - public static Offset FromKilometer(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Kilo))); + public static Offset FromKilometer(T value) => Create((value * MetricMagnitudes.Values.Kilo)); /// /// Creates a new Offset from a value in Centimeter. /// /// The value in Centimeter. /// A new Offset instance. - public static Offset FromCentimeter(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Centi))); + public static Offset FromCentimeter(T value) => Create((value * MetricMagnitudes.Values.Centi)); /// /// Creates a new Offset from a value in Millimeter. /// /// The value in Millimeter. /// A new Offset instance. - public static Offset FromMillimeter(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Milli))); + public static Offset FromMillimeter(T value) => Create((value * MetricMagnitudes.Values.Milli)); /// /// Creates a new Offset from a value in Micrometer. /// /// The value in Micrometer. /// A new Offset instance. - public static Offset FromMicrometer(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Micro))); + public static Offset FromMicrometer(T value) => Create((value * MetricMagnitudes.Values.Micro)); /// /// Creates a new Offset from a value in Nanometer. /// /// The value in Nanometer. /// A new Offset instance. - public static Offset FromNanometer(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Nano))); + public static Offset FromNanometer(T value) => Create((value * MetricMagnitudes.Values.Nano)); /// /// Creates a new Offset from a value in Angstrom. /// /// The value in Angstrom. /// A new Offset instance. - public static Offset FromAngstrom(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters))); + public static Offset FromAngstrom(T value) => Create((value * Units.ConversionConstants.Values.AngstromToMeters)); /// /// Creates a new Offset from a value in Foot. /// /// The value in Foot. /// A new Offset instance. - public static Offset FromFoot(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters))); + public static Offset FromFoot(T value) => Create((value * Units.ConversionConstants.Values.FeetToMeters)); /// /// Creates a new Offset from a value in Inch. /// /// The value in Inch. /// A new Offset instance. - public static Offset FromInch(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters))); + public static Offset FromInch(T value) => Create((value * Units.ConversionConstants.Values.InchesToMeters)); /// /// Creates a new Offset from a value in Yard. /// /// The value in Yard. /// A new Offset instance. - public static Offset FromYard(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.YardToMeters))); + public static Offset FromYard(T value) => Create((value * Units.ConversionConstants.Values.YardToMeters)); /// /// Creates a new Offset from a value in Mile. /// /// The value in Mile. /// A new Offset instance. - public static Offset FromMile(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.MileToMeters))); + public static Offset FromMile(T value) => Create((value * Units.ConversionConstants.Values.MileToMeters)); /// /// Creates a new Offset from a value in NauticalMile. /// /// The value in NauticalMile. /// A new Offset instance. - public static Offset FromNauticalMile(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.NauticalMileToMeters))); + public static Offset FromNauticalMile(T value) => Create((value * Units.ConversionConstants.Values.NauticalMileToMeters)); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Perimeter.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Perimeter.g.cs index 27a1fe6..b5c6a33 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Perimeter.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Perimeter.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilometer. /// A new Perimeter instance. /// Thrown when the resulting magnitude would be negative. - public static Perimeter FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Perimeter FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new Perimeter from a value in Centimeter. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Centimeter. /// A new Perimeter instance. /// Thrown when the resulting magnitude would be negative. - public static Perimeter FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Centi)), nameof(value))); + public static Perimeter FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Centi), nameof(value))); /// /// Creates a new Perimeter from a value in Millimeter. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Millimeter. /// A new Perimeter instance. /// Thrown when the resulting magnitude would be negative. - public static Perimeter FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static Perimeter FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new Perimeter from a value in Micrometer. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Micrometer. /// A new Perimeter instance. /// Thrown when the resulting magnitude would be negative. - public static Perimeter FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); + public static Perimeter FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Micro), nameof(value))); /// /// Creates a new Perimeter from a value in Nanometer. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Nanometer. /// A new Perimeter instance. /// Thrown when the resulting magnitude would be negative. - public static Perimeter FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); + public static Perimeter FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Nano), nameof(value))); /// /// Creates a new Perimeter from a value in Angstrom. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Angstrom. /// A new Perimeter instance. /// Thrown when the resulting magnitude would be negative. - public static Perimeter FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters)), nameof(value))); + public static Perimeter FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AngstromToMeters), nameof(value))); /// /// Creates a new Perimeter from a value in Foot. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Foot. /// A new Perimeter instance. /// Thrown when the resulting magnitude would be negative. - public static Perimeter FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters)), nameof(value))); + public static Perimeter FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.FeetToMeters), nameof(value))); /// /// Creates a new Perimeter from a value in Inch. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Inch. /// A new Perimeter instance. /// Thrown when the resulting magnitude would be negative. - public static Perimeter FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters)), nameof(value))); + public static Perimeter FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.InchesToMeters), nameof(value))); /// /// Creates a new Perimeter from a value in Yard. @@ -172,7 +172,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Yard. /// A new Perimeter instance. /// Thrown when the resulting magnitude would be negative. - public static Perimeter FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YardToMeters)), nameof(value))); + public static Perimeter FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.YardToMeters), nameof(value))); /// /// Creates a new Perimeter from a value in Mile. @@ -180,7 +180,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Mile. /// A new Perimeter instance. /// Thrown when the resulting magnitude would be negative. - public static Perimeter FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MileToMeters)), nameof(value))); + public static Perimeter FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MileToMeters), nameof(value))); /// /// Creates a new Perimeter from a value in NauticalMile. @@ -188,7 +188,7 @@ namespace ktsu.Semantics.Quantities; /// The value in NauticalMile. /// A new Perimeter instance. /// Thrown when the resulting magnitude would be negative. - public static Perimeter FromNauticalMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.NauticalMileToMeters)), nameof(value))); + public static Perimeter FromNauticalMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.NauticalMileToMeters), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Period.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Period.g.cs index 4698e26..71dc967 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Period.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Period.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Millisecond. /// A new Period instance. /// Thrown when the resulting magnitude would be negative. - public static Period FromMillisecond(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static Period FromMillisecond(T value) => Create(Vector0Guards.EnsurePositive((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new Period from a value in Microsecond. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Microsecond. /// A new Period instance. /// Thrown when the resulting magnitude would be negative. - public static Period FromMicrosecond(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); + public static Period FromMicrosecond(T value) => Create(Vector0Guards.EnsurePositive((value * MetricMagnitudes.Values.Micro), nameof(value))); /// /// Creates a new Period from a value in Minute. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Minute. /// A new Period instance. /// Thrown when the resulting magnitude would be negative. - public static Period FromMinute(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(Units.ConversionConstants.MinuteToSeconds)), nameof(value))); + public static Period FromMinute(T value) => Create(Vector0Guards.EnsurePositive((value * Units.ConversionConstants.Values.MinuteToSeconds), nameof(value))); /// /// Creates a new Period from a value in Hour. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Hour. /// A new Period instance. /// Thrown when the resulting magnitude would be negative. - public static Period FromHour(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(Units.ConversionConstants.HourToSeconds)), nameof(value))); + public static Period FromHour(T value) => Create(Vector0Guards.EnsurePositive((value * Units.ConversionConstants.Values.HourToSeconds), nameof(value))); /// /// Creates a new Period from a value in Day. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Day. /// A new Period instance. /// Thrown when the resulting magnitude would be negative. - public static Period FromDay(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(Units.ConversionConstants.DayToSeconds)), nameof(value))); + public static Period FromDay(T value) => Create(Vector0Guards.EnsurePositive((value * Units.ConversionConstants.Values.DayToSeconds), nameof(value))); /// /// Creates a new Period from a value in Year. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Year. /// A new Period instance. /// Thrown when the resulting magnitude would be negative. - public static Period FromYear(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(Units.ConversionConstants.YearToSeconds)), nameof(value))); + public static Period FromYear(T value) => Create(Vector0Guards.EnsurePositive((value * Units.ConversionConstants.Values.YearToSeconds), nameof(value))); /// /// Creates a new Period from a value in Week. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Week. /// A new Period instance. /// Thrown when the resulting magnitude would be negative. - public static Period FromWeek(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(Units.ConversionConstants.WeekToSeconds)), nameof(value))); + public static Period FromWeek(T value) => Create(Vector0Guards.EnsurePositive((value * Units.ConversionConstants.Values.WeekToSeconds), nameof(value))); /// /// Creates a new Period from a value in Nanosecond. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Nanosecond. /// A new Period instance. /// Thrown when the resulting magnitude would be negative. - public static Period FromNanosecond(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); + public static Period FromNanosecond(T value) => Create(Vector0Guards.EnsurePositive((value * MetricMagnitudes.Values.Nano), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Phase.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Phase.g.cs index 170b3b0..7d5ce60 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Phase.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Phase.g.cs @@ -110,28 +110,28 @@ namespace ktsu.Semantics.Quantities; /// /// The value in Degree. /// A new Phase instance. - public static Phase FromDegree(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians))); + public static Phase FromDegree(T value) => Create((value * Units.ConversionConstants.Values.DegreeToRadians)); /// /// Creates a new Phase from a value in Gradian. /// /// The value in Gradian. /// A new Phase instance. - public static Phase FromGradian(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.GradianToRadians))); + public static Phase FromGradian(T value) => Create((value * Units.ConversionConstants.Values.GradianToRadians)); /// /// Creates a new Phase from a value in Revolution. /// /// The value in Revolution. /// A new Phase instance. - public static Phase FromRevolution(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.RevolutionToRadians))); + public static Phase FromRevolution(T value) => Create((value * Units.ConversionConstants.Values.RevolutionToRadians)); /// /// Creates a new Phase from a value in Milliradian. /// /// The value in Milliradian. /// A new Phase instance. - public static Phase FromMilliradian(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Milli))); + public static Phase FromMilliradian(T value) => Create((value * MetricMagnitudes.Values.Milli)); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/PhaseVelocity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/PhaseVelocity.g.cs index 1444d5c..51b1440 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/PhaseVelocity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/PhaseVelocity.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in KilometerPerHour. /// A new PhaseVelocity instance. /// Thrown when the resulting magnitude would be negative. - public static PhaseVelocity FromKilometerPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilometerPerHourToMeterPerSecond)), nameof(value))); + public static PhaseVelocity FromKilometerPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilometerPerHourToMeterPerSecond), nameof(value))); /// /// Creates a new PhaseVelocity from a value in MilePerHour. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in MilePerHour. /// A new PhaseVelocity instance. /// Thrown when the resulting magnitude would be negative. - public static PhaseVelocity FromMilePerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MilePerHourToMeterPerSecond)), nameof(value))); + public static PhaseVelocity FromMilePerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MilePerHourToMeterPerSecond), nameof(value))); /// /// Creates a new PhaseVelocity from a value in FootPerSecond. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in FootPerSecond. /// A new PhaseVelocity instance. /// Thrown when the resulting magnitude would be negative. - public static PhaseVelocity FromFootPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FootPerSecondToMeterPerSecond)), nameof(value))); + public static PhaseVelocity FromFootPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.FootPerSecondToMeterPerSecond), nameof(value))); /// /// Creates a new PhaseVelocity from a value in Knot. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Knot. /// A new PhaseVelocity instance. /// Thrown when the resulting magnitude would be negative. - public static PhaseVelocity FromKnot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KnotToMeterPerSecond)), nameof(value))); + public static PhaseVelocity FromKnot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KnotToMeterPerSecond), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Pitch.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Pitch.g.cs index d1a0121..7764e0d 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Pitch.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Pitch.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilohertz. /// A new Pitch instance. /// Thrown when the resulting magnitude would be negative. - public static Pitch FromKilohertz(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Pitch FromKilohertz(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new Pitch from a value in Megahertz. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Megahertz. /// A new Pitch instance. /// Thrown when the resulting magnitude would be negative. - public static Pitch FromMegahertz(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Mega)), nameof(value))); + public static Pitch FromMegahertz(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Mega), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Position3D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Position3D.g.cs index eb1cd7a..2ed2716 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Position3D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Position3D.g.cs @@ -44,8 +44,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -67,8 +66,7 @@ public T Distance(Position3D other) T dY = Y - other.Y; T dZ = Z - other.Z; T sum = (dX * dX) + (dY * dY) + (dZ * dZ); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/PotentialEnergy.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/PotentialEnergy.g.cs index 276a760..2053be3 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/PotentialEnergy.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/PotentialEnergy.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilojoule. /// A new PotentialEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static PotentialEnergy FromKilojoule(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static PotentialEnergy FromKilojoule(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new PotentialEnergy from a value in ElectronVolt. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in ElectronVolt. /// A new PotentialEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static PotentialEnergy FromElectronVolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.ElectronVoltToJoules)), nameof(value))); + public static PotentialEnergy FromElectronVolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.ElectronVoltToJoules), nameof(value))); /// /// Creates a new PotentialEnergy from a value in Calorie. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Calorie. /// A new PotentialEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static PotentialEnergy FromCalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CalorieToJoules)), nameof(value))); + public static PotentialEnergy FromCalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.CalorieToJoules), nameof(value))); /// /// Creates a new PotentialEnergy from a value in Kilocalorie. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilocalorie. /// A new PotentialEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static PotentialEnergy FromKilocalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilocalorieToJoules)), nameof(value))); + public static PotentialEnergy FromKilocalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilocalorieToJoules), nameof(value))); /// /// Creates a new PotentialEnergy from a value in KilowattHour. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in KilowattHour. /// A new PotentialEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static PotentialEnergy FromKilowattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilowattHourToJoules)), nameof(value))); + public static PotentialEnergy FromKilowattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilowattHourToJoules), nameof(value))); /// /// Creates a new PotentialEnergy from a value in WattHour. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in WattHour. /// A new PotentialEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static PotentialEnergy FromWattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.WattHourToJoules)), nameof(value))); + public static PotentialEnergy FromWattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.WattHourToJoules), nameof(value))); /// /// Creates a new PotentialEnergy from a value in Erg. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Erg. /// A new PotentialEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static PotentialEnergy FromErg(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.ErgToJoules)), nameof(value))); + public static PotentialEnergy FromErg(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.ErgToJoules), nameof(value))); /// /// Creates a new PotentialEnergy from a value in Btu. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Btu. /// A new PotentialEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static PotentialEnergy FromBtu(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.BtuToJoules)), nameof(value))); + public static PotentialEnergy FromBtu(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.BtuToJoules), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Power.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Power.g.cs index 28fcc7b..03edb64 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Power.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Power.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilowatt. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Power FromKilowatt(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Power FromKilowatt(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new from a value in Megawatt. @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Megawatt. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Power FromMegawatt(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Mega)), nameof(value))); + public static Power FromMegawatt(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Mega), nameof(value))); /// /// Creates a new from a value in Horsepower. @@ -123,7 +123,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Horsepower. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Power FromHorsepower(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.HorsepowerToWatts)), nameof(value))); + public static Power FromHorsepower(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.HorsepowerToWatts), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Pressure.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Pressure.g.cs index ab48b62..47b6ae1 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Pressure.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Pressure.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilopascal. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Pressure FromKilopascal(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Pressure FromKilopascal(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new from a value in Bar. @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Bar. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Pressure FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.BarToPascals)), nameof(value))); + public static Pressure FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.BarToPascals), nameof(value))); /// /// Creates a new from a value in Atmosphere. @@ -123,7 +123,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Atmosphere. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Pressure FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AtmosphereToPascals)), nameof(value))); + public static Pressure FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AtmosphereToPascals), nameof(value))); /// /// Creates a new from a value in Psi. @@ -131,7 +131,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Psi. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Pressure FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PsiToPascals)), nameof(value))); + public static Pressure FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PsiToPascals), nameof(value))); /// /// Creates a new from a value in Torr. @@ -139,7 +139,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Torr. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Pressure FromTorr(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.TorrToPascals)), nameof(value))); + public static Pressure FromTorr(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.TorrToPascals), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/RadioactiveActivity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/RadioactiveActivity.g.cs index 46cecf2..10d79ee 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/RadioactiveActivity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/RadioactiveActivity.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Curie. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static RadioactiveActivity FromCurie(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CurieToBecquerels)), nameof(value))); + public static RadioactiveActivity FromCurie(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.CurieToBecquerels), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Radius.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Radius.g.cs index f660f57..02f5674 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Radius.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Radius.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilometer. /// A new Radius instance. /// Thrown when the resulting magnitude would be negative. - public static Radius FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Radius FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new Radius from a value in Centimeter. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Centimeter. /// A new Radius instance. /// Thrown when the resulting magnitude would be negative. - public static Radius FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Centi)), nameof(value))); + public static Radius FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Centi), nameof(value))); /// /// Creates a new Radius from a value in Millimeter. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Millimeter. /// A new Radius instance. /// Thrown when the resulting magnitude would be negative. - public static Radius FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static Radius FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new Radius from a value in Micrometer. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Micrometer. /// A new Radius instance. /// Thrown when the resulting magnitude would be negative. - public static Radius FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); + public static Radius FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Micro), nameof(value))); /// /// Creates a new Radius from a value in Nanometer. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Nanometer. /// A new Radius instance. /// Thrown when the resulting magnitude would be negative. - public static Radius FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); + public static Radius FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Nano), nameof(value))); /// /// Creates a new Radius from a value in Angstrom. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Angstrom. /// A new Radius instance. /// Thrown when the resulting magnitude would be negative. - public static Radius FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters)), nameof(value))); + public static Radius FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AngstromToMeters), nameof(value))); /// /// Creates a new Radius from a value in Foot. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Foot. /// A new Radius instance. /// Thrown when the resulting magnitude would be negative. - public static Radius FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters)), nameof(value))); + public static Radius FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.FeetToMeters), nameof(value))); /// /// Creates a new Radius from a value in Inch. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Inch. /// A new Radius instance. /// Thrown when the resulting magnitude would be negative. - public static Radius FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters)), nameof(value))); + public static Radius FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.InchesToMeters), nameof(value))); /// /// Creates a new Radius from a value in Yard. @@ -172,7 +172,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Yard. /// A new Radius instance. /// Thrown when the resulting magnitude would be negative. - public static Radius FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YardToMeters)), nameof(value))); + public static Radius FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.YardToMeters), nameof(value))); /// /// Creates a new Radius from a value in Mile. @@ -180,7 +180,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Mile. /// A new Radius instance. /// Thrown when the resulting magnitude would be negative. - public static Radius FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MileToMeters)), nameof(value))); + public static Radius FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MileToMeters), nameof(value))); /// /// Creates a new Radius from a value in NauticalMile. @@ -188,7 +188,7 @@ namespace ktsu.Semantics.Quantities; /// The value in NauticalMile. /// A new Radius instance. /// Thrown when the resulting magnitude would be negative. - public static Radius FromNauticalMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.NauticalMileToMeters)), nameof(value))); + public static Radius FromNauticalMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.NauticalMileToMeters), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Ratio.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Ratio.g.cs index 121932c..f9e86cc 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Ratio.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Ratio.g.cs @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Degree. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Ratio FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians)), nameof(value))); + public static Ratio FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DegreeToRadians), nameof(value))); /// /// Creates a new from a value in Gradian. @@ -123,7 +123,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Gradian. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Ratio FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GradianToRadians)), nameof(value))); + public static Ratio FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.GradianToRadians), nameof(value))); /// /// Creates a new from a value in Revolution. @@ -131,7 +131,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Revolution. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Ratio FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.RevolutionToRadians)), nameof(value))); + public static Ratio FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.RevolutionToRadians), nameof(value))); /// /// Creates a new from a value in Milliradian. @@ -139,7 +139,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Milliradian. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Ratio FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static Ratio FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new from a value in Percent. @@ -147,7 +147,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Percent. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Ratio FromPercent(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PercentToRatio)), nameof(value))); + public static Ratio FromPercent(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PercentToRatio), nameof(value))); /// /// Creates a new from a value in PartPerMillion. @@ -155,7 +155,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PartPerMillion. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Ratio FromPartPerMillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PartPerMillionToRatio)), nameof(value))); + public static Ratio FromPartPerMillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PartPerMillionToRatio), nameof(value))); /// /// Creates a new from a value in PartPerBillion. @@ -163,7 +163,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PartPerBillion. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Ratio FromPartPerBillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PartPerBillionToRatio)), nameof(value))); + public static Ratio FromPartPerBillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PartPerBillionToRatio), nameof(value))); /// /// Creates a new from a value in PercentByWeight. @@ -171,7 +171,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PercentByWeight. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Ratio FromPercentByWeight(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PercentByWeightToRatio)), nameof(value))); + public static Ratio FromPercentByWeight(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PercentByWeightToRatio), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReflectionCoefficient.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReflectionCoefficient.g.cs index f304be9..961da94 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReflectionCoefficient.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReflectionCoefficient.g.cs @@ -117,56 +117,56 @@ namespace ktsu.Semantics.Quantities; /// /// The value in Degree. /// A new ReflectionCoefficient instance. - public static ReflectionCoefficient FromDegree(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians))); + public static ReflectionCoefficient FromDegree(T value) => Create((value * Units.ConversionConstants.Values.DegreeToRadians)); /// /// Creates a new ReflectionCoefficient from a value in Gradian. /// /// The value in Gradian. /// A new ReflectionCoefficient instance. - public static ReflectionCoefficient FromGradian(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.GradianToRadians))); + public static ReflectionCoefficient FromGradian(T value) => Create((value * Units.ConversionConstants.Values.GradianToRadians)); /// /// Creates a new ReflectionCoefficient from a value in Revolution. /// /// The value in Revolution. /// A new ReflectionCoefficient instance. - public static ReflectionCoefficient FromRevolution(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.RevolutionToRadians))); + public static ReflectionCoefficient FromRevolution(T value) => Create((value * Units.ConversionConstants.Values.RevolutionToRadians)); /// /// Creates a new ReflectionCoefficient from a value in Milliradian. /// /// The value in Milliradian. /// A new ReflectionCoefficient instance. - public static ReflectionCoefficient FromMilliradian(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Milli))); + public static ReflectionCoefficient FromMilliradian(T value) => Create((value * MetricMagnitudes.Values.Milli)); /// /// Creates a new ReflectionCoefficient from a value in Percent. /// /// The value in Percent. /// A new ReflectionCoefficient instance. - public static ReflectionCoefficient FromPercent(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.PercentToRatio))); + public static ReflectionCoefficient FromPercent(T value) => Create((value * Units.ConversionConstants.Values.PercentToRatio)); /// /// Creates a new ReflectionCoefficient from a value in PartPerMillion. /// /// The value in PartPerMillion. /// A new ReflectionCoefficient instance. - public static ReflectionCoefficient FromPartPerMillion(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.PartPerMillionToRatio))); + public static ReflectionCoefficient FromPartPerMillion(T value) => Create((value * Units.ConversionConstants.Values.PartPerMillionToRatio)); /// /// Creates a new ReflectionCoefficient from a value in PartPerBillion. /// /// The value in PartPerBillion. /// A new ReflectionCoefficient instance. - public static ReflectionCoefficient FromPartPerBillion(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.PartPerBillionToRatio))); + public static ReflectionCoefficient FromPartPerBillion(T value) => Create((value * Units.ConversionConstants.Values.PartPerBillionToRatio)); /// /// Creates a new ReflectionCoefficient from a value in PercentByWeight. /// /// The value in PercentByWeight. /// A new ReflectionCoefficient instance. - public static ReflectionCoefficient FromPercentByWeight(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.PercentByWeightToRatio))); + public static ReflectionCoefficient FromPercentByWeight(T value) => Create((value * Units.ConversionConstants.Values.PercentByWeightToRatio)); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/RefractiveIndex.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/RefractiveIndex.g.cs index d6e4289..736e241 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/RefractiveIndex.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/RefractiveIndex.g.cs @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Degree. /// A new RefractiveIndex instance. /// Thrown when the resulting magnitude would be negative. - public static RefractiveIndex FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians)), nameof(value))); + public static RefractiveIndex FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DegreeToRadians), nameof(value))); /// /// Creates a new RefractiveIndex from a value in Gradian. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Gradian. /// A new RefractiveIndex instance. /// Thrown when the resulting magnitude would be negative. - public static RefractiveIndex FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GradianToRadians)), nameof(value))); + public static RefractiveIndex FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.GradianToRadians), nameof(value))); /// /// Creates a new RefractiveIndex from a value in Revolution. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Revolution. /// A new RefractiveIndex instance. /// Thrown when the resulting magnitude would be negative. - public static RefractiveIndex FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.RevolutionToRadians)), nameof(value))); + public static RefractiveIndex FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.RevolutionToRadians), nameof(value))); /// /// Creates a new RefractiveIndex from a value in Milliradian. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Milliradian. /// A new RefractiveIndex instance. /// Thrown when the resulting magnitude would be negative. - public static RefractiveIndex FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static RefractiveIndex FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new RefractiveIndex from a value in Percent. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Percent. /// A new RefractiveIndex instance. /// Thrown when the resulting magnitude would be negative. - public static RefractiveIndex FromPercent(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PercentToRatio)), nameof(value))); + public static RefractiveIndex FromPercent(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PercentToRatio), nameof(value))); /// /// Creates a new RefractiveIndex from a value in PartPerMillion. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PartPerMillion. /// A new RefractiveIndex instance. /// Thrown when the resulting magnitude would be negative. - public static RefractiveIndex FromPartPerMillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PartPerMillionToRatio)), nameof(value))); + public static RefractiveIndex FromPartPerMillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PartPerMillionToRatio), nameof(value))); /// /// Creates a new RefractiveIndex from a value in PartPerBillion. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PartPerBillion. /// A new RefractiveIndex instance. /// Thrown when the resulting magnitude would be negative. - public static RefractiveIndex FromPartPerBillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PartPerBillionToRatio)), nameof(value))); + public static RefractiveIndex FromPartPerBillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PartPerBillionToRatio), nameof(value))); /// /// Creates a new RefractiveIndex from a value in PercentByWeight. @@ -172,7 +172,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PercentByWeight. /// A new RefractiveIndex instance. /// Thrown when the resulting magnitude would be negative. - public static RefractiveIndex FromPercentByWeight(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PercentByWeightToRatio)), nameof(value))); + public static RefractiveIndex FromPercentByWeight(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PercentByWeightToRatio), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Resistance.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Resistance.g.cs index d5103a7..80b9974 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Resistance.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Resistance.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilohm. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Resistance FromKilohm(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Resistance FromKilohm(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new from a value in Megohm. @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Megohm. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Resistance FromMegohm(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Mega)), nameof(value))); + public static Resistance FromMegohm(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Mega), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReverberationTime.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReverberationTime.g.cs index 7d5e9bf..5199c1b 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReverberationTime.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReverberationTime.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Millisecond. /// A new ReverberationTime instance. /// Thrown when the resulting magnitude would be negative. - public static ReverberationTime FromMillisecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static ReverberationTime FromMillisecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new ReverberationTime from a value in Microsecond. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Microsecond. /// A new ReverberationTime instance. /// Thrown when the resulting magnitude would be negative. - public static ReverberationTime FromMicrosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); + public static ReverberationTime FromMicrosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Micro), nameof(value))); /// /// Creates a new ReverberationTime from a value in Minute. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Minute. /// A new ReverberationTime instance. /// Thrown when the resulting magnitude would be negative. - public static ReverberationTime FromMinute(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MinuteToSeconds)), nameof(value))); + public static ReverberationTime FromMinute(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MinuteToSeconds), nameof(value))); /// /// Creates a new ReverberationTime from a value in Hour. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Hour. /// A new ReverberationTime instance. /// Thrown when the resulting magnitude would be negative. - public static ReverberationTime FromHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.HourToSeconds)), nameof(value))); + public static ReverberationTime FromHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.HourToSeconds), nameof(value))); /// /// Creates a new ReverberationTime from a value in Day. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Day. /// A new ReverberationTime instance. /// Thrown when the resulting magnitude would be negative. - public static ReverberationTime FromDay(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DayToSeconds)), nameof(value))); + public static ReverberationTime FromDay(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DayToSeconds), nameof(value))); /// /// Creates a new ReverberationTime from a value in Year. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Year. /// A new ReverberationTime instance. /// Thrown when the resulting magnitude would be negative. - public static ReverberationTime FromYear(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YearToSeconds)), nameof(value))); + public static ReverberationTime FromYear(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.YearToSeconds), nameof(value))); /// /// Creates a new ReverberationTime from a value in Week. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Week. /// A new ReverberationTime instance. /// Thrown when the resulting magnitude would be negative. - public static ReverberationTime FromWeek(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.WeekToSeconds)), nameof(value))); + public static ReverberationTime FromWeek(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.WeekToSeconds), nameof(value))); /// /// Creates a new ReverberationTime from a value in Nanosecond. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Nanosecond. /// A new ReverberationTime instance. /// Thrown when the resulting magnitude would be negative. - public static ReverberationTime FromNanosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); + public static ReverberationTime FromNanosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Nano), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReynoldsNumber.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReynoldsNumber.g.cs index a4afe75..0303e50 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReynoldsNumber.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ReynoldsNumber.g.cs @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Degree. /// A new ReynoldsNumber instance. /// Thrown when the resulting magnitude would be negative. - public static ReynoldsNumber FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians)), nameof(value))); + public static ReynoldsNumber FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DegreeToRadians), nameof(value))); /// /// Creates a new ReynoldsNumber from a value in Gradian. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Gradian. /// A new ReynoldsNumber instance. /// Thrown when the resulting magnitude would be negative. - public static ReynoldsNumber FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GradianToRadians)), nameof(value))); + public static ReynoldsNumber FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.GradianToRadians), nameof(value))); /// /// Creates a new ReynoldsNumber from a value in Revolution. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Revolution. /// A new ReynoldsNumber instance. /// Thrown when the resulting magnitude would be negative. - public static ReynoldsNumber FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.RevolutionToRadians)), nameof(value))); + public static ReynoldsNumber FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.RevolutionToRadians), nameof(value))); /// /// Creates a new ReynoldsNumber from a value in Milliradian. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Milliradian. /// A new ReynoldsNumber instance. /// Thrown when the resulting magnitude would be negative. - public static ReynoldsNumber FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static ReynoldsNumber FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new ReynoldsNumber from a value in Percent. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Percent. /// A new ReynoldsNumber instance. /// Thrown when the resulting magnitude would be negative. - public static ReynoldsNumber FromPercent(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PercentToRatio)), nameof(value))); + public static ReynoldsNumber FromPercent(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PercentToRatio), nameof(value))); /// /// Creates a new ReynoldsNumber from a value in PartPerMillion. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PartPerMillion. /// A new ReynoldsNumber instance. /// Thrown when the resulting magnitude would be negative. - public static ReynoldsNumber FromPartPerMillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PartPerMillionToRatio)), nameof(value))); + public static ReynoldsNumber FromPartPerMillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PartPerMillionToRatio), nameof(value))); /// /// Creates a new ReynoldsNumber from a value in PartPerBillion. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PartPerBillion. /// A new ReynoldsNumber instance. /// Thrown when the resulting magnitude would be negative. - public static ReynoldsNumber FromPartPerBillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PartPerBillionToRatio)), nameof(value))); + public static ReynoldsNumber FromPartPerBillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PartPerBillionToRatio), nameof(value))); /// /// Creates a new ReynoldsNumber from a value in PercentByWeight. @@ -172,7 +172,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PercentByWeight. /// A new ReynoldsNumber instance. /// Thrown when the resulting magnitude would be negative. - public static ReynoldsNumber FromPercentByWeight(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PercentByWeightToRatio)), nameof(value))); + public static ReynoldsNumber FromPercentByWeight(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PercentByWeightToRatio), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Rotation.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Rotation.g.cs index c4ab4b2..08911f0 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Rotation.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Rotation.g.cs @@ -110,28 +110,28 @@ namespace ktsu.Semantics.Quantities; /// /// The value in Degree. /// A new Rotation instance. - public static Rotation FromDegree(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians))); + public static Rotation FromDegree(T value) => Create((value * Units.ConversionConstants.Values.DegreeToRadians)); /// /// Creates a new Rotation from a value in Gradian. /// /// The value in Gradian. /// A new Rotation instance. - public static Rotation FromGradian(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.GradianToRadians))); + public static Rotation FromGradian(T value) => Create((value * Units.ConversionConstants.Values.GradianToRadians)); /// /// Creates a new Rotation from a value in Revolution. /// /// The value in Revolution. /// A new Rotation instance. - public static Rotation FromRevolution(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.RevolutionToRadians))); + public static Rotation FromRevolution(T value) => Create((value * Units.ConversionConstants.Values.RevolutionToRadians)); /// /// Creates a new Rotation from a value in Milliradian. /// /// The value in Milliradian. /// A new Rotation instance. - public static Rotation FromMilliradian(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Milli))); + public static Rotation FromMilliradian(T value) => Create((value * MetricMagnitudes.Values.Milli)); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SamplingRate.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SamplingRate.g.cs index f15dd15..5bd7774 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SamplingRate.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SamplingRate.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilohertz. /// A new SamplingRate instance. /// Thrown when the resulting magnitude would be negative. - public static SamplingRate FromKilohertz(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static SamplingRate FromKilohertz(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new SamplingRate from a value in Megahertz. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Megahertz. /// A new SamplingRate instance. /// Thrown when the resulting magnitude would be negative. - public static SamplingRate FromMegahertz(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Mega)), nameof(value))); + public static SamplingRate FromMegahertz(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Mega), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ShearModulus.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ShearModulus.g.cs index 5bd55f6..abb1a46 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ShearModulus.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ShearModulus.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilopascal. /// A new ShearModulus instance. /// Thrown when the resulting magnitude would be negative. - public static ShearModulus FromKilopascal(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static ShearModulus FromKilopascal(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new ShearModulus from a value in Bar. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Bar. /// A new ShearModulus instance. /// Thrown when the resulting magnitude would be negative. - public static ShearModulus FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.BarToPascals)), nameof(value))); + public static ShearModulus FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.BarToPascals), nameof(value))); /// /// Creates a new ShearModulus from a value in Atmosphere. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Atmosphere. /// A new ShearModulus instance. /// Thrown when the resulting magnitude would be negative. - public static ShearModulus FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AtmosphereToPascals)), nameof(value))); + public static ShearModulus FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AtmosphereToPascals), nameof(value))); /// /// Creates a new ShearModulus from a value in Psi. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Psi. /// A new ShearModulus instance. /// Thrown when the resulting magnitude would be negative. - public static ShearModulus FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PsiToPascals)), nameof(value))); + public static ShearModulus FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PsiToPascals), nameof(value))); /// /// Creates a new ShearModulus from a value in Torr. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Torr. /// A new ShearModulus instance. /// Thrown when the resulting magnitude would be negative. - public static ShearModulus FromTorr(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.TorrToPascals)), nameof(value))); + public static ShearModulus FromTorr(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.TorrToPascals), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SignedAngle.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SignedAngle.g.cs index 3f9f4ce..36124ab 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SignedAngle.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SignedAngle.g.cs @@ -109,28 +109,28 @@ namespace ktsu.Semantics.Quantities; /// /// The value in Degree. /// A new instance. - public static SignedAngle FromDegree(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians))); + public static SignedAngle FromDegree(T value) => Create((value * Units.ConversionConstants.Values.DegreeToRadians)); /// /// Creates a new from a value in Gradian. /// /// The value in Gradian. /// A new instance. - public static SignedAngle FromGradian(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.GradianToRadians))); + public static SignedAngle FromGradian(T value) => Create((value * Units.ConversionConstants.Values.GradianToRadians)); /// /// Creates a new from a value in Revolution. /// /// The value in Revolution. /// A new instance. - public static SignedAngle FromRevolution(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.RevolutionToRadians))); + public static SignedAngle FromRevolution(T value) => Create((value * Units.ConversionConstants.Values.RevolutionToRadians)); /// /// Creates a new from a value in Milliradian. /// /// The value in Milliradian. /// A new instance. - public static SignedAngle FromMilliradian(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Milli))); + public static SignedAngle FromMilliradian(T value) => Create((value * MetricMagnitudes.Values.Milli)); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SignedRatio.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SignedRatio.g.cs index 76b5abf..75c3ee7 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SignedRatio.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SignedRatio.g.cs @@ -116,56 +116,56 @@ namespace ktsu.Semantics.Quantities; /// /// The value in Degree. /// A new instance. - public static SignedRatio FromDegree(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians))); + public static SignedRatio FromDegree(T value) => Create((value * Units.ConversionConstants.Values.DegreeToRadians)); /// /// Creates a new from a value in Gradian. /// /// The value in Gradian. /// A new instance. - public static SignedRatio FromGradian(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.GradianToRadians))); + public static SignedRatio FromGradian(T value) => Create((value * Units.ConversionConstants.Values.GradianToRadians)); /// /// Creates a new from a value in Revolution. /// /// The value in Revolution. /// A new instance. - public static SignedRatio FromRevolution(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.RevolutionToRadians))); + public static SignedRatio FromRevolution(T value) => Create((value * Units.ConversionConstants.Values.RevolutionToRadians)); /// /// Creates a new from a value in Milliradian. /// /// The value in Milliradian. /// A new instance. - public static SignedRatio FromMilliradian(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Milli))); + public static SignedRatio FromMilliradian(T value) => Create((value * MetricMagnitudes.Values.Milli)); /// /// Creates a new from a value in Percent. /// /// The value in Percent. /// A new instance. - public static SignedRatio FromPercent(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.PercentToRatio))); + public static SignedRatio FromPercent(T value) => Create((value * Units.ConversionConstants.Values.PercentToRatio)); /// /// Creates a new from a value in PartPerMillion. /// /// The value in PartPerMillion. /// A new instance. - public static SignedRatio FromPartPerMillion(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.PartPerMillionToRatio))); + public static SignedRatio FromPartPerMillion(T value) => Create((value * Units.ConversionConstants.Values.PartPerMillionToRatio)); /// /// Creates a new from a value in PartPerBillion. /// /// The value in PartPerBillion. /// A new instance. - public static SignedRatio FromPartPerBillion(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.PartPerBillionToRatio))); + public static SignedRatio FromPartPerBillion(T value) => Create((value * Units.ConversionConstants.Values.PartPerBillionToRatio)); /// /// Creates a new from a value in PercentByWeight. /// /// The value in PercentByWeight. /// A new instance. - public static SignedRatio FromPercentByWeight(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.PercentByWeightToRatio))); + public static SignedRatio FromPercentByWeight(T value) => Create((value * Units.ConversionConstants.Values.PercentByWeightToRatio)); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Snap2D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Snap2D.g.cs index 71d4aa6..a4862f2 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Snap2D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Snap2D.g.cs @@ -41,8 +41,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -57,8 +56,7 @@ public T Distance(Snap2D other) T dX = X - other.X; T dY = Y - other.Y; T sum = (dX * dX) + (dY * dY); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Snap3D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Snap3D.g.cs index 57e9514..478f4d8 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Snap3D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Snap3D.g.cs @@ -47,8 +47,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -70,8 +69,7 @@ public T Distance(Snap3D other) T dY = Y - other.Y; T dZ = Z - other.Z; T sum = (dX * dX) + (dY * dY) + (dZ * dZ); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Snap4D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Snap4D.g.cs index 459e8a3..a26006c 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Snap4D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Snap4D.g.cs @@ -53,8 +53,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z) + (W * W); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -71,8 +70,7 @@ public T Distance(Snap4D other) T dZ = Z - other.Z; T dW = W - other.W; T sum = (dX * dX) + (dY * dY) + (dZ * dZ) + (dW * dW); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundAbsorption.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundAbsorption.g.cs index 87c2ee9..e34acbd 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundAbsorption.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundAbsorption.g.cs @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Degree. /// A new SoundAbsorption instance. /// Thrown when the resulting magnitude would be negative. - public static SoundAbsorption FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians)), nameof(value))); + public static SoundAbsorption FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DegreeToRadians), nameof(value))); /// /// Creates a new SoundAbsorption from a value in Gradian. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Gradian. /// A new SoundAbsorption instance. /// Thrown when the resulting magnitude would be negative. - public static SoundAbsorption FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GradianToRadians)), nameof(value))); + public static SoundAbsorption FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.GradianToRadians), nameof(value))); /// /// Creates a new SoundAbsorption from a value in Revolution. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Revolution. /// A new SoundAbsorption instance. /// Thrown when the resulting magnitude would be negative. - public static SoundAbsorption FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.RevolutionToRadians)), nameof(value))); + public static SoundAbsorption FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.RevolutionToRadians), nameof(value))); /// /// Creates a new SoundAbsorption from a value in Milliradian. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Milliradian. /// A new SoundAbsorption instance. /// Thrown when the resulting magnitude would be negative. - public static SoundAbsorption FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static SoundAbsorption FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new SoundAbsorption from a value in Percent. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Percent. /// A new SoundAbsorption instance. /// Thrown when the resulting magnitude would be negative. - public static SoundAbsorption FromPercent(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PercentToRatio)), nameof(value))); + public static SoundAbsorption FromPercent(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PercentToRatio), nameof(value))); /// /// Creates a new SoundAbsorption from a value in PartPerMillion. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PartPerMillion. /// A new SoundAbsorption instance. /// Thrown when the resulting magnitude would be negative. - public static SoundAbsorption FromPartPerMillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PartPerMillionToRatio)), nameof(value))); + public static SoundAbsorption FromPartPerMillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PartPerMillionToRatio), nameof(value))); /// /// Creates a new SoundAbsorption from a value in PartPerBillion. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PartPerBillion. /// A new SoundAbsorption instance. /// Thrown when the resulting magnitude would be negative. - public static SoundAbsorption FromPartPerBillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PartPerBillionToRatio)), nameof(value))); + public static SoundAbsorption FromPartPerBillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PartPerBillionToRatio), nameof(value))); /// /// Creates a new SoundAbsorption from a value in PercentByWeight. @@ -172,7 +172,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PercentByWeight. /// A new SoundAbsorption instance. /// Thrown when the resulting magnitude would be negative. - public static SoundAbsorption FromPercentByWeight(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PercentByWeightToRatio)), nameof(value))); + public static SoundAbsorption FromPercentByWeight(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PercentByWeightToRatio), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundPower.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundPower.g.cs index 5ca93c8..bfc433a 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundPower.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundPower.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilowatt. /// A new SoundPower instance. /// Thrown when the resulting magnitude would be negative. - public static SoundPower FromKilowatt(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static SoundPower FromKilowatt(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new SoundPower from a value in Megawatt. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Megawatt. /// A new SoundPower instance. /// Thrown when the resulting magnitude would be negative. - public static SoundPower FromMegawatt(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Mega)), nameof(value))); + public static SoundPower FromMegawatt(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Mega), nameof(value))); /// /// Creates a new SoundPower from a value in Horsepower. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Horsepower. /// A new SoundPower instance. /// Thrown when the resulting magnitude would be negative. - public static SoundPower FromHorsepower(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.HorsepowerToWatts)), nameof(value))); + public static SoundPower FromHorsepower(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.HorsepowerToWatts), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundPressure.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundPressure.g.cs index f1d8a0e..144f62f 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundPressure.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundPressure.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilopascal. /// A new SoundPressure instance. /// Thrown when the resulting magnitude would be negative. - public static SoundPressure FromKilopascal(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static SoundPressure FromKilopascal(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new SoundPressure from a value in Bar. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Bar. /// A new SoundPressure instance. /// Thrown when the resulting magnitude would be negative. - public static SoundPressure FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.BarToPascals)), nameof(value))); + public static SoundPressure FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.BarToPascals), nameof(value))); /// /// Creates a new SoundPressure from a value in Atmosphere. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Atmosphere. /// A new SoundPressure instance. /// Thrown when the resulting magnitude would be negative. - public static SoundPressure FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AtmosphereToPascals)), nameof(value))); + public static SoundPressure FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AtmosphereToPascals), nameof(value))); /// /// Creates a new SoundPressure from a value in Psi. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Psi. /// A new SoundPressure instance. /// Thrown when the resulting magnitude would be negative. - public static SoundPressure FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PsiToPascals)), nameof(value))); + public static SoundPressure FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PsiToPascals), nameof(value))); /// /// Creates a new SoundPressure from a value in Torr. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Torr. /// A new SoundPressure instance. /// Thrown when the resulting magnitude would be negative. - public static SoundPressure FromTorr(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.TorrToPascals)), nameof(value))); + public static SoundPressure FromTorr(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.TorrToPascals), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundSpeed.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundSpeed.g.cs index 1dfbd11..77aff08 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundSpeed.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundSpeed.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in KilometerPerHour. /// A new SoundSpeed instance. /// Thrown when the resulting magnitude would be negative. - public static SoundSpeed FromKilometerPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilometerPerHourToMeterPerSecond)), nameof(value))); + public static SoundSpeed FromKilometerPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilometerPerHourToMeterPerSecond), nameof(value))); /// /// Creates a new SoundSpeed from a value in MilePerHour. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in MilePerHour. /// A new SoundSpeed instance. /// Thrown when the resulting magnitude would be negative. - public static SoundSpeed FromMilePerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MilePerHourToMeterPerSecond)), nameof(value))); + public static SoundSpeed FromMilePerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MilePerHourToMeterPerSecond), nameof(value))); /// /// Creates a new SoundSpeed from a value in FootPerSecond. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in FootPerSecond. /// A new SoundSpeed instance. /// Thrown when the resulting magnitude would be negative. - public static SoundSpeed FromFootPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FootPerSecondToMeterPerSecond)), nameof(value))); + public static SoundSpeed FromFootPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.FootPerSecondToMeterPerSecond), nameof(value))); /// /// Creates a new SoundSpeed from a value in Knot. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Knot. /// A new SoundSpeed instance. /// Thrown when the resulting magnitude would be negative. - public static SoundSpeed FromKnot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KnotToMeterPerSecond)), nameof(value))); + public static SoundSpeed FromKnot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KnotToMeterPerSecond), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundTransmissionClass.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundTransmissionClass.g.cs index 70e3353..7c6cc28 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundTransmissionClass.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SoundTransmissionClass.g.cs @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Degree. /// A new SoundTransmissionClass instance. /// Thrown when the resulting magnitude would be negative. - public static SoundTransmissionClass FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians)), nameof(value))); + public static SoundTransmissionClass FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DegreeToRadians), nameof(value))); /// /// Creates a new SoundTransmissionClass from a value in Gradian. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Gradian. /// A new SoundTransmissionClass instance. /// Thrown when the resulting magnitude would be negative. - public static SoundTransmissionClass FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GradianToRadians)), nameof(value))); + public static SoundTransmissionClass FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.GradianToRadians), nameof(value))); /// /// Creates a new SoundTransmissionClass from a value in Revolution. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Revolution. /// A new SoundTransmissionClass instance. /// Thrown when the resulting magnitude would be negative. - public static SoundTransmissionClass FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.RevolutionToRadians)), nameof(value))); + public static SoundTransmissionClass FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.RevolutionToRadians), nameof(value))); /// /// Creates a new SoundTransmissionClass from a value in Milliradian. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Milliradian. /// A new SoundTransmissionClass instance. /// Thrown when the resulting magnitude would be negative. - public static SoundTransmissionClass FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static SoundTransmissionClass FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new SoundTransmissionClass from a value in Percent. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Percent. /// A new SoundTransmissionClass instance. /// Thrown when the resulting magnitude would be negative. - public static SoundTransmissionClass FromPercent(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PercentToRatio)), nameof(value))); + public static SoundTransmissionClass FromPercent(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PercentToRatio), nameof(value))); /// /// Creates a new SoundTransmissionClass from a value in PartPerMillion. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PartPerMillion. /// A new SoundTransmissionClass instance. /// Thrown when the resulting magnitude would be negative. - public static SoundTransmissionClass FromPartPerMillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PartPerMillionToRatio)), nameof(value))); + public static SoundTransmissionClass FromPartPerMillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PartPerMillionToRatio), nameof(value))); /// /// Creates a new SoundTransmissionClass from a value in PartPerBillion. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PartPerBillion. /// A new SoundTransmissionClass instance. /// Thrown when the resulting magnitude would be negative. - public static SoundTransmissionClass FromPartPerBillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PartPerBillionToRatio)), nameof(value))); + public static SoundTransmissionClass FromPartPerBillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PartPerBillionToRatio), nameof(value))); /// /// Creates a new SoundTransmissionClass from a value in PercentByWeight. @@ -172,7 +172,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PercentByWeight. /// A new SoundTransmissionClass instance. /// Thrown when the resulting magnitude would be negative. - public static SoundTransmissionClass FromPercentByWeight(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PercentByWeightToRatio)), nameof(value))); + public static SoundTransmissionClass FromPercentByWeight(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PercentByWeightToRatio), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificGravity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificGravity.g.cs index 1e6d437..82b6502 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificGravity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SpecificGravity.g.cs @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Degree. /// A new SpecificGravity instance. /// Thrown when the resulting magnitude would be negative. - public static SpecificGravity FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DegreeToRadians)), nameof(value))); + public static SpecificGravity FromDegree(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DegreeToRadians), nameof(value))); /// /// Creates a new SpecificGravity from a value in Gradian. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Gradian. /// A new SpecificGravity instance. /// Thrown when the resulting magnitude would be negative. - public static SpecificGravity FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GradianToRadians)), nameof(value))); + public static SpecificGravity FromGradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.GradianToRadians), nameof(value))); /// /// Creates a new SpecificGravity from a value in Revolution. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Revolution. /// A new SpecificGravity instance. /// Thrown when the resulting magnitude would be negative. - public static SpecificGravity FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.RevolutionToRadians)), nameof(value))); + public static SpecificGravity FromRevolution(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.RevolutionToRadians), nameof(value))); /// /// Creates a new SpecificGravity from a value in Milliradian. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Milliradian. /// A new SpecificGravity instance. /// Thrown when the resulting magnitude would be negative. - public static SpecificGravity FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static SpecificGravity FromMilliradian(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new SpecificGravity from a value in Percent. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Percent. /// A new SpecificGravity instance. /// Thrown when the resulting magnitude would be negative. - public static SpecificGravity FromPercent(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PercentToRatio)), nameof(value))); + public static SpecificGravity FromPercent(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PercentToRatio), nameof(value))); /// /// Creates a new SpecificGravity from a value in PartPerMillion. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PartPerMillion. /// A new SpecificGravity instance. /// Thrown when the resulting magnitude would be negative. - public static SpecificGravity FromPartPerMillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PartPerMillionToRatio)), nameof(value))); + public static SpecificGravity FromPartPerMillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PartPerMillionToRatio), nameof(value))); /// /// Creates a new SpecificGravity from a value in PartPerBillion. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PartPerBillion. /// A new SpecificGravity instance. /// Thrown when the resulting magnitude would be negative. - public static SpecificGravity FromPartPerBillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PartPerBillionToRatio)), nameof(value))); + public static SpecificGravity FromPartPerBillion(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PartPerBillionToRatio), nameof(value))); /// /// Creates a new SpecificGravity from a value in PercentByWeight. @@ -172,7 +172,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PercentByWeight. /// A new SpecificGravity instance. /// Thrown when the resulting magnitude would be negative. - public static SpecificGravity FromPercentByWeight(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PercentByWeightToRatio)), nameof(value))); + public static SpecificGravity FromPercentByWeight(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PercentByWeightToRatio), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Speed.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Speed.g.cs index 94c81b0..ea19b3b 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Speed.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Speed.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in KilometerPerHour. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Speed FromKilometerPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilometerPerHourToMeterPerSecond)), nameof(value))); + public static Speed FromKilometerPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilometerPerHourToMeterPerSecond), nameof(value))); /// /// Creates a new from a value in MilePerHour. @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in MilePerHour. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Speed FromMilePerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MilePerHourToMeterPerSecond)), nameof(value))); + public static Speed FromMilePerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MilePerHourToMeterPerSecond), nameof(value))); /// /// Creates a new from a value in FootPerSecond. @@ -123,7 +123,7 @@ namespace ktsu.Semantics.Quantities; /// The value in FootPerSecond. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Speed FromFootPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FootPerSecondToMeterPerSecond)), nameof(value))); + public static Speed FromFootPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.FootPerSecondToMeterPerSecond), nameof(value))); /// /// Creates a new from a value in Knot. @@ -131,7 +131,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Knot. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Speed FromKnot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KnotToMeterPerSecond)), nameof(value))); + public static Speed FromKnot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KnotToMeterPerSecond), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Stress.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Stress.g.cs index 3f2165d..57fe698 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Stress.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Stress.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilopascal. /// A new Stress instance. /// Thrown when the resulting magnitude would be negative. - public static Stress FromKilopascal(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Stress FromKilopascal(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new Stress from a value in Bar. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Bar. /// A new Stress instance. /// Thrown when the resulting magnitude would be negative. - public static Stress FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.BarToPascals)), nameof(value))); + public static Stress FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.BarToPascals), nameof(value))); /// /// Creates a new Stress from a value in Atmosphere. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Atmosphere. /// A new Stress instance. /// Thrown when the resulting magnitude would be negative. - public static Stress FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AtmosphereToPascals)), nameof(value))); + public static Stress FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AtmosphereToPascals), nameof(value))); /// /// Creates a new Stress from a value in Psi. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Psi. /// A new Stress instance. /// Thrown when the resulting magnitude would be negative. - public static Stress FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PsiToPascals)), nameof(value))); + public static Stress FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PsiToPascals), nameof(value))); /// /// Creates a new Stress from a value in Torr. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Torr. /// A new Stress instance. /// Thrown when the resulting magnitude would be negative. - public static Stress FromTorr(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.TorrToPascals)), nameof(value))); + public static Stress FromTorr(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.TorrToPascals), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SurfaceArea.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SurfaceArea.g.cs index 38b09e1..7580b2b 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SurfaceArea.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SurfaceArea.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in SquareKilometer. /// A new SurfaceArea instance. /// Thrown when the resulting magnitude would be negative. - public static SurfaceArea FromSquareKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.SquareKilometerToSquareMeters)), nameof(value))); + public static SurfaceArea FromSquareKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.SquareKilometerToSquareMeters), nameof(value))); /// /// Creates a new SurfaceArea from a value in SquareCentimeter. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in SquareCentimeter. /// A new SurfaceArea instance. /// Thrown when the resulting magnitude would be negative. - public static SurfaceArea FromSquareCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.SquareCentimeterToSquareMeters)), nameof(value))); + public static SurfaceArea FromSquareCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.SquareCentimeterToSquareMeters), nameof(value))); /// /// Creates a new SurfaceArea from a value in SquareFoot. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in SquareFoot. /// A new SurfaceArea instance. /// Thrown when the resulting magnitude would be negative. - public static SurfaceArea FromSquareFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.SquareFootToSquareMeters)), nameof(value))); + public static SurfaceArea FromSquareFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.SquareFootToSquareMeters), nameof(value))); /// /// Creates a new SurfaceArea from a value in SquareInch. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in SquareInch. /// A new SurfaceArea instance. /// Thrown when the resulting magnitude would be negative. - public static SurfaceArea FromSquareInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.SquareInchToSquareMeters)), nameof(value))); + public static SurfaceArea FromSquareInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.SquareInchToSquareMeters), nameof(value))); /// /// Creates a new SurfaceArea from a value in SquareMile. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in SquareMile. /// A new SurfaceArea instance. /// Thrown when the resulting magnitude would be negative. - public static SurfaceArea FromSquareMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.SquareMileToSquareMeters)), nameof(value))); + public static SurfaceArea FromSquareMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.SquareMileToSquareMeters), nameof(value))); /// /// Creates a new SurfaceArea from a value in Hectare. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Hectare. /// A new SurfaceArea instance. /// Thrown when the resulting magnitude would be negative. - public static SurfaceArea FromHectare(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.HectareToSquareMeters)), nameof(value))); + public static SurfaceArea FromHectare(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.HectareToSquareMeters), nameof(value))); /// /// Creates a new SurfaceArea from a value in Acre. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Acre. /// A new SurfaceArea instance. /// Thrown when the resulting magnitude would be negative. - public static SurfaceArea FromAcre(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AcreToSquareMeters)), nameof(value))); + public static SurfaceArea FromAcre(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AcreToSquareMeters), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SurfaceTension.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SurfaceTension.g.cs index f41a110..83df84d 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SurfaceTension.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/SurfaceTension.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in DynePerCentimeter. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static SurfaceTension FromDynePerCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DynePerCentimeterToNewtonPerMeter)), nameof(value))); + public static SurfaceTension FromDynePerCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DynePerCentimeterToNewtonPerMeter), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Temperature.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Temperature.g.cs index 83ed8af..b58c76e 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Temperature.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Temperature.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Celsius. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Temperature FromCelsius(T value) => Create(Vector0Guards.EnsureNonNegative((value + T.CreateChecked(Units.ConversionConstants.CelsiusToKelvinOffset)), nameof(value))); + public static Temperature FromCelsius(T value) => Create(Vector0Guards.EnsureNonNegative((value + Units.ConversionConstants.Values.CelsiusToKelvinOffset), nameof(value))); /// /// Creates a new from a value in Fahrenheit. @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Fahrenheit. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Temperature FromFahrenheit(T value) => Create(Vector0Guards.EnsureNonNegative(((value * T.CreateChecked(Units.ConversionConstants.FahrenheitScale)) + T.CreateChecked(Units.ConversionConstants.FahrenheitToKelvinOffset)), nameof(value))); + public static Temperature FromFahrenheit(T value) => Create(Vector0Guards.EnsureNonNegative(((value * Units.ConversionConstants.Values.FahrenheitScale) + Units.ConversionConstants.Values.FahrenheitToKelvinOffset), nameof(value))); /// /// Creates a new from a value in Rankine. @@ -123,7 +123,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Rankine. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Temperature FromRankine(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FahrenheitScale)), nameof(value))); + public static Temperature FromRankine(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.FahrenheitScale), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureDelta.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureDelta.g.cs index 08f0d3a..da6a766 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureDelta.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureDelta.g.cs @@ -109,21 +109,21 @@ namespace ktsu.Semantics.Quantities; /// /// The value in Celsius. /// A new instance. - public static TemperatureDelta FromCelsius(T value) => Create((value + T.CreateChecked(Units.ConversionConstants.CelsiusToKelvinOffset))); + public static TemperatureDelta FromCelsius(T value) => Create((value + Units.ConversionConstants.Values.CelsiusToKelvinOffset)); /// /// Creates a new from a value in Fahrenheit. /// /// The value in Fahrenheit. /// A new instance. - public static TemperatureDelta FromFahrenheit(T value) => Create(((value * T.CreateChecked(Units.ConversionConstants.FahrenheitScale)) + T.CreateChecked(Units.ConversionConstants.FahrenheitToKelvinOffset))); + public static TemperatureDelta FromFahrenheit(T value) => Create(((value * Units.ConversionConstants.Values.FahrenheitScale) + Units.ConversionConstants.Values.FahrenheitToKelvinOffset)); /// /// Creates a new from a value in Rankine. /// /// The value in Rankine. /// A new instance. - public static TemperatureDelta FromRankine(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.FahrenheitScale))); + public static TemperatureDelta FromRankine(T value) => Create((value * Units.ConversionConstants.Values.FahrenheitScale)); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureDrop.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureDrop.g.cs index 84a1300..cc8a59c 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureDrop.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureDrop.g.cs @@ -110,21 +110,21 @@ namespace ktsu.Semantics.Quantities; /// /// The value in Celsius. /// A new TemperatureDrop instance. - public static TemperatureDrop FromCelsius(T value) => Create((value + T.CreateChecked(Units.ConversionConstants.CelsiusToKelvinOffset))); + public static TemperatureDrop FromCelsius(T value) => Create((value + Units.ConversionConstants.Values.CelsiusToKelvinOffset)); /// /// Creates a new TemperatureDrop from a value in Fahrenheit. /// /// The value in Fahrenheit. /// A new TemperatureDrop instance. - public static TemperatureDrop FromFahrenheit(T value) => Create(((value * T.CreateChecked(Units.ConversionConstants.FahrenheitScale)) + T.CreateChecked(Units.ConversionConstants.FahrenheitToKelvinOffset))); + public static TemperatureDrop FromFahrenheit(T value) => Create(((value * Units.ConversionConstants.Values.FahrenheitScale) + Units.ConversionConstants.Values.FahrenheitToKelvinOffset)); /// /// Creates a new TemperatureDrop from a value in Rankine. /// /// The value in Rankine. /// A new TemperatureDrop instance. - public static TemperatureDrop FromRankine(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.FahrenheitScale))); + public static TemperatureDrop FromRankine(T value) => Create((value * Units.ConversionConstants.Values.FahrenheitScale)); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureRise.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureRise.g.cs index 7fafb25..6df1151 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureRise.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TemperatureRise.g.cs @@ -110,21 +110,21 @@ namespace ktsu.Semantics.Quantities; /// /// The value in Celsius. /// A new TemperatureRise instance. - public static TemperatureRise FromCelsius(T value) => Create((value + T.CreateChecked(Units.ConversionConstants.CelsiusToKelvinOffset))); + public static TemperatureRise FromCelsius(T value) => Create((value + Units.ConversionConstants.Values.CelsiusToKelvinOffset)); /// /// Creates a new TemperatureRise from a value in Fahrenheit. /// /// The value in Fahrenheit. /// A new TemperatureRise instance. - public static TemperatureRise FromFahrenheit(T value) => Create(((value * T.CreateChecked(Units.ConversionConstants.FahrenheitScale)) + T.CreateChecked(Units.ConversionConstants.FahrenheitToKelvinOffset))); + public static TemperatureRise FromFahrenheit(T value) => Create(((value * Units.ConversionConstants.Values.FahrenheitScale) + Units.ConversionConstants.Values.FahrenheitToKelvinOffset)); /// /// Creates a new TemperatureRise from a value in Rankine. /// /// The value in Rankine. /// A new TemperatureRise instance. - public static TemperatureRise FromRankine(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.FahrenheitScale))); + public static TemperatureRise FromRankine(T value) => Create((value * Units.ConversionConstants.Values.FahrenheitScale)); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Tension.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Tension.g.cs index 3874a41..e49a64b 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Tension.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Tension.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilonewton. /// A new Tension instance. /// Thrown when the resulting magnitude would be negative. - public static Tension FromKilonewton(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Tension FromKilonewton(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new Tension from a value in Dyne. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Dyne. /// A new Tension instance. /// Thrown when the resulting magnitude would be negative. - public static Tension FromDyne(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DyneToNewtons)), nameof(value))); + public static Tension FromDyne(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DyneToNewtons), nameof(value))); /// /// Creates a new Tension from a value in PoundForce. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PoundForce. /// A new Tension instance. /// Thrown when the resulting magnitude would be negative. - public static Tension FromPoundForce(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PoundForceToNewtons)), nameof(value))); + public static Tension FromPoundForce(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PoundForceToNewtons), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalDiffusivity.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalDiffusivity.g.cs index 1c64441..e752eac 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalDiffusivity.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalDiffusivity.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Stokes. /// A new ThermalDiffusivity instance. /// Thrown when the resulting magnitude would be negative. - public static ThermalDiffusivity FromStokes(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.StokesToSquareMeterPerSecond)), nameof(value))); + public static ThermalDiffusivity FromStokes(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.StokesToSquareMeterPerSecond), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalEnergy.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalEnergy.g.cs index 655dcc7..a540c71 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalEnergy.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThermalEnergy.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilojoule. /// A new ThermalEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static ThermalEnergy FromKilojoule(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static ThermalEnergy FromKilojoule(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new ThermalEnergy from a value in ElectronVolt. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in ElectronVolt. /// A new ThermalEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static ThermalEnergy FromElectronVolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.ElectronVoltToJoules)), nameof(value))); + public static ThermalEnergy FromElectronVolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.ElectronVoltToJoules), nameof(value))); /// /// Creates a new ThermalEnergy from a value in Calorie. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Calorie. /// A new ThermalEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static ThermalEnergy FromCalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CalorieToJoules)), nameof(value))); + public static ThermalEnergy FromCalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.CalorieToJoules), nameof(value))); /// /// Creates a new ThermalEnergy from a value in Kilocalorie. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilocalorie. /// A new ThermalEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static ThermalEnergy FromKilocalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilocalorieToJoules)), nameof(value))); + public static ThermalEnergy FromKilocalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilocalorieToJoules), nameof(value))); /// /// Creates a new ThermalEnergy from a value in KilowattHour. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in KilowattHour. /// A new ThermalEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static ThermalEnergy FromKilowattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilowattHourToJoules)), nameof(value))); + public static ThermalEnergy FromKilowattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilowattHourToJoules), nameof(value))); /// /// Creates a new ThermalEnergy from a value in WattHour. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in WattHour. /// A new ThermalEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static ThermalEnergy FromWattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.WattHourToJoules)), nameof(value))); + public static ThermalEnergy FromWattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.WattHourToJoules), nameof(value))); /// /// Creates a new ThermalEnergy from a value in Erg. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Erg. /// A new ThermalEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static ThermalEnergy FromErg(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.ErgToJoules)), nameof(value))); + public static ThermalEnergy FromErg(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.ErgToJoules), nameof(value))); /// /// Creates a new ThermalEnergy from a value in Btu. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Btu. /// A new ThermalEnergy instance. /// Thrown when the resulting magnitude would be negative. - public static ThermalEnergy FromBtu(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.BtuToJoules)), nameof(value))); + public static ThermalEnergy FromBtu(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.BtuToJoules), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Thickness.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Thickness.g.cs index 461b8d7..d748c0a 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Thickness.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Thickness.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilometer. /// A new Thickness instance. /// Thrown when the resulting magnitude would be negative. - public static Thickness FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Thickness FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new Thickness from a value in Centimeter. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Centimeter. /// A new Thickness instance. /// Thrown when the resulting magnitude would be negative. - public static Thickness FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Centi)), nameof(value))); + public static Thickness FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Centi), nameof(value))); /// /// Creates a new Thickness from a value in Millimeter. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Millimeter. /// A new Thickness instance. /// Thrown when the resulting magnitude would be negative. - public static Thickness FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static Thickness FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new Thickness from a value in Micrometer. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Micrometer. /// A new Thickness instance. /// Thrown when the resulting magnitude would be negative. - public static Thickness FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); + public static Thickness FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Micro), nameof(value))); /// /// Creates a new Thickness from a value in Nanometer. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Nanometer. /// A new Thickness instance. /// Thrown when the resulting magnitude would be negative. - public static Thickness FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); + public static Thickness FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Nano), nameof(value))); /// /// Creates a new Thickness from a value in Angstrom. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Angstrom. /// A new Thickness instance. /// Thrown when the resulting magnitude would be negative. - public static Thickness FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters)), nameof(value))); + public static Thickness FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AngstromToMeters), nameof(value))); /// /// Creates a new Thickness from a value in Foot. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Foot. /// A new Thickness instance. /// Thrown when the resulting magnitude would be negative. - public static Thickness FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters)), nameof(value))); + public static Thickness FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.FeetToMeters), nameof(value))); /// /// Creates a new Thickness from a value in Inch. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Inch. /// A new Thickness instance. /// Thrown when the resulting magnitude would be negative. - public static Thickness FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters)), nameof(value))); + public static Thickness FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.InchesToMeters), nameof(value))); /// /// Creates a new Thickness from a value in Yard. @@ -172,7 +172,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Yard. /// A new Thickness instance. /// Thrown when the resulting magnitude would be negative. - public static Thickness FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YardToMeters)), nameof(value))); + public static Thickness FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.YardToMeters), nameof(value))); /// /// Creates a new Thickness from a value in Mile. @@ -180,7 +180,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Mile. /// A new Thickness instance. /// Thrown when the resulting magnitude would be negative. - public static Thickness FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MileToMeters)), nameof(value))); + public static Thickness FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MileToMeters), nameof(value))); /// /// Creates a new Thickness from a value in NauticalMile. @@ -188,7 +188,7 @@ namespace ktsu.Semantics.Quantities; /// The value in NauticalMile. /// A new Thickness instance. /// Thrown when the resulting magnitude would be negative. - public static Thickness FromNauticalMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.NauticalMileToMeters)), nameof(value))); + public static Thickness FromNauticalMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.NauticalMileToMeters), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Thrust.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Thrust.g.cs index 93d7314..b9daa8b 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Thrust.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Thrust.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilonewton. /// A new Thrust instance. /// Thrown when the resulting magnitude would be negative. - public static Thrust FromKilonewton(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Thrust FromKilonewton(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new Thrust from a value in Dyne. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Dyne. /// A new Thrust instance. /// Thrown when the resulting magnitude would be negative. - public static Thrust FromDyne(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DyneToNewtons)), nameof(value))); + public static Thrust FromDyne(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DyneToNewtons), nameof(value))); /// /// Creates a new Thrust from a value in PoundForce. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PoundForce. /// A new Thrust instance. /// Thrown when the resulting magnitude would be negative. - public static Thrust FromPoundForce(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PoundForceToNewtons)), nameof(value))); + public static Thrust FromPoundForce(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PoundForceToNewtons), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThrustVector.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThrustVector.g.cs index a329479..5a2bfc1 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThrustVector.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/ThrustVector.g.cs @@ -44,8 +44,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -67,8 +66,7 @@ public T Distance(ThrustVector other) T dY = Y - other.Y; T dZ = Z - other.Z; T sum = (dX * dX) + (dY * dY) + (dZ * dZ); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TimeConstant.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TimeConstant.g.cs index 52b2d4f..beb64aa 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TimeConstant.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TimeConstant.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Millisecond. /// A new TimeConstant instance. /// Thrown when the resulting magnitude would be negative. - public static TimeConstant FromMillisecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static TimeConstant FromMillisecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new TimeConstant from a value in Microsecond. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Microsecond. /// A new TimeConstant instance. /// Thrown when the resulting magnitude would be negative. - public static TimeConstant FromMicrosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); + public static TimeConstant FromMicrosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Micro), nameof(value))); /// /// Creates a new TimeConstant from a value in Minute. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Minute. /// A new TimeConstant instance. /// Thrown when the resulting magnitude would be negative. - public static TimeConstant FromMinute(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MinuteToSeconds)), nameof(value))); + public static TimeConstant FromMinute(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MinuteToSeconds), nameof(value))); /// /// Creates a new TimeConstant from a value in Hour. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Hour. /// A new TimeConstant instance. /// Thrown when the resulting magnitude would be negative. - public static TimeConstant FromHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.HourToSeconds)), nameof(value))); + public static TimeConstant FromHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.HourToSeconds), nameof(value))); /// /// Creates a new TimeConstant from a value in Day. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Day. /// A new TimeConstant instance. /// Thrown when the resulting magnitude would be negative. - public static TimeConstant FromDay(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DayToSeconds)), nameof(value))); + public static TimeConstant FromDay(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DayToSeconds), nameof(value))); /// /// Creates a new TimeConstant from a value in Year. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Year. /// A new TimeConstant instance. /// Thrown when the resulting magnitude would be negative. - public static TimeConstant FromYear(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YearToSeconds)), nameof(value))); + public static TimeConstant FromYear(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.YearToSeconds), nameof(value))); /// /// Creates a new TimeConstant from a value in Week. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Week. /// A new TimeConstant instance. /// Thrown when the resulting magnitude would be negative. - public static TimeConstant FromWeek(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.WeekToSeconds)), nameof(value))); + public static TimeConstant FromWeek(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.WeekToSeconds), nameof(value))); /// /// Creates a new TimeConstant from a value in Nanosecond. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Nanosecond. /// A new TimeConstant instance. /// Thrown when the resulting magnitude would be negative. - public static TimeConstant FromNanosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); + public static TimeConstant FromNanosecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Nano), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Torque1D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Torque1D.g.cs index 916ebb9..15f7d01 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Torque1D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Torque1D.g.cs @@ -109,7 +109,7 @@ namespace ktsu.Semantics.Quantities; /// /// The value in PoundFoot. /// A new instance. - public static Torque1D FromPoundFoot(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.PoundFootToNewtonMeters))); + public static Torque1D FromPoundFoot(T value) => Create((value * Units.ConversionConstants.Values.PoundFootToNewtonMeters)); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Torque3D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Torque3D.g.cs index 556b51f..0a31627 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Torque3D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Torque3D.g.cs @@ -47,8 +47,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -70,8 +69,7 @@ public T Distance(Torque3D other) T dY = Y - other.Y; T dZ = Z - other.Z; T sum = (dX * dX) + (dY * dY) + (dZ * dZ); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TorqueMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TorqueMagnitude.g.cs index 545ec02..de14d6d 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TorqueMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/TorqueMagnitude.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PoundFoot. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static TorqueMagnitude FromPoundFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PoundFootToNewtonMeters)), nameof(value))); + public static TorqueMagnitude FromPoundFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PoundFootToNewtonMeters), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Translation3D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Translation3D.g.cs index b97d301..1404c2c 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Translation3D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Translation3D.g.cs @@ -44,8 +44,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -67,8 +66,7 @@ public T Distance(Translation3D other) T dY = Y - other.Y; T dZ = Z - other.Z; T sum = (dX * dX) + (dY * dY) + (dZ * dZ); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Velocity1D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Velocity1D.g.cs index 5431f98..a1b023d 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Velocity1D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Velocity1D.g.cs @@ -109,28 +109,28 @@ namespace ktsu.Semantics.Quantities; /// /// The value in KilometerPerHour. /// A new instance. - public static Velocity1D FromKilometerPerHour(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.KilometerPerHourToMeterPerSecond))); + public static Velocity1D FromKilometerPerHour(T value) => Create((value * Units.ConversionConstants.Values.KilometerPerHourToMeterPerSecond)); /// /// Creates a new from a value in MilePerHour. /// /// The value in MilePerHour. /// A new instance. - public static Velocity1D FromMilePerHour(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.MilePerHourToMeterPerSecond))); + public static Velocity1D FromMilePerHour(T value) => Create((value * Units.ConversionConstants.Values.MilePerHourToMeterPerSecond)); /// /// Creates a new from a value in FootPerSecond. /// /// The value in FootPerSecond. /// A new instance. - public static Velocity1D FromFootPerSecond(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.FootPerSecondToMeterPerSecond))); + public static Velocity1D FromFootPerSecond(T value) => Create((value * Units.ConversionConstants.Values.FootPerSecondToMeterPerSecond)); /// /// Creates a new from a value in Knot. /// /// The value in Knot. /// A new instance. - public static Velocity1D FromKnot(T value) => Create((value * T.CreateChecked(Units.ConversionConstants.KnotToMeterPerSecond))); + public static Velocity1D FromKnot(T value) => Create((value * Units.ConversionConstants.Values.KnotToMeterPerSecond)); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Velocity2D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Velocity2D.g.cs index de91c45..56715ad 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Velocity2D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Velocity2D.g.cs @@ -41,8 +41,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -57,8 +56,7 @@ public T Distance(Velocity2D other) T dX = X - other.X; T dY = Y - other.Y; T sum = (dX * dX) + (dY * dY); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Velocity3D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Velocity3D.g.cs index 3ada42e..f113969 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Velocity3D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Velocity3D.g.cs @@ -47,8 +47,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -70,8 +69,7 @@ public T Distance(Velocity3D other) T dY = Y - other.Y; T dZ = Z - other.Z; T sum = (dX * dX) + (dY * dY) + (dZ * dZ); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Velocity4D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Velocity4D.g.cs index c197cfc..662ff63 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Velocity4D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Velocity4D.g.cs @@ -53,8 +53,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z) + (W * W); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -71,8 +70,7 @@ public T Distance(Velocity4D other) T dZ = Z - other.Z; T dW = W - other.W; T sum = (dX * dX) + (dY * dY) + (dZ * dZ) + (dW * dW); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Voltage.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Voltage.g.cs index 605c799..57c598b 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Voltage.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Voltage.g.cs @@ -109,7 +109,7 @@ namespace ktsu.Semantics.Quantities; /// /// The value in Kilovolt. /// A new instance. - public static Voltage FromKilovolt(T value) => Create((value * T.CreateChecked(MetricMagnitudes.Kilo))); + public static Voltage FromKilovolt(T value) => Create((value * MetricMagnitudes.Values.Kilo)); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VoltageDrop.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VoltageDrop.g.cs index 8304904..efdcfb0 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VoltageDrop.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VoltageDrop.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilovolt. /// A new VoltageDrop instance. /// Thrown when the resulting magnitude would be negative. - public static VoltageDrop FromKilovolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static VoltageDrop FromKilovolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VoltageMagnitude.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VoltageMagnitude.g.cs index c3529c0..d96c284 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VoltageMagnitude.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VoltageMagnitude.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilovolt. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static VoltageMagnitude FromKilovolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static VoltageMagnitude FromKilovolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Volume.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Volume.g.cs index 3c28664..8146e09 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Volume.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Volume.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Liter. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Volume FromLiter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.LiterToCubicMeters)), nameof(value))); + public static Volume FromLiter(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.LiterToCubicMeters), nameof(value))); /// /// Creates a new from a value in Milliliter. @@ -115,7 +115,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Milliliter. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Volume FromMilliliter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static Volume FromMilliliter(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new from a value in CubicCentimeter. @@ -123,7 +123,7 @@ namespace ktsu.Semantics.Quantities; /// The value in CubicCentimeter. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Volume FromCubicCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CubicCentimeterToCubicMeters)), nameof(value))); + public static Volume FromCubicCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.CubicCentimeterToCubicMeters), nameof(value))); /// /// Creates a new from a value in CubicFoot. @@ -131,7 +131,7 @@ namespace ktsu.Semantics.Quantities; /// The value in CubicFoot. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Volume FromCubicFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CubicFootToCubicMeters)), nameof(value))); + public static Volume FromCubicFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.CubicFootToCubicMeters), nameof(value))); /// /// Creates a new from a value in CubicInch. @@ -139,7 +139,7 @@ namespace ktsu.Semantics.Quantities; /// The value in CubicInch. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Volume FromCubicInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CubicInchToCubicMeters)), nameof(value))); + public static Volume FromCubicInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.CubicInchToCubicMeters), nameof(value))); /// /// Creates a new from a value in Gallon. @@ -147,7 +147,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Gallon. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Volume FromGallon(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.GallonToCubicMeters)), nameof(value))); + public static Volume FromGallon(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.GallonToCubicMeters), nameof(value))); /// /// Creates a new from a value in ImperialGallon. @@ -155,7 +155,7 @@ namespace ktsu.Semantics.Quantities; /// The value in ImperialGallon. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Volume FromImperialGallon(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.ImperialGallonToCubicMeters)), nameof(value))); + public static Volume FromImperialGallon(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.ImperialGallonToCubicMeters), nameof(value))); /// /// Creates a new from a value in USQuart. @@ -163,7 +163,7 @@ namespace ktsu.Semantics.Quantities; /// The value in USQuart. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Volume FromUSQuart(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.USQuartToCubicMeters)), nameof(value))); + public static Volume FromUSQuart(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.USQuartToCubicMeters), nameof(value))); /// /// Creates a new from a value in USPint. @@ -171,7 +171,7 @@ namespace ktsu.Semantics.Quantities; /// The value in USPint. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Volume FromUSPint(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.USPintToCubicMeters)), nameof(value))); + public static Volume FromUSPint(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.USPintToCubicMeters), nameof(value))); /// /// Creates a new from a value in USFluidOunce. @@ -179,7 +179,7 @@ namespace ktsu.Semantics.Quantities; /// The value in USFluidOunce. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static Volume FromUSFluidOunce(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.USFluidOunceToCubicMeters)), nameof(value))); + public static Volume FromUSFluidOunce(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.USFluidOunceToCubicMeters), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VolumetricFlowRate.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VolumetricFlowRate.g.cs index 776b7d2..40d3272 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VolumetricFlowRate.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/VolumetricFlowRate.g.cs @@ -107,7 +107,7 @@ namespace ktsu.Semantics.Quantities; /// The value in LiterPerSecond. /// A new instance. /// Thrown when the resulting magnitude would be negative. - public static VolumetricFlowRate FromLiterPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.LiterPerSecondToCubicMeterPerSecond)), nameof(value))); + public static VolumetricFlowRate FromLiterPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.LiterPerSecondToCubicMeterPerSecond), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Wavelength.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Wavelength.g.cs index a2bd8d5..1129548 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Wavelength.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Wavelength.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilometer. /// A new Wavelength instance. /// Thrown when the resulting magnitude would be negative. - public static Wavelength FromKilometer(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Wavelength FromKilometer(T value) => Create(Vector0Guards.EnsurePositive((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new Wavelength from a value in Centimeter. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Centimeter. /// A new Wavelength instance. /// Thrown when the resulting magnitude would be negative. - public static Wavelength FromCentimeter(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(MetricMagnitudes.Centi)), nameof(value))); + public static Wavelength FromCentimeter(T value) => Create(Vector0Guards.EnsurePositive((value * MetricMagnitudes.Values.Centi), nameof(value))); /// /// Creates a new Wavelength from a value in Millimeter. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Millimeter. /// A new Wavelength instance. /// Thrown when the resulting magnitude would be negative. - public static Wavelength FromMillimeter(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static Wavelength FromMillimeter(T value) => Create(Vector0Guards.EnsurePositive((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new Wavelength from a value in Micrometer. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Micrometer. /// A new Wavelength instance. /// Thrown when the resulting magnitude would be negative. - public static Wavelength FromMicrometer(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); + public static Wavelength FromMicrometer(T value) => Create(Vector0Guards.EnsurePositive((value * MetricMagnitudes.Values.Micro), nameof(value))); /// /// Creates a new Wavelength from a value in Nanometer. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Nanometer. /// A new Wavelength instance. /// Thrown when the resulting magnitude would be negative. - public static Wavelength FromNanometer(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); + public static Wavelength FromNanometer(T value) => Create(Vector0Guards.EnsurePositive((value * MetricMagnitudes.Values.Nano), nameof(value))); /// /// Creates a new Wavelength from a value in Angstrom. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Angstrom. /// A new Wavelength instance. /// Thrown when the resulting magnitude would be negative. - public static Wavelength FromAngstrom(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters)), nameof(value))); + public static Wavelength FromAngstrom(T value) => Create(Vector0Guards.EnsurePositive((value * Units.ConversionConstants.Values.AngstromToMeters), nameof(value))); /// /// Creates a new Wavelength from a value in Foot. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Foot. /// A new Wavelength instance. /// Thrown when the resulting magnitude would be negative. - public static Wavelength FromFoot(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters)), nameof(value))); + public static Wavelength FromFoot(T value) => Create(Vector0Guards.EnsurePositive((value * Units.ConversionConstants.Values.FeetToMeters), nameof(value))); /// /// Creates a new Wavelength from a value in Inch. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Inch. /// A new Wavelength instance. /// Thrown when the resulting magnitude would be negative. - public static Wavelength FromInch(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters)), nameof(value))); + public static Wavelength FromInch(T value) => Create(Vector0Guards.EnsurePositive((value * Units.ConversionConstants.Values.InchesToMeters), nameof(value))); /// /// Creates a new Wavelength from a value in Yard. @@ -172,7 +172,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Yard. /// A new Wavelength instance. /// Thrown when the resulting magnitude would be negative. - public static Wavelength FromYard(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(Units.ConversionConstants.YardToMeters)), nameof(value))); + public static Wavelength FromYard(T value) => Create(Vector0Guards.EnsurePositive((value * Units.ConversionConstants.Values.YardToMeters), nameof(value))); /// /// Creates a new Wavelength from a value in Mile. @@ -180,7 +180,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Mile. /// A new Wavelength instance. /// Thrown when the resulting magnitude would be negative. - public static Wavelength FromMile(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(Units.ConversionConstants.MileToMeters)), nameof(value))); + public static Wavelength FromMile(T value) => Create(Vector0Guards.EnsurePositive((value * Units.ConversionConstants.Values.MileToMeters), nameof(value))); /// /// Creates a new Wavelength from a value in NauticalMile. @@ -188,7 +188,7 @@ namespace ktsu.Semantics.Quantities; /// The value in NauticalMile. /// A new Wavelength instance. /// Thrown when the resulting magnitude would be negative. - public static Wavelength FromNauticalMile(T value) => Create(Vector0Guards.EnsurePositive((value * T.CreateChecked(Units.ConversionConstants.NauticalMileToMeters)), nameof(value))); + public static Wavelength FromNauticalMile(T value) => Create(Vector0Guards.EnsurePositive((value * Units.ConversionConstants.Values.NauticalMileToMeters), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Weight.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Weight.g.cs index 13b453b..39a8d92 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Weight.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Weight.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilonewton. /// A new Weight instance. /// Thrown when the resulting magnitude would be negative. - public static Weight FromKilonewton(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Weight FromKilonewton(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new Weight from a value in Dyne. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Dyne. /// A new Weight instance. /// Thrown when the resulting magnitude would be negative. - public static Weight FromDyne(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.DyneToNewtons)), nameof(value))); + public static Weight FromDyne(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.DyneToNewtons), nameof(value))); /// /// Creates a new Weight from a value in PoundForce. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in PoundForce. /// A new Weight instance. /// Thrown when the resulting magnitude would be negative. - public static Weight FromPoundForce(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PoundForceToNewtons)), nameof(value))); + public static Weight FromPoundForce(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PoundForceToNewtons), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/WeightVector.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/WeightVector.g.cs index 2fe88f3..3e45863 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/WeightVector.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/WeightVector.g.cs @@ -44,8 +44,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -67,8 +66,7 @@ public T Distance(WeightVector other) T dY = Y - other.Y; T dZ = Z - other.Z; T sum = (dX * dX) + (dY * dY) + (dZ * dZ); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Width.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Width.g.cs index bb280d7..921f99a 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Width.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Width.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilometer. /// A new Width instance. /// Thrown when the resulting magnitude would be negative. - public static Width FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Width FromKilometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new Width from a value in Centimeter. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Centimeter. /// A new Width instance. /// Thrown when the resulting magnitude would be negative. - public static Width FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Centi)), nameof(value))); + public static Width FromCentimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Centi), nameof(value))); /// /// Creates a new Width from a value in Millimeter. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Millimeter. /// A new Width instance. /// Thrown when the resulting magnitude would be negative. - public static Width FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Milli)), nameof(value))); + public static Width FromMillimeter(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Milli), nameof(value))); /// /// Creates a new Width from a value in Micrometer. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Micrometer. /// A new Width instance. /// Thrown when the resulting magnitude would be negative. - public static Width FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Micro)), nameof(value))); + public static Width FromMicrometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Micro), nameof(value))); /// /// Creates a new Width from a value in Nanometer. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Nanometer. /// A new Width instance. /// Thrown when the resulting magnitude would be negative. - public static Width FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Nano)), nameof(value))); + public static Width FromNanometer(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Nano), nameof(value))); /// /// Creates a new Width from a value in Angstrom. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Angstrom. /// A new Width instance. /// Thrown when the resulting magnitude would be negative. - public static Width FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AngstromToMeters)), nameof(value))); + public static Width FromAngstrom(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AngstromToMeters), nameof(value))); /// /// Creates a new Width from a value in Foot. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Foot. /// A new Width instance. /// Thrown when the resulting magnitude would be negative. - public static Width FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FeetToMeters)), nameof(value))); + public static Width FromFoot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.FeetToMeters), nameof(value))); /// /// Creates a new Width from a value in Inch. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Inch. /// A new Width instance. /// Thrown when the resulting magnitude would be negative. - public static Width FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.InchesToMeters)), nameof(value))); + public static Width FromInch(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.InchesToMeters), nameof(value))); /// /// Creates a new Width from a value in Yard. @@ -172,7 +172,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Yard. /// A new Width instance. /// Thrown when the resulting magnitude would be negative. - public static Width FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.YardToMeters)), nameof(value))); + public static Width FromYard(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.YardToMeters), nameof(value))); /// /// Creates a new Width from a value in Mile. @@ -180,7 +180,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Mile. /// A new Width instance. /// Thrown when the resulting magnitude would be negative. - public static Width FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MileToMeters)), nameof(value))); + public static Width FromMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MileToMeters), nameof(value))); /// /// Creates a new Width from a value in NauticalMile. @@ -188,7 +188,7 @@ namespace ktsu.Semantics.Quantities; /// The value in NauticalMile. /// A new Width instance. /// Thrown when the resulting magnitude would be negative. - public static Width FromNauticalMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.NauticalMileToMeters)), nameof(value))); + public static Width FromNauticalMile(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.NauticalMileToMeters), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/WindSpeed.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/WindSpeed.g.cs index d4f9ed3..780d280 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/WindSpeed.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/WindSpeed.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in KilometerPerHour. /// A new WindSpeed instance. /// Thrown when the resulting magnitude would be negative. - public static WindSpeed FromKilometerPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilometerPerHourToMeterPerSecond)), nameof(value))); + public static WindSpeed FromKilometerPerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilometerPerHourToMeterPerSecond), nameof(value))); /// /// Creates a new WindSpeed from a value in MilePerHour. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in MilePerHour. /// A new WindSpeed instance. /// Thrown when the resulting magnitude would be negative. - public static WindSpeed FromMilePerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.MilePerHourToMeterPerSecond)), nameof(value))); + public static WindSpeed FromMilePerHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.MilePerHourToMeterPerSecond), nameof(value))); /// /// Creates a new WindSpeed from a value in FootPerSecond. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in FootPerSecond. /// A new WindSpeed instance. /// Thrown when the resulting magnitude would be negative. - public static WindSpeed FromFootPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.FootPerSecondToMeterPerSecond)), nameof(value))); + public static WindSpeed FromFootPerSecond(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.FootPerSecondToMeterPerSecond), nameof(value))); /// /// Creates a new WindSpeed from a value in Knot. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Knot. /// A new WindSpeed instance. /// Thrown when the resulting magnitude would be negative. - public static WindSpeed FromKnot(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KnotToMeterPerSecond)), nameof(value))); + public static WindSpeed FromKnot(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KnotToMeterPerSecond), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/WindVelocity3D.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/WindVelocity3D.g.cs index 58f9c6a..d57e9b8 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/WindVelocity3D.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/WindVelocity3D.g.cs @@ -44,8 +44,7 @@ namespace ktsu.Semantics.Quantities; public T Length() { T sum = (X * X) + (Y * Y) + (Z * Z); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared length of the vector. @@ -67,8 +66,7 @@ public T Distance(WindVelocity3D other) T dY = Y - other.Y; T dZ = Z - other.Z; T sum = (dX * dX) + (dY * dY) + (dZ * dZ); - double asDouble = double.CreateChecked(sum); - return T.CreateChecked(Math.Sqrt(asDouble)); + return StorageMath.Sqrt(sum); } /// Calculates the squared distance between two vectors. diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Work.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Work.g.cs index f248ed3..25f2e20 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Work.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/Work.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilojoule. /// A new Work instance. /// Thrown when the resulting magnitude would be negative. - public static Work FromKilojoule(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static Work FromKilojoule(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new Work from a value in ElectronVolt. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in ElectronVolt. /// A new Work instance. /// Thrown when the resulting magnitude would be negative. - public static Work FromElectronVolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.ElectronVoltToJoules)), nameof(value))); + public static Work FromElectronVolt(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.ElectronVoltToJoules), nameof(value))); /// /// Creates a new Work from a value in Calorie. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Calorie. /// A new Work instance. /// Thrown when the resulting magnitude would be negative. - public static Work FromCalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.CalorieToJoules)), nameof(value))); + public static Work FromCalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.CalorieToJoules), nameof(value))); /// /// Creates a new Work from a value in Kilocalorie. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilocalorie. /// A new Work instance. /// Thrown when the resulting magnitude would be negative. - public static Work FromKilocalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilocalorieToJoules)), nameof(value))); + public static Work FromKilocalorie(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilocalorieToJoules), nameof(value))); /// /// Creates a new Work from a value in KilowattHour. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in KilowattHour. /// A new Work instance. /// Thrown when the resulting magnitude would be negative. - public static Work FromKilowattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.KilowattHourToJoules)), nameof(value))); + public static Work FromKilowattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.KilowattHourToJoules), nameof(value))); /// /// Creates a new Work from a value in WattHour. @@ -148,7 +148,7 @@ namespace ktsu.Semantics.Quantities; /// The value in WattHour. /// A new Work instance. /// Thrown when the resulting magnitude would be negative. - public static Work FromWattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.WattHourToJoules)), nameof(value))); + public static Work FromWattHour(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.WattHourToJoules), nameof(value))); /// /// Creates a new Work from a value in Erg. @@ -156,7 +156,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Erg. /// A new Work instance. /// Thrown when the resulting magnitude would be negative. - public static Work FromErg(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.ErgToJoules)), nameof(value))); + public static Work FromErg(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.ErgToJoules), nameof(value))); /// /// Creates a new Work from a value in Btu. @@ -164,7 +164,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Btu. /// A new Work instance. /// Thrown when the resulting magnitude would be negative. - public static Work FromBtu(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.BtuToJoules)), nameof(value))); + public static Work FromBtu(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.BtuToJoules), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/YoungsModulus.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/YoungsModulus.g.cs index 9ac1ba7..84da184 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/YoungsModulus.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.QuantitiesGenerator/YoungsModulus.g.cs @@ -108,7 +108,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Kilopascal. /// A new YoungsModulus instance. /// Thrown when the resulting magnitude would be negative. - public static YoungsModulus FromKilopascal(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(MetricMagnitudes.Kilo)), nameof(value))); + public static YoungsModulus FromKilopascal(T value) => Create(Vector0Guards.EnsureNonNegative((value * MetricMagnitudes.Values.Kilo), nameof(value))); /// /// Creates a new YoungsModulus from a value in Bar. @@ -116,7 +116,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Bar. /// A new YoungsModulus instance. /// Thrown when the resulting magnitude would be negative. - public static YoungsModulus FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.BarToPascals)), nameof(value))); + public static YoungsModulus FromBar(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.BarToPascals), nameof(value))); /// /// Creates a new YoungsModulus from a value in Atmosphere. @@ -124,7 +124,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Atmosphere. /// A new YoungsModulus instance. /// Thrown when the resulting magnitude would be negative. - public static YoungsModulus FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.AtmosphereToPascals)), nameof(value))); + public static YoungsModulus FromAtmosphere(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.AtmosphereToPascals), nameof(value))); /// /// Creates a new YoungsModulus from a value in Psi. @@ -132,7 +132,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Psi. /// A new YoungsModulus instance. /// Thrown when the resulting magnitude would be negative. - public static YoungsModulus FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.PsiToPascals)), nameof(value))); + public static YoungsModulus FromPsi(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.PsiToPascals), nameof(value))); /// /// Creates a new YoungsModulus from a value in Torr. @@ -140,7 +140,7 @@ namespace ktsu.Semantics.Quantities; /// The value in Torr. /// A new YoungsModulus instance. /// Thrown when the resulting magnitude would be negative. - public static YoungsModulus FromTorr(T value) => Create(Vector0Guards.EnsureNonNegative((value * T.CreateChecked(Units.ConversionConstants.TorrToPascals)), nameof(value))); + public static YoungsModulus FromTorr(T value) => Create(Vector0Guards.EnsureNonNegative((value * Units.ConversionConstants.Values.TorrToPascals), nameof(value))); /// /// Converts this quantity's SI-base value to the value in . diff --git a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.UnitsGenerator/Units.g.cs b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.UnitsGenerator/Units.g.cs index b25cf38..6b496ed 100644 --- a/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.UnitsGenerator/Units.g.cs +++ b/Semantics.Quantities/Generated/Semantics.SourceGenerators/Semantics.SourceGenerators.UnitsGenerator/Units.g.cs @@ -31,6 +31,12 @@ public sealed record Meter : IUnit, ILengthUnit /// Initializes a new instance of the unit. public Meter() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -58,6 +64,12 @@ public sealed record Kilometer : IUnit, ILengthUnit /// Initializes a new instance of the unit. public Kilometer() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Kilo; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -85,6 +97,12 @@ public sealed record Centimeter : IUnit, ILengthUnit /// Initializes a new instance of the unit. public Centimeter() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Centi; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -112,6 +130,12 @@ public sealed record Millimeter : IUnit, ILengthUnit /// Initializes a new instance of the unit. public Millimeter() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Milli; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -139,6 +163,12 @@ public sealed record Foot : IUnit, ILengthUnit /// Initializes a new instance of the unit. public Foot() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.FeetToMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -166,6 +196,12 @@ public sealed record Inch : IUnit, ILengthUnit /// Initializes a new instance of the unit. public Inch() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.InchesToMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -193,6 +229,12 @@ public sealed record Micrometer : IUnit, ILengthUnit /// Initializes a new instance of the unit. public Micrometer() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Micro; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -220,6 +262,12 @@ public sealed record Nanometer : IUnit, ILengthUnit /// Initializes a new instance of the unit. public Nanometer() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Nano; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -247,6 +295,12 @@ public sealed record Angstrom : IUnit, ILengthUnit /// Initializes a new instance of the unit. public Angstrom() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.AngstromToMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -274,6 +328,12 @@ public sealed record Yard : IUnit, ILengthUnit /// Initializes a new instance of the unit. public Yard() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.YardToMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -301,6 +361,12 @@ public sealed record Mile : IUnit, ILengthUnit /// Initializes a new instance of the unit. public Mile() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.MileToMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -328,6 +394,12 @@ public sealed record Kilogram : IUnit, IMassUnit /// Initializes a new instance of the unit. public Kilogram() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -355,6 +427,12 @@ public sealed record Gram : IUnit, IMassUnit /// Initializes a new instance of the unit. public Gram() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Milli; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -382,6 +460,12 @@ public sealed record Ton : IUnit, IMassUnit /// Initializes a new instance of the unit. public Ton() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.TonToKilograms; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -409,6 +493,12 @@ public sealed record Pound : IUnit, IMassUnit /// Initializes a new instance of the unit. public Pound() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.PoundToKilograms; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -436,6 +526,12 @@ public sealed record Ounce : IUnit, IMassUnit /// Initializes a new instance of the unit. public Ounce() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.OunceToKilograms; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -463,6 +559,12 @@ public sealed record Second : IUnit, ITimeUnit /// Initializes a new instance of the unit. public Second() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -490,6 +592,12 @@ public sealed record Minute : IUnit, ITimeUnit /// Initializes a new instance of the unit. public Minute() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.MinuteToSeconds; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -517,6 +625,12 @@ public sealed record Hour : IUnit, ITimeUnit /// Initializes a new instance of the unit. public Hour() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.HourToSeconds; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -544,6 +658,12 @@ public sealed record Day : IUnit, ITimeUnit /// Initializes a new instance of the unit. public Day() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.DayToSeconds; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -571,6 +691,12 @@ public sealed record Year : IUnit, ITimeUnit /// Initializes a new instance of the unit. public Year() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.YearToSeconds; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -598,6 +724,12 @@ public sealed record Millisecond : IUnit, ITimeUnit /// Initializes a new instance of the unit. public Millisecond() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Milli; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -625,6 +757,12 @@ public sealed record Microsecond : IUnit, ITimeUnit /// Initializes a new instance of the unit. public Microsecond() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Micro; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -652,6 +790,12 @@ public sealed record SquareMeter : IUnit, IAreaUnit, INuclearCrossSectionUnit /// Initializes a new instance of the unit. public SquareMeter() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -679,6 +823,12 @@ public sealed record SquareFoot : IUnit, IAreaUnit /// Initializes a new instance of the unit. public SquareFoot() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.SquareFootToSquareMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -706,6 +856,12 @@ public sealed record SquareInch : IUnit, IAreaUnit /// Initializes a new instance of the unit. public SquareInch() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.SquareInchToSquareMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -733,6 +889,12 @@ public sealed record CubicMeter : IUnit, IVolumeUnit /// Initializes a new instance of the unit. public CubicMeter() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -760,6 +922,12 @@ public sealed record Liter : IUnit, IVolumeUnit /// Initializes a new instance of the unit. public Liter() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.LiterToCubicMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -787,6 +955,12 @@ public sealed record Milliliter : IUnit, IVolumeUnit /// Initializes a new instance of the unit. public Milliliter() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Milli; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -814,6 +988,12 @@ public sealed record Gallon : IUnit, IVolumeUnit /// Initializes a new instance of the unit. public Gallon() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.GallonToCubicMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -841,6 +1021,12 @@ public sealed record Dimensionless : IUnit, IDimensionlessUnit /// Initializes a new instance of the unit. public Dimensionless() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -868,6 +1054,12 @@ public sealed record Radian : IUnit, IDimensionlessUnit, IAngularDisplacementUni /// Initializes a new instance of the unit. public Radian() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -895,6 +1087,12 @@ public sealed record Degree : IUnit, IDimensionlessUnit, IAngularDisplacementUni /// Initializes a new instance of the unit. public Degree() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.DegreeToRadians; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -922,6 +1120,12 @@ public sealed record NauticalMile : IUnit, ILengthUnit /// Initializes a new instance of the unit. public NauticalMile() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.NauticalMileToMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -949,6 +1153,12 @@ public sealed record Stone : IUnit, IMassUnit /// Initializes a new instance of the unit. public Stone() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.StoneToKilograms; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -976,6 +1186,12 @@ public sealed record ShortTon : IUnit, IMassUnit /// Initializes a new instance of the unit. public ShortTon() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.ShortTonToKilograms; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1003,6 +1219,12 @@ public sealed record AtomicMassUnit : IUnit, IMassUnit /// Initializes a new instance of the unit. public AtomicMassUnit() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.AtomicMassUnitToKilograms; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1030,6 +1252,12 @@ public sealed record Week : IUnit, ITimeUnit /// Initializes a new instance of the unit. public Week() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.WeekToSeconds; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1057,6 +1285,12 @@ public sealed record Nanosecond : IUnit, ITimeUnit /// Initializes a new instance of the unit. public Nanosecond() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Nano; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1084,6 +1318,12 @@ public sealed record SquareKilometer : IUnit, IAreaUnit /// Initializes a new instance of the unit. public SquareKilometer() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.SquareKilometerToSquareMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1111,6 +1351,12 @@ public sealed record SquareCentimeter : IUnit, IAreaUnit /// Initializes a new instance of the unit. public SquareCentimeter() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.SquareCentimeterToSquareMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1138,6 +1384,12 @@ public sealed record SquareMile : IUnit, IAreaUnit /// Initializes a new instance of the unit. public SquareMile() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.SquareMileToSquareMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1165,6 +1417,12 @@ public sealed record Hectare : IUnit, IAreaUnit /// Initializes a new instance of the unit. public Hectare() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.HectareToSquareMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1192,6 +1450,12 @@ public sealed record Acre : IUnit, IAreaUnit /// Initializes a new instance of the unit. public Acre() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.AcreToSquareMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1219,6 +1483,12 @@ public sealed record CubicCentimeter : IUnit, IVolumeUnit /// Initializes a new instance of the unit. public CubicCentimeter() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.CubicCentimeterToCubicMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1246,6 +1516,12 @@ public sealed record CubicFoot : IUnit, IVolumeUnit /// Initializes a new instance of the unit. public CubicFoot() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.CubicFootToCubicMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1273,6 +1549,12 @@ public sealed record CubicInch : IUnit, IVolumeUnit /// Initializes a new instance of the unit. public CubicInch() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.CubicInchToCubicMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1300,6 +1582,12 @@ public sealed record ImperialGallon : IUnit, IVolumeUnit /// Initializes a new instance of the unit. public ImperialGallon() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.ImperialGallonToCubicMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1327,6 +1615,12 @@ public sealed record USQuart : IUnit, IVolumeUnit /// Initializes a new instance of the unit. public USQuart() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.USQuartToCubicMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1354,6 +1648,12 @@ public sealed record USPint : IUnit, IVolumeUnit /// Initializes a new instance of the unit. public USPint() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.USPintToCubicMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1381,6 +1681,12 @@ public sealed record USFluidOunce : IUnit, IVolumeUnit /// Initializes a new instance of the unit. public USFluidOunce() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.USFluidOunceToCubicMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1408,6 +1714,12 @@ public sealed record Gradian : IUnit, IDimensionlessUnit, IAngularDisplacementUn /// Initializes a new instance of the unit. public Gradian() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.GradianToRadians; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1435,6 +1747,12 @@ public sealed record Revolution : IUnit, IDimensionlessUnit, IAngularDisplacemen /// Initializes a new instance of the unit. public Revolution() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.RevolutionToRadians; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1462,6 +1780,12 @@ public sealed record Milliradian : IUnit, IDimensionlessUnit, IAngularDisplaceme /// Initializes a new instance of the unit. public Milliradian() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Milli; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1489,6 +1813,12 @@ public sealed record Percent : IUnit, IDimensionlessUnit /// Initializes a new instance of the unit. public Percent() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.PercentToRatio; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1516,6 +1846,12 @@ public sealed record PartPerMillion : IUnit, IDimensionlessUnit /// Initializes a new instance of the unit. public PartPerMillion() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.PartPerMillionToRatio; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1543,6 +1879,12 @@ public sealed record PartPerBillion : IUnit, IDimensionlessUnit /// Initializes a new instance of the unit. public PartPerBillion() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.PartPerBillionToRatio; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1570,6 +1912,12 @@ public sealed record PercentByWeight : IUnit, IDimensionlessUnit /// Initializes a new instance of the unit. public PercentByWeight() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.PercentByWeightToRatio; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1597,6 +1945,12 @@ public sealed record Newton : IUnit, IForceUnit /// Initializes a new instance of the unit. public Newton() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1624,6 +1978,12 @@ public sealed record Pascal : IUnit, IPressureUnit /// Initializes a new instance of the unit. public Pascal() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1651,6 +2011,12 @@ public sealed record MeterPerSecond : IUnit, IVelocityUnit /// Initializes a new instance of the unit. public MeterPerSecond() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1678,6 +2044,12 @@ public sealed record MeterPerSecondSquared : IUnit, IAccelerationUnit /// Initializes a new instance of the unit. public MeterPerSecondSquared() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1705,6 +2077,12 @@ public sealed record Bar : IUnit, IPressureUnit /// Initializes a new instance of the unit. public Bar() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.BarToPascals; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1732,6 +2110,12 @@ public sealed record Atmosphere : IUnit, IPressureUnit /// Initializes a new instance of the unit. public Atmosphere() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.AtmosphereToPascals; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1759,6 +2143,12 @@ public sealed record Psi : IUnit, IPressureUnit /// Initializes a new instance of the unit. public Psi() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.PsiToPascals; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1786,6 +2176,12 @@ public sealed record KilometerPerHour : IUnit, IVelocityUnit /// Initializes a new instance of the unit. public KilometerPerHour() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.KilometerPerHourToMeterPerSecond; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1813,6 +2209,12 @@ public sealed record MilePerHour : IUnit, IVelocityUnit /// Initializes a new instance of the unit. public MilePerHour() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.MilePerHourToMeterPerSecond; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1840,6 +2242,12 @@ public sealed record Joule : IUnit, IEnergyUnit /// Initializes a new instance of the unit. public Joule() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1867,6 +2275,12 @@ public sealed record Watt : IUnit, IPowerUnit /// Initializes a new instance of the unit. public Watt() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1894,6 +2308,12 @@ public sealed record Calorie : IUnit, IEnergyUnit /// Initializes a new instance of the unit. public Calorie() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.CalorieToJoules; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1921,6 +2341,12 @@ public sealed record KilowattHour : IUnit, IEnergyUnit /// Initializes a new instance of the unit. public KilowattHour() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.KilowattHourToJoules; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1948,6 +2374,12 @@ public sealed record Horsepower : IUnit, IPowerUnit /// Initializes a new instance of the unit. public Horsepower() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.HorsepowerToWatts; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -1975,6 +2407,12 @@ public sealed record NewtonSecond : IUnit, IMomentumUnit /// Initializes a new instance of the unit. public NewtonSecond() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2002,6 +2440,12 @@ public sealed record ElectronVolt : IUnit, IEnergyUnit /// Initializes a new instance of the unit. public ElectronVolt() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.ElectronVoltToJoules; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2029,6 +2473,12 @@ public sealed record NewtonMeter : IUnit, ITorqueUnit /// Initializes a new instance of the unit. public NewtonMeter() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2056,6 +2506,12 @@ public sealed record PoundFoot : IUnit, ITorqueUnit /// Initializes a new instance of the unit. public PoundFoot() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.PoundFootToNewtonMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2083,6 +2539,12 @@ public sealed record KilogramMeterSquared : IUnit, IMomentOfInertiaUnit /// Initializes a new instance of the unit. public KilogramMeterSquared() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2110,6 +2572,12 @@ public sealed record KilogramMeterSquaredPerSecond : IUnit, IAngularMomentumUnit /// Initializes a new instance of the unit. public KilogramMeterSquaredPerSecond() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2137,6 +2605,12 @@ public sealed record MeterPerSecondCubed : IUnit, IJerkUnit /// Initializes a new instance of the unit. public MeterPerSecondCubed() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2164,6 +2638,12 @@ public sealed record MeterPerSecondQuartic : IUnit, ISnapUnit /// Initializes a new instance of the unit. public MeterPerSecondQuartic() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2191,6 +2671,12 @@ public sealed record FootPerSecond : IUnit, IVelocityUnit /// Initializes a new instance of the unit. public FootPerSecond() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.FootPerSecondToMeterPerSecond; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2218,6 +2704,12 @@ public sealed record Knot : IUnit, IVelocityUnit /// Initializes a new instance of the unit. public Knot() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.KnotToMeterPerSecond; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2245,6 +2737,12 @@ public sealed record StandardGravity : IUnit, IAccelerationUnit /// Initializes a new instance of the unit. public StandardGravity() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.StandardGravityToMeterPerSecondSquared; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2272,6 +2770,12 @@ public sealed record Kilonewton : IUnit, IForceUnit /// Initializes a new instance of the unit. public Kilonewton() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Kilo; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2299,6 +2803,12 @@ public sealed record Dyne : IUnit, IForceUnit /// Initializes a new instance of the unit. public Dyne() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.DyneToNewtons; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2326,6 +2836,12 @@ public sealed record PoundForce : IUnit, IForceUnit /// Initializes a new instance of the unit. public PoundForce() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.PoundForceToNewtons; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2353,6 +2869,12 @@ public sealed record Kilopascal : IUnit, IPressureUnit /// Initializes a new instance of the unit. public Kilopascal() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Kilo; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2380,6 +2902,12 @@ public sealed record Torr : IUnit, IPressureUnit /// Initializes a new instance of the unit. public Torr() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.TorrToPascals; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2407,6 +2935,12 @@ public sealed record Kilojoule : IUnit, IEnergyUnit /// Initializes a new instance of the unit. public Kilojoule() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Kilo; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2434,6 +2968,12 @@ public sealed record Kilocalorie : IUnit, IEnergyUnit /// Initializes a new instance of the unit. public Kilocalorie() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.KilocalorieToJoules; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2461,6 +3001,12 @@ public sealed record WattHour : IUnit, IEnergyUnit /// Initializes a new instance of the unit. public WattHour() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.WattHourToJoules; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2488,6 +3034,12 @@ public sealed record Erg : IUnit, IEnergyUnit /// Initializes a new instance of the unit. public Erg() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.ErgToJoules; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2515,6 +3067,12 @@ public sealed record Btu : IUnit, IEnergyUnit /// Initializes a new instance of the unit. public Btu() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.BtuToJoules; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2542,6 +3100,12 @@ public sealed record Kilowatt : IUnit, IPowerUnit /// Initializes a new instance of the unit. public Kilowatt() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Kilo; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2569,6 +3133,12 @@ public sealed record Megawatt : IUnit, IPowerUnit /// Initializes a new instance of the unit. public Megawatt() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Mega; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2596,6 +3166,12 @@ public sealed record WattPerCubicMeter : IUnit, IElectricPowerDensityUnit /// Initializes a new instance of the unit. public WattPerCubicMeter() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2623,6 +3199,12 @@ public sealed record Kelvin : IUnit, ITemperatureUnit /// Initializes a new instance of the unit. public Kelvin() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2650,6 +3232,12 @@ public sealed record Celsius : IUnit, ITemperatureUnit /// Initializes a new instance of the unit. public Celsius() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => ConversionConstants.Values.CelsiusToKelvinOffset; } /// @@ -2677,6 +3265,12 @@ public sealed record Fahrenheit : IUnit, ITemperatureUnit /// Initializes a new instance of the unit. public Fahrenheit() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.FahrenheitScale; + + /// + T IUnit.ToBaseOffsetAs() => ConversionConstants.Values.FahrenheitToKelvinOffset; } /// @@ -2704,6 +3298,12 @@ public sealed record JoulePerKelvin : IUnit, IEntropyUnit /// Initializes a new instance of the unit. public JoulePerKelvin() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2731,6 +3331,12 @@ public sealed record JoulePerKilogramKelvin : IUnit, ISpecificHeatUnit /// Initializes a new instance of the unit. public JoulePerKilogramKelvin() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2758,6 +3364,12 @@ public sealed record WattPerMeterKelvin : IUnit, IThermalConductivityUnit /// Initializes a new instance of the unit. public WattPerMeterKelvin() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2785,6 +3397,12 @@ public sealed record WattPerSquareMeterKelvin : IUnit, IHeatTransferCoefficientU /// Initializes a new instance of the unit. public WattPerSquareMeterKelvin() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2812,6 +3430,12 @@ public sealed record PerKelvin : IUnit, IThermalExpansionUnit /// Initializes a new instance of the unit. public PerKelvin() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2839,6 +3463,12 @@ public sealed record Rankine : IUnit, ITemperatureUnit /// Initializes a new instance of the unit. public Rankine() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.FahrenheitScale; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2866,6 +3496,12 @@ public sealed record KelvinPerWatt : IUnit, IThermalResistanceUnit /// Initializes a new instance of the unit. public KelvinPerWatt() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2893,6 +3529,12 @@ public sealed record Ampere : IUnit, IElectricCurrentUnit /// Initializes a new instance of the unit. public Ampere() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2920,6 +3562,12 @@ public sealed record Volt : IUnit, IElectricPotentialUnit /// Initializes a new instance of the unit. public Volt() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2947,6 +3595,12 @@ public sealed record VoltPerMeter : IUnit, IElectricFieldUnit /// Initializes a new instance of the unit. public VoltPerMeter() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -2974,6 +3628,12 @@ public sealed record Ohm : IUnit, IElectricResistanceUnit /// Initializes a new instance of the unit. public Ohm() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3001,6 +3661,12 @@ public sealed record Coulomb : IUnit, IElectricChargeUnit /// Initializes a new instance of the unit. public Coulomb() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3028,6 +3694,12 @@ public sealed record Farad : IUnit, IElectricCapacitanceUnit /// Initializes a new instance of the unit. public Farad() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3055,6 +3727,12 @@ public sealed record Siemens : IUnit, IElectricConductanceUnit /// Initializes a new instance of the unit. public Siemens() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3082,6 +3760,12 @@ public sealed record Tesla : IUnit, IMagneticFluxDensityUnit /// Initializes a new instance of the unit. public Tesla() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3109,6 +3793,12 @@ public sealed record Gauss : IUnit, IMagneticFluxDensityUnit /// Initializes a new instance of the unit. public Gauss() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.GaussToTesla; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3136,6 +3826,12 @@ public sealed record Weber : IUnit, IMagneticFluxUnit /// Initializes a new instance of the unit. public Weber() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3163,6 +3859,12 @@ public sealed record Henry : IUnit, IInductanceUnit /// Initializes a new instance of the unit. public Henry() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3190,6 +3892,12 @@ public sealed record Milliampere : IUnit, IElectricCurrentUnit /// Initializes a new instance of the unit. public Milliampere() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Milli; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3217,6 +3925,12 @@ public sealed record Kiloampere : IUnit, IElectricCurrentUnit /// Initializes a new instance of the unit. public Kiloampere() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Kilo; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3244,6 +3958,12 @@ public sealed record Kilovolt : IUnit, IElectricPotentialUnit /// Initializes a new instance of the unit. public Kilovolt() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Kilo; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3271,6 +3991,12 @@ public sealed record Kilohm : IUnit, IElectricResistanceUnit /// Initializes a new instance of the unit. public Kilohm() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Kilo; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3298,6 +4024,12 @@ public sealed record Megohm : IUnit, IElectricResistanceUnit /// Initializes a new instance of the unit. public Megohm() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Mega; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3325,6 +4057,12 @@ public sealed record Microfarad : IUnit, IElectricCapacitanceUnit /// Initializes a new instance of the unit. public Microfarad() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Micro; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3352,6 +4090,12 @@ public sealed record Nanofarad : IUnit, IElectricCapacitanceUnit /// Initializes a new instance of the unit. public Nanofarad() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Nano; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3379,6 +4123,12 @@ public sealed record Picofarad : IUnit, IElectricCapacitanceUnit /// Initializes a new instance of the unit. public Picofarad() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Pico; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3406,6 +4156,12 @@ public sealed record AmpereHour : IUnit, IElectricChargeUnit /// Initializes a new instance of the unit. public AmpereHour() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.AmpereHourToCoulombs; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3433,6 +4189,12 @@ public sealed record VoltMeter : IUnit, IElectricFluxUnit /// Initializes a new instance of the unit. public VoltMeter() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3460,6 +4222,12 @@ public sealed record FaradPerMeter : IUnit, IPermittivityUnit /// Initializes a new instance of the unit. public FaradPerMeter() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3487,6 +4255,12 @@ public sealed record SiemensPerMeter : IUnit, IElectricConductivityUnit /// Initializes a new instance of the unit. public SiemensPerMeter() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3514,6 +4288,12 @@ public sealed record VoltPerPascal : IUnit, ISensitivityUnit /// Initializes a new instance of the unit. public VoltPerPascal() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3541,6 +4321,12 @@ public sealed record RadianPerSecond : IUnit, IAngularVelocityUnit /// Initializes a new instance of the unit. public RadianPerSecond() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3568,6 +4354,12 @@ public sealed record RevolutionPerMinute : IUnit, IAngularVelocityUnit /// Initializes a new instance of the unit. public RevolutionPerMinute() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.RevolutionPerMinuteToRadianPerSecond; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3595,6 +4387,12 @@ public sealed record RadianPerSecondSquared : IUnit, IAngularAccelerationUnit /// Initializes a new instance of the unit. public RadianPerSecondSquared() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3622,6 +4420,12 @@ public sealed record RadianPerSecondCubed : IUnit, IAngularJerkUnit /// Initializes a new instance of the unit. public RadianPerSecondCubed() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3649,6 +4453,12 @@ public sealed record Hertz : IUnit, IFrequencyUnit /// Initializes a new instance of the unit. public Hertz() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3676,6 +4486,12 @@ public sealed record Kilohertz : IUnit, IFrequencyUnit /// Initializes a new instance of the unit. public Kilohertz() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Kilo; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3703,6 +4519,12 @@ public sealed record Megahertz : IUnit, IFrequencyUnit /// Initializes a new instance of the unit. public Megahertz() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Mega; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3730,6 +4552,12 @@ public sealed record Sone : IUnit, ILoudnessUnit /// Initializes a new instance of the unit. public Sone() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3757,6 +4585,12 @@ public sealed record Acum : IUnit, ISharpnessUnit /// Initializes a new instance of the unit. public Acum() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3784,6 +4618,12 @@ public sealed record Candela : IUnit, ILuminousIntensityUnit /// Initializes a new instance of the unit. public Candela() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3811,6 +4651,12 @@ public sealed record Lumen : IUnit, ILuminousFluxUnit /// Initializes a new instance of the unit. public Lumen() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3838,6 +4684,12 @@ public sealed record Lux : IUnit, IIlluminanceUnit /// Initializes a new instance of the unit. public Lux() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3865,6 +4717,12 @@ public sealed record Diopter : IUnit, IOpticalPowerUnit /// Initializes a new instance of the unit. public Diopter() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3892,6 +4750,12 @@ public sealed record Millicandela : IUnit, ILuminousIntensityUnit /// Initializes a new instance of the unit. public Millicandela() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Milli; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3919,6 +4783,12 @@ public sealed record FootCandle : IUnit, IIlluminanceUnit /// Initializes a new instance of the unit. public FootCandle() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.FootCandleToLux; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3946,6 +4816,12 @@ public sealed record CandelaPerSquareMeter : IUnit, ILuminanceUnit /// Initializes a new instance of the unit. public CandelaPerSquareMeter() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -3973,6 +4849,12 @@ public sealed record Nit : IUnit, ILuminanceUnit /// Initializes a new instance of the unit. public Nit() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4000,6 +4882,12 @@ public sealed record FootLambert : IUnit, ILuminanceUnit /// Initializes a new instance of the unit. public FootLambert() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.FootLambertToCandelaPerSquareMeter; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4027,6 +4915,12 @@ public sealed record Becquerel : IUnit, IRadioactiveActivityUnit /// Initializes a new instance of the unit. public Becquerel() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4054,6 +4948,12 @@ public sealed record Gray : IUnit, IAbsorbedDoseUnit /// Initializes a new instance of the unit. public Gray() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4081,6 +4981,12 @@ public sealed record Sievert : IUnit, IEquivalentDoseUnit /// Initializes a new instance of the unit. public Sievert() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4108,6 +5014,12 @@ public sealed record Barn : IUnit, INuclearCrossSectionUnit /// Initializes a new instance of the unit. public Barn() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.BarnToSquareMeters; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4135,6 +5047,12 @@ public sealed record CoulombPerKilogram : IUnit, IExposureUnit /// Initializes a new instance of the unit. public CoulombPerKilogram() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4162,6 +5080,12 @@ public sealed record Curie : IUnit, IRadioactiveActivityUnit /// Initializes a new instance of the unit. public Curie() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.CurieToBecquerels; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4189,6 +5113,12 @@ public sealed record Rad : IUnit, IAbsorbedDoseUnit /// Initializes a new instance of the unit. public Rad() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.RadToGrays; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4216,6 +5146,12 @@ public sealed record Rem : IUnit, IEquivalentDoseUnit /// Initializes a new instance of the unit. public Rem() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.RemToSieverts; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4243,6 +5179,12 @@ public sealed record Roentgen : IUnit, IExposureUnit /// Initializes a new instance of the unit. public Roentgen() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.RoentgenToCoulombsPerKilogram; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4270,6 +5212,12 @@ public sealed record KilogramPerCubicMeter : IUnit, IDensityUnit /// Initializes a new instance of the unit. public KilogramPerCubicMeter() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4297,6 +5245,12 @@ public sealed record GramPerCubicCentimeter : IUnit, IDensityUnit /// Initializes a new instance of the unit. public GramPerCubicCentimeter() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.GramPerCubicCentimeterToKilogramPerCubicMeter; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4324,6 +5278,12 @@ public sealed record GramPerLiter : IUnit, IDensityUnit /// Initializes a new instance of the unit. public GramPerLiter() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.GramPerLiterToKilogramPerCubicMeter; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4351,6 +5311,12 @@ public sealed record Mole : IUnit, IAmountOfSubstanceUnit /// Initializes a new instance of the unit. public Mole() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4378,6 +5344,12 @@ public sealed record MolePerCubicMeter : IUnit, IConcentrationUnit /// Initializes a new instance of the unit. public MolePerCubicMeter() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4405,6 +5377,12 @@ public sealed record Molar : IUnit, IConcentrationUnit /// Initializes a new instance of the unit. public Molar() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.MolarToCubicMeter; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4432,6 +5410,12 @@ public sealed record Kilomole : IUnit, IAmountOfSubstanceUnit /// Initializes a new instance of the unit. public Kilomole() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Kilo; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4459,6 +5443,12 @@ public sealed record Millimole : IUnit, IAmountOfSubstanceUnit /// Initializes a new instance of the unit. public Millimole() { } + + /// + T IUnit.ToBaseFactorAs() => MetricMagnitudes.Values.Milli; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4486,6 +5476,12 @@ public sealed record Millimolar : IUnit, IConcentrationUnit /// Initializes a new instance of the unit. public Millimolar() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.MillimolarToMolePerCubicMeter; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4513,6 +5509,12 @@ public sealed record Micromolar : IUnit, IConcentrationUnit /// Initializes a new instance of the unit. public Micromolar() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.MicromolarToMolePerCubicMeter; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4540,6 +5542,12 @@ public sealed record SquareMeterPerSecond : IUnit, IKinematicViscosityUnit /// Initializes a new instance of the unit. public SquareMeterPerSecond() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4567,6 +5575,12 @@ public sealed record Stokes : IUnit, IKinematicViscosityUnit /// Initializes a new instance of the unit. public Stokes() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.StokesToSquareMeterPerSecond; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4594,6 +5608,12 @@ public sealed record PascalSecond : IUnit, IDynamicViscosityUnit /// Initializes a new instance of the unit. public PascalSecond() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4621,6 +5641,12 @@ public sealed record Poise : IUnit, IDynamicViscosityUnit /// Initializes a new instance of the unit. public Poise() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.PoiseToPascalSecond; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4648,6 +5674,12 @@ public sealed record CubicMeterPerSecond : IUnit, IVolumetricFlowRateUnit /// Initializes a new instance of the unit. public CubicMeterPerSecond() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4675,6 +5707,12 @@ public sealed record LiterPerSecond : IUnit, IVolumetricFlowRateUnit /// Initializes a new instance of the unit. public LiterPerSecond() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.LiterPerSecondToCubicMeterPerSecond; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4702,6 +5740,12 @@ public sealed record KilogramPerSecond : IUnit, IMassFlowRateUnit /// Initializes a new instance of the unit. public KilogramPerSecond() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4729,6 +5773,12 @@ public sealed record NewtonPerMeter : IUnit, ISurfaceTensionUnit /// Initializes a new instance of the unit. public NewtonPerMeter() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4756,6 +5806,12 @@ public sealed record Centipoise : IUnit, IDynamicViscosityUnit /// Initializes a new instance of the unit. public Centipoise() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.CentipoiseToPascalSecond; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4783,6 +5839,12 @@ public sealed record DynePerCentimeter : IUnit, ISurfaceTensionUnit /// Initializes a new instance of the unit. public DynePerCentimeter() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.DynePerCentimeterToNewtonPerMeter; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4810,6 +5872,12 @@ public sealed record KilogramPerMole : IUnit, IMolarMassUnit /// Initializes a new instance of the unit. public KilogramPerMole() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4837,6 +5905,12 @@ public sealed record GramPerMole : IUnit, IMolarMassUnit /// Initializes a new instance of the unit. public GramPerMole() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.GramPerMoleToKilogramPerMole; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4864,6 +5938,12 @@ public sealed record Katal : IUnit, ICatalyticActivityUnit /// Initializes a new instance of the unit. public Katal() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4891,6 +5971,12 @@ public sealed record MolePerCubicMeterSecond : IUnit, IReactionRateUnit /// Initializes a new instance of the unit. public MolePerCubicMeterSecond() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4918,6 +6004,12 @@ public sealed record JoulePerMole : IUnit, IMolarEnergyUnit /// Initializes a new instance of the unit. public JoulePerMole() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4945,6 +6037,12 @@ public sealed record KilojoulePerMole : IUnit, IMolarEnergyUnit /// Initializes a new instance of the unit. public KilojoulePerMole() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.KilojoulePerMoleToJoulePerMole; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4972,6 +6070,12 @@ public sealed record CaloriePerMole : IUnit, IMolarEnergyUnit /// Initializes a new instance of the unit. public CaloriePerMole() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.CaloriePerMoleToJoulePerMole; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -4999,6 +6103,12 @@ public sealed record EnzymeUnit : IUnit, ICatalyticActivityUnit /// Initializes a new instance of the unit. public EnzymeUnit() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.EnzymeUnitToKatals; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -5026,6 +6136,12 @@ public sealed record Dalton : IUnit, IMolarMassUnit /// Initializes a new instance of the unit. public Dalton() { } + + /// + T IUnit.ToBaseFactorAs() => ConversionConstants.Values.GramPerMoleToKilogramPerMole; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -5053,6 +6169,12 @@ public sealed record PerSecond : IUnit, IRateConstantUnit /// Initializes a new instance of the unit. public PerSecond() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -5080,6 +6202,12 @@ public sealed record WattPerSquareMeter : IUnit, IIrradianceUnit /// Initializes a new instance of the unit. public WattPerSquareMeter() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// @@ -5107,6 +6235,12 @@ public sealed record PascalSecondPerMeter : IUnit, IAcousticImpedanceUnit /// Initializes a new instance of the unit. public PascalSecondPerMeter() { } + + /// + T IUnit.ToBaseFactorAs() => T.One; + + /// + T IUnit.ToBaseOffsetAs() => T.Zero; } /// diff --git a/Semantics.Quantities/IUnit.cs b/Semantics.Quantities/IUnit.cs index 4c687d8..483e4bb 100644 --- a/Semantics.Quantities/IUnit.cs +++ b/Semantics.Quantities/IUnit.cs @@ -22,6 +22,13 @@ namespace ktsu.Semantics.Quantities; /// ToBase / FromBase are default-implemented; concrete units only /// have to provide and . /// +/// +/// The conversion itself reads and , +/// not the properties. Their default implementations convert those properties, +/// so a unit written outside this library behaves as it always did. The generated units override +/// them with the factor materialised directly into the storage type, which is what gives a +/// quantity all 28 of its digits. +/// /// public interface IUnit { @@ -43,11 +50,27 @@ public interface IUnit /// Gets the additive offset used in the to-base affine conversion. public double ToBaseOffset { get; } + /// + /// Gets the multiplication factor used in the to-base affine conversion, at the precision of a storage type. + /// + /// The numeric storage type. + /// The factor as . By default, converted with T.CreateChecked. + public T ToBaseFactorAs() where T : struct, INumber + => T.CreateChecked(ToBaseFactor); + + /// + /// Gets the additive offset used in the to-base affine conversion, at the precision of a storage type. + /// + /// The numeric storage type. + /// The offset as . By default, converted with T.CreateChecked. + public T ToBaseOffsetAs() where T : struct, INumber + => T.CreateChecked(ToBaseOffset); + /// Converts a value expressed in this unit to the dimension's SI base unit. public T ToBase(T value) where T : struct, INumber - => (value * T.CreateChecked(ToBaseFactor)) + T.CreateChecked(ToBaseOffset); + => (value * ToBaseFactorAs()) + ToBaseOffsetAs(); /// Converts a value expressed in the dimension's SI base unit to this unit. public T FromBase(T baseValue) where T : struct, INumber - => (baseValue - T.CreateChecked(ToBaseOffset)) / T.CreateChecked(ToBaseFactor); + => (baseValue - ToBaseOffsetAs()) / ToBaseFactorAs(); } diff --git a/Semantics.Quantities/StorageLiteral.cs b/Semantics.Quantities/StorageLiteral.cs new file mode 100644 index 0000000..c2f41d6 --- /dev/null +++ b/Semantics.Quantities/StorageLiteral.cs @@ -0,0 +1,66 @@ +// Copyright (c) 2023-2026 ktsu-dev contributors + +namespace ktsu.Semantics.Quantities; + +using System.Globalization; +using System.Numerics; + +/// +/// Materialises a metadata literal into a storage type at that type's own precision, for the +/// conversion factors and metric magnitudes the generated code caches per closed generic type. +/// +/// +/// +/// A factor used to reach a storage type through T.CreateChecked(double), so every type +/// inherited the rounding of , and kept only the 15 +/// significant digits that conversion preserves. Parsing the literal gives each type the nearest +/// value it can represent, and a fraction is divided in the storage type itself. +/// +/// +/// An integer storage type keeps the old route. Parsing "0.3048" into an +/// fails, and dividing 5 by 9 in one answers zero for a different reason than truncating 0.5555… +/// does, so integers convert the exactly as they did before. A type that +/// cannot parse the literal falls back the same way. +/// +/// +internal static class StorageLiteral +{ + /// + /// Converts a decimal literal to . + /// + /// The numeric storage type. + /// The literal as written in the metadata, for example "0.3048" or "1e-10". + /// The same value as a , used when is an integer or cannot parse the literal. + /// The nearest value represents. + internal static T Parse(string literal, double fallback) + where T : struct, INumber + => !IsIntegral() && T.TryParse(literal, NumberStyles.Float, CultureInfo.InvariantCulture, out T value) + ? value + : T.CreateChecked(fallback); + + /// + /// Converts an exact fraction of two decimal literals to , dividing in . + /// + /// The numeric storage type. + /// The numerator literal, for example "5". + /// The denominator literal, for example "9". + /// The quotient as a , used when is an integer or cannot parse either literal. + /// The quotient at the precision divides to. + internal static T Divide(string numerator, string denominator, double fallback) + where T : struct, INumber + => !IsIntegral() + && T.TryParse(numerator, NumberStyles.Float, CultureInfo.InvariantCulture, out T dividend) + && T.TryParse(denominator, NumberStyles.Float, CultureInfo.InvariantCulture, out T divisor) + && !T.IsZero(divisor) + ? dividend / divisor + : T.CreateChecked(fallback); + + /// + /// Reports whether discards fractions, which is to say whether a half is zero in it. + /// + /// The numeric storage type. + /// when one divided by two is zero in . + private static bool IsIntegral() + where T : struct, INumber + => T.IsZero(T.One / (T.One + T.One)); +} diff --git a/Semantics.Quantities/StorageMath.cs b/Semantics.Quantities/StorageMath.cs new file mode 100644 index 0000000..ee30546 --- /dev/null +++ b/Semantics.Quantities/StorageMath.cs @@ -0,0 +1,156 @@ +// Copyright (c) 2023-2026 ktsu-dev contributors + +namespace ktsu.Semantics.Quantities; + +using System; +using System.Numerics; + +/// +/// Numeric operations the generated quantities need that does not declare. +/// +internal static class StorageMath +{ + /// + /// The most Newton steps taken before the current estimate is returned as it stands. + /// + /// + /// From a seed each step roughly doubles the number of correct digits, so a + /// handful suffice. The cap matters only when no seed could be taken and the estimate starts at + /// the value itself, where the early steps halve it rather than refine it. + /// + private const int MaximumIterations = 256; + + /// + /// Computes the square root of a storage value at the precision of its type. + /// + /// The numeric storage type. + /// The value to take the root of. Generated callers pass a sum of squares, which is never negative. + /// The square root of . + /// + /// is negative and cannot represent the that results. + /// + /// + /// + /// The binary floating point and integer primitives take the route every generated + /// Length() and Distance() took before this helper existed, a round trip through + /// , so their results are unchanged. For them that route is + /// already as precise as the type. + /// + /// + /// Any other type is refined in its own arithmetic: seeded from that same + /// root, then Newton steps x = (x + value / x) / 2 until the estimate stops changing. A + /// root therefore has 28 significant digits rather than the 15 its + /// conversion from keeps, and no constraint beyond + /// is needed, which could not meet had this required + /// . + /// + /// + /// A negative input keeps its old behaviour too, where the type has + /// one and an exception where it does not. + /// + /// + internal static T Sqrt(T value) + where T : struct, INumber + { + if (IsRoundedThroughDouble() || T.IsNegative(value)) + { + return T.CreateChecked(Math.Sqrt(double.CreateChecked(value))); + } + + if (T.IsZero(value)) + { + return T.Zero; + } + + T two = T.One + T.One; + T estimate = Seed(value); + T previous = estimate; + + for (int iteration = 0; iteration < MaximumIterations; iteration++) + { + T next = (estimate + (value / estimate)) / two; + + if (next == estimate) + { + return next; + } + + // Rounding can leave the estimate alternating between two neighbours instead of settling. + if (next == previous) + { + return T.Min(estimate, next); + } + + previous = estimate; + estimate = next; + } + + return estimate; + } + + /// + /// Reports whether is one of the primitives whose square root has always + /// been taken through . + /// + /// The numeric storage type. + /// for the binary floating point and integer primitives. + /// + /// Written as comparisons because the JIT folds them for a value type, + /// so each specialisation of compiles down to one of its two branches. + /// + private static bool IsRoundedThroughDouble() + where T : struct, INumber + => typeof(T) == typeof(double) + || typeof(T) == typeof(float) + || typeof(T) == typeof(Half) + || typeof(T) == typeof(byte) + || typeof(T) == typeof(sbyte) + || typeof(T) == typeof(short) + || typeof(T) == typeof(ushort) + || typeof(T) == typeof(int) + || typeof(T) == typeof(uint) + || typeof(T) == typeof(long) + || typeof(T) == typeof(ulong) + || typeof(T) == typeof(nint) + || typeof(T) == typeof(nuint) + || typeof(T) == typeof(Int128) + || typeof(T) == typeof(UInt128); + + /// + /// Chooses the first Newton estimate for a positive value. + /// + /// The numeric storage type. + /// The positive value whose root is wanted. + /// The root converted to when both conversions succeed, otherwise the larger of and one. + /// + /// Any positive start converges, because Newton's method for a square root approaches from above + /// after its first step. The fallback exists for a type that will not convert to or from + /// , or whose value is outside its range. + /// + private static T Seed(T value) + where T : struct, INumber + { + try + { + double root = Math.Sqrt(double.CreateChecked(value)); + if (double.IsFinite(root) && root > 0d) + { + T seed = T.CreateChecked(root); + if (!T.IsZero(seed)) + { + return seed; + } + } + } + catch (NotSupportedException) + { + // The type does not convert through double. The fallback below still converges. + } + catch (OverflowException) + { + // The value or its root is outside the range of double or of the type. The fallback below still converges. + } + + return value > T.One ? value : T.One; + } +} diff --git a/Semantics.SourceGenerators/AnalyzerReleases.Unshipped.md b/Semantics.SourceGenerators/AnalyzerReleases.Unshipped.md index ce1074b..ed61c58 100644 --- a/Semantics.SourceGenerators/AnalyzerReleases.Unshipped.md +++ b/Semantics.SourceGenerators/AnalyzerReleases.Unshipped.md @@ -13,3 +13,4 @@ SEM005 | Semantics.SourceGenerators | Warning | Reports schema-level validation SEM006 | Semantics.SourceGenerators | Warning | Reports a metadata file a generator declared that was not supplied as an AdditionalFile. SEM007 | Semantics.SourceGenerators | Error | Reports a metadata file that could not be parsed. Replaces the base generator's CONV001. SEM008 | Semantics.SourceGenerators | Warning | Reports a relationship whose declared result does not follow from the dimensions of its operands, or whose signed value cannot land in a magnitude result. +SEM009 | Semantics.SourceGenerators | Error | Reports a conversions.json factor whose value is neither a decimal literal nor a fraction of two decimal literals with a non-zero denominator. diff --git a/Semantics.SourceGenerators/Generators/ConversionValue.cs b/Semantics.SourceGenerators/Generators/ConversionValue.cs new file mode 100644 index 0000000..2f3d6d4 --- /dev/null +++ b/Semantics.SourceGenerators/Generators/ConversionValue.cs @@ -0,0 +1,162 @@ +// Copyright (c) 2023-2026 ktsu-dev contributors + +namespace Semantics.SourceGenerators; + +/// +/// The value of one conversion factor in conversions.json: a decimal literal, or an exact +/// fraction of two decimal literals. +/// +/// +/// A repeating ratio such as 5/9 has no finite decimal literal, so writing it as one rounds it before +/// any storage type sees it. Keeping the fraction lets each storage type divide at its own precision: +/// gets the correctly rounded quotient, and gets 28 digits +/// rather than the 17 a -length literal carried. +/// +/// The literal, or the numerator of the fraction. +/// The denominator of the fraction, or for a plain literal. +internal sealed class ConversionValue(string numerator, string? denominator) +{ + /// Gets the literal, or the numerator of the fraction. + public string Numerator { get; } = numerator; + + /// Gets the denominator of the fraction, or for a plain literal. + public string? Denominator { get; } = denominator; + + /// + /// Gets a C# constant expression of type for the value. + /// + /// + /// A plain literal is written exactly as the metadata spells it, so the committed constants for + /// existing factors do not change. Each operand of a fraction carries a d suffix, because + /// 5 / 9 would be integer division and evaluate to zero. + /// + public string DoubleExpression => Denominator is null + ? Numerator + : $"{Numerator}d / {Denominator}d"; + + /// + /// Builds the expression that materialises the value into the storage type T. + /// + /// An expression for the same value as a , for storage types that cannot parse it. + /// A call to StorageLiteral.Parse or StorageLiteral.Divide. + public string StorageExpression(string fallback) => Denominator is null + ? $"StorageLiteral.Parse(\"{Numerator}\", {fallback})" + : $"StorageLiteral.Divide(\"{Numerator}\", \"{Denominator}\", {fallback})"; + + /// + /// Reads a factor value, accepting a decimal literal such as "0.3048" or "1e-10", or a + /// fraction of two such as "5/9". + /// + /// The value as written in the metadata. + /// The value, or when is neither form or the denominator is zero. + public static ConversionValue? Parse(string? text) + { + if (text is null) + { + return null; + } + + int slash = text.IndexOf('/'); + if (slash < 0) + { + return IsDecimalLiteral(text) ? new ConversionValue(text, null) : null; + } + + string top = text.Substring(0, slash); + string bottom = text.Substring(slash + 1); + + return IsDecimalLiteral(top) && IsDecimalLiteral(bottom) && !IsZero(bottom) + ? new ConversionValue(top, bottom) + : null; + } + + /// + /// Reports whether is a decimal literal that is valid both in C# and in + /// Parse with NumberStyles.Float: an optional sign, digits with an optional + /// fractional part, and an optional exponent. + /// + /// The candidate literal. + /// when has that shape. + private static bool IsDecimalLiteral(string text) + { + int index = 0; + if (index < text.Length && (text[index] == '+' || text[index] == '-')) + { + index++; + } + + int integerDigits = CountDigits(text, ref index); + int fractionDigits = 0; + + if (index < text.Length && text[index] == '.') + { + index++; + fractionDigits = CountDigits(text, ref index); + if (fractionDigits == 0) + { + return false; + } + } + + if (integerDigits + fractionDigits == 0) + { + return false; + } + + if (index < text.Length && (text[index] == 'e' || text[index] == 'E')) + { + index++; + if (index < text.Length && (text[index] == '+' || text[index] == '-')) + { + index++; + } + + if (CountDigits(text, ref index) == 0) + { + return false; + } + } + + return index == text.Length; + } + + /// + /// Advances past a run of ASCII digits. + /// + /// The text being scanned. + /// The position to start at, moved to the first character that is not a digit. + /// The number of digits passed. + private static int CountDigits(string text, ref int index) + { + int start = index; + while (index < text.Length && text[index] >= '0' && text[index] <= '9') + { + index++; + } + + return index - start; + } + + /// + /// Reports whether a decimal literal is zero, which is to say whether every digit of its significand is zero. + /// + /// A literal that accepted. + /// when the literal denotes zero. + private static bool IsZero(string literal) + { + foreach (char character in literal) + { + if (character is 'e' or 'E') + { + break; + } + + if (character is >= '1' and <= '9') + { + return false; + } + } + + return true; + } +} diff --git a/Semantics.SourceGenerators/Generators/ConversionsGenerator.cs b/Semantics.SourceGenerators/Generators/ConversionsGenerator.cs index e2a0fe0..725b18c 100644 --- a/Semantics.SourceGenerators/Generators/ConversionsGenerator.cs +++ b/Semantics.SourceGenerators/Generators/ConversionsGenerator.cs @@ -12,9 +12,34 @@ namespace Semantics.SourceGenerators; /// /// Source generator that creates the ConversionConstants.cs file from JSON metadata. /// +/// +/// +/// Each factor is emitted twice. The constant backs the public +/// IUnit.ToBaseFactor and ToBaseOffset properties. The nested Values<T> +/// holder materialises the same literal into each storage type once, the way +/// does for constants, and that is what the generated +/// factories and In(unit) read. Before the holder existed they reached every storage type +/// through T.CreateChecked(double), so a quantity converted with 15 +/// significant digits of a 17-digit literal. +/// +/// +/// A value is a decimal literal or an exact fraction of two, "5/9". Anything else is reported +/// as SEM009 and generates no constant. +/// +/// [Generator] public class ConversionsGenerator : SemanticsGenerator { + /// + /// Name of the nested holder that caches each factor materialised into a storage type. + /// + private const string HolderName = "Values"; + + /// + /// Constraint carried by the holder, matching the one on every generated quantity. + /// + private const string NumericConstraint = "where T : struct, INumber"; + public ConversionsGenerator() : base("conversions.json") { } protected override void Generate(SourceProductionContext context, ConversionsMetadata metadata, CodeBlocker codeBlocker) @@ -28,6 +53,10 @@ protected override void Generate(SourceProductionContext context, ConversionsMet { FileName = "ConversionConstants.g.cs", Namespace = "ktsu.Semantics.Quantities.Units", + Usings = + { + "System.Numerics", + }, }; ClassTemplate constantsClass = new() @@ -48,10 +77,35 @@ protected override void Generate(SourceProductionContext context, ConversionsMet Name = "ConversionConstants", }; + ClassTemplate holderClass = new() + { + Comments = + { + Emit.SummaryOpen, + "/// Caches each conversion constant materialised into at that type's own precision.", + Emit.SummaryClose, + }, + Kind = TypeKind.Class, + Keywords = + { + "internal", + Emit.Static, + }, + Name = $"{HolderName}", + Constraints = {NumericConstraint}, + }; + foreach (ConversionCategory category in metadata.Conversions) { foreach (ConversionFactor factor in category.Factors) { + ConversionValue? value = ConversionValue.Parse(factor.Value); + if (value is null) + { + context.Report(SemanticsDiagnostics.InvalidConversionFactor, factor.Name, factor.Value); + continue; + } + constantsClass.Members.Add(new FieldTemplate() { Comments = @@ -65,11 +119,34 @@ protected override void Generate(SourceProductionContext context, ConversionsMet "double", }, Name = factor.Name, - DefaultValue = factor.Value, + DefaultValue = value.DoubleExpression, + }); + + // Qualified, because inside the holder the bare name is the field being declared. + holderClass.Members.Add(new FieldTemplate() + { + Comments = + { + $"/// {factor.Description}", + }, + Keywords = + { + "internal", + Emit.Static, + "readonly", + "T", + }, + Name = factor.Name, + DefaultValue = value.StorageExpression($"ConversionConstants.{factor.Name}"), }); } } + if (holderClass.Members.Count > 0) + { + constantsClass.NestedClasses.Add(holderClass); + } + sourceFileTemplate.Classes.Add(constantsClass); WriteSourceFileTo(codeBlocker, sourceFileTemplate); diff --git a/Semantics.SourceGenerators/Generators/MagnitudesGenerator.cs b/Semantics.SourceGenerators/Generators/MagnitudesGenerator.cs index 8afdb8a..2627598 100644 --- a/Semantics.SourceGenerators/Generators/MagnitudesGenerator.cs +++ b/Semantics.SourceGenerators/Generators/MagnitudesGenerator.cs @@ -12,6 +12,12 @@ namespace Semantics.SourceGenerators; /// /// Source generator that creates the MetricMagnitudes.cs file from JSON metadata. /// +/// +/// The public constants are unchanged. Alongside them an internal +/// Values<T> holder parses each power of ten into each storage type once, which is what +/// the generated factories multiply by. A such as 1e-2 is not exactly a +/// hundredth, and converting it gave a quantity its rounding. +/// [Generator] public class MagnitudesGenerator : SemanticsGenerator { @@ -28,6 +34,10 @@ protected override void Generate(SourceProductionContext context, MagnitudesMeta { FileName = "MetricMagnitudes.g.cs", Namespace = "ktsu.Semantics.Quantities", + Usings = + { + "System.Numerics", + }, }; ClassTemplate magnitudesClass = new() @@ -43,6 +53,20 @@ protected override void Generate(SourceProductionContext context, MagnitudesMeta Name = "MetricMagnitudes", }; + ClassTemplate holderClass = new() + { + Comments = + { + Emit.SummaryOpen, + "/// Caches each magnitude materialised into at that type's own precision.", + Emit.SummaryClose, + }, + Kind = TypeKind.Class, + Keywords = {"internal", Emit.Static}, + Name = "Values", + Constraints = {"where T : struct, INumber"}, + }; + foreach (MagnitudeDefinition magnitude in metadata.Magnitudes) { string valueString = magnitude.Exponent switch @@ -51,15 +75,27 @@ protected override void Generate(SourceProductionContext context, MagnitudesMeta _ => $"1e{magnitude.Exponent}", }; + string comment = $"/// {magnitude.Name} magnitude ({magnitude.Symbol}): 10^{magnitude.Exponent}"; + magnitudesClass.Members.Add(new FieldTemplate() { - Comments = {$"/// {magnitude.Name} magnitude ({magnitude.Symbol}): 10^{magnitude.Exponent}"}, + Comments = {comment}, Keywords = {Emit.Public, "const", "double"}, Name = magnitude.Name, DefaultValue = valueString, }); + + // Qualified, because inside the holder the bare name is the field being declared. + holderClass.Members.Add(new FieldTemplate() + { + Comments = {comment}, + Keywords = {"internal", Emit.Static, "readonly", "T"}, + Name = magnitude.Name, + DefaultValue = $"StorageLiteral.Parse(\"{valueString}\", MetricMagnitudes.{magnitude.Name})", + }); } + magnitudesClass.NestedClasses.Add(holderClass); sourceFileTemplate.Classes.Add(magnitudesClass); WriteSourceFileTo(codeBlocker, sourceFileTemplate); diff --git a/Semantics.SourceGenerators/Generators/QuantitiesGenerator.cs b/Semantics.SourceGenerators/Generators/QuantitiesGenerator.cs index bf46291..3d6d615 100644 --- a/Semantics.SourceGenerators/Generators/QuantitiesGenerator.cs +++ b/Semantics.SourceGenerators/Generators/QuantitiesGenerator.cs @@ -635,6 +635,12 @@ private static void AddUnitFactories( /// base unit. Honours magnitude (Kilo, Centi, …), conversionFactor (lookup in /// ), and offset (additive, after scaling). /// + /// + /// Each factor is read from the Values<T> holder that + /// and emit, which parses the metadata literal into the storage + /// type once. It used to be T.CreateChecked of the constant, which + /// capped every storage type at the precision of . + /// private static string BuildToBaseExpression(string unitName, IReadOnlyDictionary unitMap) { // If we don't have unit metadata, fall back to identity. The dimensions.json author is @@ -652,17 +658,17 @@ private static string BuildToBaseExpression(string unitName, IReadOnlyDictionary if (hasMagnitude) { - scaled = $"(value * T.CreateChecked(MetricMagnitudes.{unit.Magnitude}))"; + scaled = $"(value * MetricMagnitudes.Values.{unit.Magnitude})"; } else if (hasFactor) { - scaled = $"(value * T.CreateChecked(Units.ConversionConstants.{unit.ConversionFactor}))"; + scaled = $"(value * Units.ConversionConstants.Values.{unit.ConversionFactor})"; } bool hasOffset = !string.IsNullOrEmpty(unit.Offset) && unit.Offset != "0"; if (hasOffset) { - scaled = $"({scaled} + T.CreateChecked(Units.ConversionConstants.{unit.Offset}))"; + scaled = $"({scaled} + Units.ConversionConstants.Values.{unit.Offset})"; } return scaled; @@ -1597,8 +1603,7 @@ private static void WriteVectorMethods(CodeBlocker cb, string fullType, string[] using (new Scope(cb)) { cb.WriteLine($"T sum = {sumOfSquares};"); - cb.WriteLine("double asDouble = double.CreateChecked(sum);"); - cb.WriteLine("return T.CreateChecked(Math.Sqrt(asDouble));"); + cb.WriteLine("return StorageMath.Sqrt(sum);"); } cb.NewLine(); @@ -1635,8 +1640,7 @@ private static void WriteVectorMethods(CodeBlocker cb, string fullType, string[] string distSum = string.Join(" + ", components.Select(c => $"(d{c} * d{c})")); cb.WriteLine($"T sum = {distSum};"); - cb.WriteLine("double asDouble = double.CreateChecked(sum);"); - cb.WriteLine("return T.CreateChecked(Math.Sqrt(asDouble));"); + cb.WriteLine("return StorageMath.Sqrt(sum);"); } cb.NewLine(); diff --git a/Semantics.SourceGenerators/Generators/UnitsGenerator.cs b/Semantics.SourceGenerators/Generators/UnitsGenerator.cs index acc1ce5..fa93bef 100644 --- a/Semantics.SourceGenerators/Generators/UnitsGenerator.cs +++ b/Semantics.SourceGenerators/Generators/UnitsGenerator.cs @@ -166,9 +166,10 @@ private static ClassTemplate BuildUnitClass(UnitDefinition unit, List di } string factorExpr = BuildToBaseFactorExpression(unit); - string offsetExpr = string.IsNullOrEmpty(unit.Offset) || unit.Offset == "0" - ? "0d" - : unit.Offset; + bool hasOffset = !string.IsNullOrEmpty(unit.Offset) && unit.Offset != "0"; + string offsetExpr = hasOffset ? unit.Offset : "0d"; + string storageFactorExpr = BuildStorageFactorExpression(unit); + string storageOffsetExpr = hasOffset ? $"ConversionConstants.Values.{unit.Offset}" : "T.Zero"; string dimensionExpr = ReportedDimension(dims, withoutExponents) is string reported ? $"PhysicalDimensions.{reported}" : "null!"; @@ -228,6 +229,22 @@ private static ClassTemplate BuildUnitClass(UnitDefinition unit, List di Keywords = {Emit.Public, "double"}, Name = $"ToBaseOffset => {offsetExpr}", }, + // Explicit, so the unit's own surface is unchanged: these exist for IUnit.ToBase and + // FromBase to read, and they give each storage type the factor at its own precision. + new MethodTemplate() + { + Comments = {"/// "}, + Keywords = {"T"}, + Name = "IUnit.ToBaseFactorAs", + BodyFactory = (body) => body.Write($"=> {storageFactorExpr};"), + }, + new MethodTemplate() + { + Comments = {"/// "}, + Keywords = {"T"}, + Name = "IUnit.ToBaseOffsetAs", + BodyFactory = (body) => body.Write($"=> {storageOffsetExpr};"), + }, }, }.WithInterfaces(interfaces); } @@ -293,4 +310,36 @@ private static string BuildToBaseFactorExpression(UnitDefinition unit) return "1d"; } + + /// + /// Builds the expression for the unit's to-base multiplication factor in the storage type T, + /// folding magnitude and conversion factor the same way does. + /// + /// + /// Reads the Values<T> holders, which parse each metadata literal into the storage + /// type once, so a conversion is not limited by the + /// constant the public ToBaseFactor property returns. + /// + private static string BuildStorageFactorExpression(UnitDefinition unit) + { + bool hasMagnitude = !string.IsNullOrEmpty(unit.Magnitude) && unit.Magnitude != "1"; + bool hasFactor = !string.IsNullOrEmpty(unit.ConversionFactor) && unit.ConversionFactor != "1"; + + if (hasMagnitude && hasFactor) + { + return $"MetricMagnitudes.Values.{unit.Magnitude} * ConversionConstants.Values.{unit.ConversionFactor}"; + } + + if (hasMagnitude) + { + return $"MetricMagnitudes.Values.{unit.Magnitude}"; + } + + if (hasFactor) + { + return $"ConversionConstants.Values.{unit.ConversionFactor}"; + } + + return "T.One"; + } } diff --git a/Semantics.SourceGenerators/Metadata/conversions.json b/Semantics.SourceGenerators/Metadata/conversions.json index 38ceff1..4bf1eb9 100644 --- a/Semantics.SourceGenerators/Metadata/conversions.json +++ b/Semantics.SourceGenerators/Metadata/conversions.json @@ -170,13 +170,13 @@ }, { "name": "FahrenheitScale", - "description": "Fahrenheit-to-Kelvin degree scale factor: 5/9 (exact)", - "value": "0.5555555555555556" + "description": "Fahrenheit-to-Kelvin degree scale factor: 5/9 K/°F (exact, stored as a fraction)", + "value": "5/9" }, { "name": "FahrenheitToKelvinOffset", - "description": "Fahrenheit to Kelvin affine offset: 459.67 × 5/9 ≈ 255.372 K (exact)", - "value": "255.37222222222223" + "description": "Fahrenheit to Kelvin affine offset: 459.67 × 5/9 = 45967/180 ≈ 255.372 K (exact, stored as a fraction)", + "value": "45967/180" } ] }, @@ -191,13 +191,13 @@ }, { "name": "GradianToRadians", - "description": "Gradian to radian conversion: π/200 rad/grad (exact)", - "value": "0.015707963267948966" + "description": "Gradian to radian conversion: π/200 rad/grad (π to 150 significant digits, taken as DegreeToRadians × 180)", + "value": "0.0157079632679489661923132169163975144209858469968755291048747229615390820314310449931401741267105876411909366360292356011914856685250059698650262847" }, { "name": "RevolutionToRadians", - "description": "Revolution to radian conversion: 2π rad/rev (exact)", - "value": "6.283185307179586" + "description": "Revolution to radian conversion: 2π rad/rev (π to 150 significant digits, taken as DegreeToRadians × 180)", + "value": "6.28318530717958647692528676655900576839433879875021164194988918461563281257241799725606965068423505647637465441169424047659426741000238794601051388" } ] }, @@ -217,8 +217,8 @@ }, { "name": "HorsepowerToWatts", - "description": "Mechanical horsepower to watt conversion: 745.6998715822702 W/hp (exact)", - "value": "745.6998715822702" + "description": "Mechanical horsepower to watt conversion: 550 ft⋅lbf/s = 550 × 0.3048 × 4.4482216152605 = 745.69987158227022 W/hp (exact)", + "value": "745.69987158227022" }, { "name": "ElectronVoltToJoules", @@ -263,13 +263,13 @@ }, { "name": "PsiToPascals", - "description": "PSI to pascal conversion: 6894.757293168361 Pa/psi (exact)", - "value": "6894.757293168361" + "description": "PSI to pascal conversion: 4.4482216152605 N / 0.0254² m² = 8896443230521/1290320000 Pa/psi, written to 150 significant digits (a literal rather than the fraction, because float storage rounds that numerator before dividing)", + "value": "6894.75729316836133672267344534689069378138756277512555025110050220100440200880401760803521607043214086428172856345712691425382850765701531403062806126" }, { "name": "TorrToPascals", - "description": "Torr to pascal conversion: 101325/760 ≈ 133.322 Pa/Torr (exact)", - "value": "133.32236842105263" + "description": "Torr to pascal conversion: 101325/760 = 20265/152 Pa/Torr (exact, stored as a fraction)", + "value": "20265/152" } ] }, @@ -325,8 +325,8 @@ "factors": [ { "name": "KilometerPerHourToMeterPerSecond", - "description": "Kilometers per hour to meters per second conversion: 0.2777777777777778 m/s per km/h (exact)", - "value": "0.2777777777777778" + "description": "Kilometers per hour to meters per second conversion: 1000/3600 = 5/18 m/s per km/h (exact, stored as a fraction)", + "value": "5/18" }, { "name": "MilePerHourToMeterPerSecond", @@ -340,8 +340,8 @@ }, { "name": "KnotToMeterPerSecond", - "description": "Knot to meters per second: 1852/3600 ≈ 0.514444 m/s per kn (exact)", - "value": "0.5144444444444445" + "description": "Knot to meters per second: 1852/3600 = 463/900 m/s per kn (exact, stored as a fraction)", + "value": "463/900" } ] }, @@ -351,8 +351,8 @@ "factors": [ { "name": "RevolutionPerMinuteToRadianPerSecond", - "description": "RPM to rad/s conversion: π/30 rad/s per rpm (exact)", - "value": "0.10471975511965977" + "description": "RPM to rad/s conversion: 2π/60 = π/30 rad/s per rpm (π to 150 significant digits, taken as DegreeToRadians × 180)", + "value": "0.104719755119659774615421446109316762806572313312503527365831486410260546876206966620934494178070584274606244240194904007943237790166706465766841898" } ] }, @@ -466,8 +466,8 @@ }, { "name": "EnzymeUnitToKatals", - "description": "Enzyme unit (1 μmol/min) to katal: 1/6e7 ≈ 1.6667e-8 kat/U (exact)", - "value": "1.6666666666666667e-8" + "description": "Enzyme unit (1 μmol/min) to katal: 1e-6/60 = 1/60000000 kat/U (exact, stored as a fraction)", + "value": "1/60000000" } ] }, @@ -530,13 +530,13 @@ "factors": [ { "name": "FootCandleToLux", - "description": "Foot-candle to lux conversion: 1/0.09290304 ≈ 10.7639 lx/fc (exact)", - "value": "10.763910416709722" + "description": "Foot-candle to lux conversion: 1 lm/ft² = 1/0.09290304 = 100000000/9290304 lx/fc (exact, stored as a fraction)", + "value": "100000000/9290304" }, { "name": "FootLambertToCandelaPerSquareMeter", - "description": "Foot-lambert to candela per square meter: 1/(π·0.09290304) ≈ 3.4263 cd/m² per fL (exact)", - "value": "3.4262590996353905" + "description": "Foot-lambert to candela per square meter: 1/(π × 0.09290304) cd/m² per fL (π to 150 significant digits, taken as DegreeToRadians × 180)", + "value": "3.42625909963539052691674596165021859423458362052428959800814578422615229026362399099348746319287426200971476339509417994666710818534309005070458689906" } ] }, diff --git a/Semantics.SourceGenerators/Metadata/precision.json b/Semantics.SourceGenerators/Metadata/precision.json index af873e2..0b0e7db 100644 --- a/Semantics.SourceGenerators/Metadata/precision.json +++ b/Semantics.SourceGenerators/Metadata/precision.json @@ -1,6 +1,7 @@ { "storageTypes": [ "float", - "double" + "double", + "decimal" ] } diff --git a/Semantics.SourceGenerators/SemanticsDiagnostics.cs b/Semantics.SourceGenerators/SemanticsDiagnostics.cs index c3bd29b..60328a2 100644 --- a/Semantics.SourceGenerators/SemanticsDiagnostics.cs +++ b/Semantics.SourceGenerators/SemanticsDiagnostics.cs @@ -105,4 +105,18 @@ public static class SemanticsDiagnostics 8, "Physics relationship does not follow from the dimensions of its operands", "Relationship {0} {1} No operator is generated for it; fix dimensions.json."); + + /// + /// SEM009: a conversion factor's value is neither a decimal literal nor a fraction of two. + /// + /// + /// A factor is emitted as a C# constant and parsed into every storage type, so a value that is + /// neither form would otherwise surface as a compile error in generated code, far from the line in + /// conversions.json that caused it. An error rather than a warning, because every unit using + /// the factor fails to compile without its constant. + /// + public static DiagnosticDescriptor InvalidConversionFactor { get; } = Catalog.Error( + 9, + "conversions.json factor value is malformed", + "Conversion factor '{0}' has value '{1}', which is neither a decimal literal such as \"0.3048\" nor a fraction of two such as \"5/9\" with a non-zero denominator. No constant is generated for it. Fix conversions.json."); } diff --git a/Semantics.Test/Quantities/GeneratorDiagnosticTests.cs b/Semantics.Test/Quantities/GeneratorDiagnosticTests.cs index b788a02..342cde0 100644 --- a/Semantics.Test/Quantities/GeneratorDiagnosticTests.cs +++ b/Semantics.Test/Quantities/GeneratorDiagnosticTests.cs @@ -392,6 +392,100 @@ public void Sem007_IsReportedForASecondMetadataFileThatIsMalformed() AssertReports(diagnostics, "SEM007"); } + /// + /// A conversions document with one factor whose value the test chooses. + /// + /// The factor's value, exactly as it would be written in the file. + /// The document. + private static string ConversionsDocument(string value) => + $$""" + { + "conversions": [ + { + "category": "Test", + "description": "A category.", + "factors": [ { "name": "Factor", "description": "A factor.", "value": "{{value}}" } ] + } + ] + } + """; + + /// + /// SEM009 fires for a value that is neither a decimal literal nor a fraction of two. + /// + /// A malformed value. + /// + /// Each of these would otherwise become a C# constant or a Parse call that fails far from + /// the metadata: an empty operand, a zero denominator, a second slash, a trailing space, a name, + /// and a trailing decimal point, which C# does not accept as a literal. + /// + [TestMethod] + [DataRow("5/")] + [DataRow("/9")] + [DataRow("1/0")] + [DataRow("1/0.0e5")] + [DataRow("1/2/3")] + [DataRow("0.3048 ")] + [DataRow("pi")] + [DataRow("1.")] + [DataRow("1e")] + [DataRow("")] + public void Sem009_IsReportedForAConversionValueThatIsNeitherALiteralNorAFraction(string value) => + AssertReports(Run(ConversionsDocument(value), new ConversionsGenerator(), "conversions.json"), "SEM009"); + + /// + /// Every shape of value the metadata uses, or is meant to be able to use, passes. + /// + /// A well-formed value. + [TestMethod] + [DataRow("0.3048")] + [DataRow("1e-10")] + [DataRow("3.7e10")] + [DataRow("1000.0")] + [DataRow("-273.15")] + [DataRow("5/9")] + [DataRow("4.4482216152605/0.00064516")] + [DataRow("1e-6/60")] + public void Sem009_IsNotReportedForAWellFormedConversionValue(string value) + { + IReadOnlyList diagnostics = Run(ConversionsDocument(value), new ConversionsGenerator(), "conversions.json"); + + Assert.IsEmpty(diagnostics.Where(static diagnostic => diagnostic.Id == "SEM009")); + } + + /// + /// A fraction reaches the double constant as a division of two double literals, and each storage + /// type as a division in that type, rather than as a literal rounded before either sees it. + /// + [TestMethod] + public void AFractionIsDividedInTheStorageTypeRatherThanRoundedFirst() + { + GeneratorRunResult result = Harness.Run( + new ConversionsGenerator(), + new Dictionary { ["conversions.json"] = ConversionsDocument("5/9") }); + + string source = result.GeneratedSources.Single().SourceText.ToString(); + + Assert.Contains("internal const double Factor = 5d / 9d;", source); + Assert.Contains("StorageLiteral.Divide(\"5\", \"9\", ConversionConstants.Factor)", source); + } + + /// + /// A plain literal is written into the double constant exactly as the metadata spells it, and parsed into each storage type. + /// + [TestMethod] + public void ALiteralIsParsedIntoTheStorageType() + { + GeneratorRunResult result = Harness.Run( + new ConversionsGenerator(), + new Dictionary { ["conversions.json"] = ConversionsDocument("0.3048") }); + + string source = result.GeneratedSources.Single().SourceText.ToString(); + + Assert.Contains("internal const double Factor = 0.3048;", source); + Assert.Contains("StorageLiteral.Parse(\"0.3048\", ConversionConstants.Factor)", source); + } + /// /// The real metadata reports nothing except the relationships it is already known to get wrong. /// diff --git a/Semantics.Test/Quantities/QuantityValueTypeTests.cs b/Semantics.Test/Quantities/QuantityValueTypeTests.cs index cb3c150..9b38ca2 100644 --- a/Semantics.Test/Quantities/QuantityValueTypeTests.cs +++ b/Semantics.Test/Quantities/QuantityValueTypeTests.cs @@ -64,6 +64,7 @@ public void QuantityArithmeticDoesNotAllocate() Assert.AreEqual(0L, MeasureAllocation(() => (a * 2.0).Value), "scaling allocated"); Assert.AreEqual(0L, MeasureAllocation(() => Length.FromMeter(3.0).Value), "a base-unit factory allocated"); Assert.AreEqual(0L, MeasureAllocation(() => Length.FromFoot(3.0).Value), "a converting factory allocated"); + Assert.AreEqual(0L, MeasureAllocation(() => Length.FromMeter(3.0).In(ktsu.Semantics.Quantities.Units.Units.Foot)), "converting to a unit allocated"); Assert.AreEqual(0L, MeasureAllocation(() => (a / t).Value), "a cross-dimensional operator allocated"); } diff --git a/Semantics.Test/Quantities/StorageConversionTests.cs b/Semantics.Test/Quantities/StorageConversionTests.cs new file mode 100644 index 0000000..d8b6831 --- /dev/null +++ b/Semantics.Test/Quantities/StorageConversionTests.cs @@ -0,0 +1,208 @@ +// Copyright (c) 2023-2026 ktsu-dev contributors + +namespace ktsu.Semantics.Test.Quantities; + +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Numerics; +using System.Reflection; +using ktsu.Semantics.Quantities; +using ktsu.Semantics.Quantities.Units; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +/// +/// Runs over . +/// +[TestClass] +public sealed class DoubleStorageConversionTests() : StorageConversionTests(tolerance: "1e-14", decimalExact: false); + +/// +/// Runs over , where every terminating answer is exact. +/// +[TestClass] +public sealed class DecimalStorageConversionTests() : StorageConversionTests(tolerance: "1e-25", decimalExact: true); + +/// +/// The same unit conversions, physics relationships and vector lengths, run over each storage type. +/// +/// The storage type under test. +/// +/// The largest relative error accepted where the answer does not terminate in , +/// as a literal. For it is far below the 15 significant digits a factor kept when +/// it reached the type through , so a regression to that route fails. +/// +/// +/// Whether represents a terminating decimal exactly, as +/// does and does not. Where it does, a terminating answer is asserted exactly. +/// +/// +/// Adding a storage type is one line: a sealed derived class like the two above. +/// +public abstract class StorageConversionTests(string tolerance, bool decimalExact) + where T : struct, INumber +{ + private readonly T relativeTolerance = Of(tolerance); + + [TestMethod] + public void AFootIsTwelveInches() + { + Length foot = Length.FromFoot(T.One); + + AssertValue("0.3048", foot.Value, terminates: true); + AssertValue("12", foot.In(Units.Inch), terminates: true); + } + + [TestMethod] + public void KilometersPerHourConvertAndRoundTrip() + { + Speed speed = Speed.FromKilometerPerHour(Of("36")); + + AssertValue("10", speed.Value, terminates: false); + AssertValue("36", speed.In(Units.KilometerPerHour), terminates: false); + AssertValue("10", speed.In(Units.MeterPerSecond), terminates: false); + } + + [TestMethod] + public void AKnotIsTheRepeatingFractionOfAMeterPerSecond() + { + Speed knot = Speed.FromKnot(T.One); + + AssertValue("0.51444444444444444444444444444444444444", knot.Value, terminates: false); + AssertValue("1", knot.In(Units.Knot), terminates: false); + } + + [TestMethod] + public void FahrenheitConvertsToKelvinAndCelsius() + { + Temperature boiling = Temperature.FromFahrenheit(Of("212")); + + AssertValue("373.15", boiling.Value, terminates: false); + AssertValue("100", boiling.In(Units.Celsius), terminates: false); + AssertValue("212", boiling.In(Units.Fahrenheit), terminates: false); + } + + [TestMethod] + public void AnglesUsePiToThePrecisionOfTheStorageType() + { + const string Pi = "3.14159265358979323846264338327950288419716939937510582097494459"; + const string Tau = "6.28318530717958647692528676655900576839433879875021164194988918"; + + AssertValue(Pi, Angle.FromDegree(Of("180")).Value, terminates: false); + AssertValue(Tau, Angle.FromRevolution(T.One).Value, terminates: false); + AssertValue(Pi, Angle.FromGradian(Of("200")).Value, terminates: false); + AssertValue(Pi, AngularSpeed.FromRevolutionPerMinute(Of("30")).Value, terminates: false); + } + + [TestMethod] + public void PressureAndPowerUseTheirExactDefinitions() + { + AssertValue("745.69987158227022", Power.FromHorsepower(T.One).Value, terminates: true); + AssertValue("6894.757293168361336722673445346890693781387562775", Pressure.FromPsi(T.One).Value, terminates: false); + AssertValue("101325", Pressure.FromTorr(Of("760")).Value, terminates: false); + } + + [TestMethod] + public void AMetricMagnitudeIsExact() + { + AssertValue("0.01", Length.FromCentimeter(T.One).Value, terminates: true); + AssertValue("36000", Length.FromKilometer(Of("36")).Value, terminates: true); + } + + [TestMethod] + public void DividingALengthByADurationGivesASpeed() + { + Speed speed = Length.FromKilometer(Of("36")) / Duration.FromHour(T.One); + + AssertValue("10", speed.Value, terminates: true); + } + + [TestMethod] + public void AThreeFourFiveVectorHasLengthFive() + { + Displacement3D vector = new() { X = Of("3"), Y = Of("4"), Z = T.Zero }; + + Assert.AreEqual(Of("5"), vector.Length()); + Assert.AreEqual(Of("5"), vector.Magnitude().Value); + } + + [TestMethod] + public void TheDistanceBetweenTwoPointsIsExactWhenTheRootIs() + { + Displacement3D from = new() { X = Of("1"), Y = Of("2"), Z = Of("3") }; + Displacement3D to = new() { X = Of("4"), Y = Of("6"), Z = Of("3") }; + + Assert.AreEqual(Of("5"), from.Distance(to)); + } + + [TestMethod] + public void AnIrrationalLengthHasThePrecisionOfTheStorageType() + { + Displacement2D diagonal = new() { X = T.One, Y = T.One }; + + AssertValue("1.41421356237309504880168872420969807856967187537694807317667973799", diagonal.Length(), terminates: false); + } + + /// + /// Parses a literal into . + /// + /// The literal. + /// The nearest value of . + protected static T Of(string literal) => T.Parse(literal, NumberStyles.Float, CultureInfo.InvariantCulture); + + /// + /// Asserts a result against its exact value. + /// + /// The exact answer as a literal, written with more digits than any storage type holds where it does not terminate. + /// The result. + /// Whether the exact answer is a terminating decimal the storage type has the digits for, and is therefore compared exactly when decimalExact is set. + private void AssertValue(string expected, T actual, bool terminates) + { + T target = Of(expected); + + if (terminates && decimalExact) + { + Assert.AreEqual(target, actual, $"Expected exactly {expected}."); + return; + } + + T allowed = relativeTolerance * T.Max(T.One, T.Abs(target)); + Assert.IsLessThanOrEqualTo(allowed, T.Abs(actual - target), $"Expected {expected} to within {tolerance} relative, got {actual}."); + } +} + +/// +/// The storage-type factor path and the public properties describe the same conversion. +/// +[TestClass] +public sealed class UnitFactorConsistencyTests +{ + /// + /// For storage, every generated unit hands out exactly the factor and offset its + /// and report, so the two routes + /// cannot drift apart. + /// + [TestMethod] + public void EveryUnitGivesDoubleStorageWhatItsPropertiesReport() + { + List units = + [ + .. typeof(Units) + .GetFields(BindingFlags.Public | BindingFlags.Static) + .Select(static field => field.GetValue(null)) + .OfType(), + ]; + + Assert.IsGreaterThan(100, units.Count, "The catalogue scan found too few units to mean anything."); + + List mismatched = + [ + .. units + .Where(static unit => unit.ToBaseFactorAs().CompareTo(unit.ToBaseFactor) != 0 + || unit.ToBaseOffsetAs().CompareTo(unit.ToBaseOffset) != 0) + .Select(static unit => unit.Name), + ]; + + Assert.IsEmpty(mismatched, $"These units convert double storage differently from their properties: {string.Join(", ", mismatched)}"); + } +} diff --git a/Semantics.Test/Quantities/StorageMathTests.cs b/Semantics.Test/Quantities/StorageMathTests.cs new file mode 100644 index 0000000..7d13cac --- /dev/null +++ b/Semantics.Test/Quantities/StorageMathTests.cs @@ -0,0 +1,100 @@ +// Copyright (c) 2023-2026 ktsu-dev contributors + +namespace ktsu.Semantics.Test.Quantities; + +using System; +using System.Numerics; +using ktsu.Semantics.Quantities; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +/// +/// The square root every generated Length() and Distance() takes. +/// +/// +/// The primitives are asserted against the expression the generated code used to inline, so a change +/// to their results fails here. The other types are asserted against the answer at their own +/// precision, which the old round trip through could not reach. +/// +[TestClass] +public sealed class StorageMathTests +{ + /// + /// A root has every digit the type holds, where converting the + /// root kept 15. + /// + [TestMethod] + public void DecimalSquareRootOfTwoHasEveryDigitTheTypeHolds() + { + decimal expected = 1.4142135623730950488016887242m; + decimal throughDouble = decimal.CreateChecked(Math.Sqrt(2d)); + + Assert.AreEqual(expected, StorageMath.Sqrt(2m)); + Assert.AreNotEqual(expected, throughDouble, "The old route should have been the less precise one, or this test proves nothing."); + } + + /// + /// A perfect square comes back exactly, across the range of . + /// + /// The value to take the root of, as a literal. + /// Its exact root, as a literal. + [TestMethod] + [DataRow("144", "12")] + [DataRow("25", "5")] + [DataRow("0.0000000000000000000001", "0.00000000001")] + [DataRow("10000000000000000000000000000", "100000000000000")] + [DataRow("1", "1")] + public void DecimalPerfectSquareIsExact(string square, string root) + { + decimal value = decimal.Parse(square, System.Globalization.CultureInfo.InvariantCulture); + decimal expected = decimal.Parse(root, System.Globalization.CultureInfo.InvariantCulture); + + Assert.AreEqual(expected, StorageMath.Sqrt(value)); + } + + [TestMethod] + public void DecimalZeroIsZero() => Assert.AreEqual(0m, StorageMath.Sqrt(0m)); + + /// + /// A negative throws exactly as the old round trip did, since has no NaN to answer with. + /// + [TestMethod] + public void DecimalNegativeThrowsAsTheDoubleRoundTripDid() + { + Assert.ThrowsExactly(static () => decimal.CreateChecked(Math.Sqrt(double.CreateChecked(-4m)))); + Assert.ThrowsExactly(static () => StorageMath.Sqrt(-4m)); + } + + /// + /// goes through unchanged, including NaN for a negative input. + /// + /// The value to take the root of. + [TestMethod] + [DataRow(2d)] + [DataRow(0.5d)] + [DataRow(1e300)] + [DataRow(3d)] + [DataRow(-1d)] + public void DoubleIsUnchanged(double value) => Assert.AreEqual(Math.Sqrt(value), StorageMath.Sqrt(value)); + + [TestMethod] + public void FloatIsUnchanged() => Assert.AreEqual(float.CreateChecked(Math.Sqrt(2d)), StorageMath.Sqrt(2f)); + + [TestMethod] + public void IntegerIsUnchanged() => Assert.AreEqual(int.CreateChecked(Math.Sqrt(26d)), StorageMath.Sqrt(26)); + + /// + /// An integer type outside the primitives is refined in integer arithmetic and settles on the + /// floor of the root, which is what truncating the root gave for values small + /// enough to fit one. + /// + [TestMethod] + public void BigIntegerSettlesOnTheFloorOfTheRoot() + { + BigInteger tenToTheForty = BigInteger.Pow(10, 40); + BigInteger tenToTheTwenty = BigInteger.Pow(10, 20); + + Assert.AreEqual(new BigInteger(5), StorageMath.Sqrt(new BigInteger(26))); + Assert.AreEqual(tenToTheTwenty, StorageMath.Sqrt(tenToTheForty)); + Assert.AreEqual(tenToTheTwenty, StorageMath.Sqrt(tenToTheForty + BigInteger.One)); + } +} diff --git a/docs/physics-generator.md b/docs/physics-generator.md index dbaeeb2..2865a9a 100644 --- a/docs/physics-generator.md +++ b/docs/physics-generator.md @@ -9,10 +9,10 @@ For the *why* (the unified vector model), see `docs/strategy-unified-vector-quan | Generator | Output | Notes | |---|---|---| | `DimensionsGenerator` | `PhysicalDimensions.g.cs` | One static record per dimension with its symbol and dimensional formula. | -| `UnitsGenerator` | `Units.g.cs` | All declared units with their conversion factors. | -| `ConversionsGenerator` | `ConversionConstants.g.cs` | Hard-coded conversion ratios (`FeetToMeters`, etc.) used by `Units` and operators. | -| `MagnitudesGenerator` | `MetricMagnitudes.g.cs` | SI prefixes and their numeric magnitudes. | -| `PrecisionGenerator` | `StorageTypes.g.cs` | The set of `INumber` storage types the library opts into (`double`, `float`, `decimal`, …). | +| `UnitsGenerator` | `Units.g.cs` | All declared units with their conversion factors, as `double` properties and as `IUnit.ToBaseFactorAs()`/`ToBaseOffsetAs()` explicit implementations that read the per-type values. | +| `ConversionsGenerator` | `ConversionConstants.g.cs` | Conversion ratios (`FeetToMeters`, etc.) from `conversions.json`, as `double` constants plus a `Values` holder that parses each one into the storage type. See [Conversion factor values](#conversion-factor-values). | +| `MagnitudesGenerator` | `MetricMagnitudes.g.cs` | SI prefixes and their numeric magnitudes, as public `double` constants plus an internal `Values` holder parsed per storage type. | +| `PrecisionGenerator` | `StorageTypes.g.cs` | The storage types the alias packages cover (`decimal`, `double`, `float`), as a public `StorageTypes` class. Nothing in the library reads it. | | `PhysicalConstantsGenerator` | `PhysicalConstants.g.cs` | `PhysicalConstants..X()`, `PhysicalConstants.Generic.X()`, and `PhysicalConstants.Conversion.X()` accessors; each literal is parsed straight into `T` and cached per closed generic type. | | `QuantitiesGenerator` | one `*.g.cs` file per emitted type | Vector0/V1/V2/V3/V4 bases, semantic overloads, factories, operators, magnitude extraction, dot/cross products. | | `LogarithmicScalesGenerator` | one `*.g.cs` file per logarithmic scale | Decibel levels, pitch intervals, and pH from `logarithmic.json`: standalone `readonly partial record struct`s with linear-quantity conversions, log-space arithmetic, and comparisons. | @@ -161,6 +161,35 @@ go in a hand-written `partial` next to the generated core (see SEM005 flags missing or duplicate scale names and conversions with no linear type. +## Conversion factor values + +Each factor in `conversions.json` has a `value` in one of two forms: + +| Form | Example | Use it for | +|---|---|---| +| Decimal literal | `"0.3048"`, `"1e-10"`, `"745.69987158227022"` | A factor with a terminating decimal definition, or a long literal for one built on π. | +| Fraction of two decimal literals | `"5/9"`, `"20265/152"` | A repeating ratio. Write the exact fraction rather than its rounded decimal. | + +`ConversionsGenerator` emits each factor twice. The `double` constant (`5d / 9d` for a fraction) +backs the public `IUnit.ToBaseFactor` and `ToBaseOffset` properties. The `Values` holder calls +`StorageLiteral.Parse` or `StorageLiteral.Divide` once per closed generic type, and the +generated factories and `In(unit)` read that. So each storage type gets the factor at its own +precision: `double` gets the correctly rounded value, and `decimal` gets 28 significant digits +where `T.CreateChecked(double)` used to leave it 15. An integer storage type, or one that cannot +parse the literal, falls back to converting the `double` constant, which is what every type did +before. + +`MagnitudesGenerator` does the same for the SI prefixes, so `1e-2` reaches `decimal` as exactly a +hundredth. + +A fraction is not always the better choice. `PsiToPascals` is written as a 150-digit literal rather +than `8896443230521/1290320000`, because `float` storage rounds a numerator that large before +dividing and lands further from the true value than parsing the literal does. + +Vector `Length()` and `Distance()` take their root through `StorageMath.Sqrt`. The binary floating +point and integer primitives keep the `Math.Sqrt` round trip they always had. Other types refine +that root with Newton steps in their own arithmetic. + ## Validation, diagnostics, and gotchas - Unknown dimension references in `integrals` / `derivatives` / `dotProducts` / `crossProducts` report **SEM001** and the operator is dropped. @@ -176,6 +205,7 @@ type. | SEM006 | A metadata file a generator declared that was not supplied as an `AdditionalFile`. | | SEM007 | A metadata file that could not be parsed. | | SEM008 | A relationship whose declared result does not follow from the dimensions of its operands, or whose signed value cannot land in a magnitude result. No operator is generated for it. | + | SEM009 | A `conversions.json` factor whose `value` is neither a decimal literal nor a fraction of two with a non-zero denominator. An error, and no constant is generated for it. | Adding one means adding it to `SemanticsDiagnostics` and to `AnalyzerReleases.Unshipped.md`; `AnalyzerReleaseTrackingTests` fails if the second step is forgotten. `GeneratorDiagnosticTests` proves each one still fires on the input it is meant to catch. - `availableUnits` order matters: the first entry is treated as the SI base unit by `UnitsGenerator`.