-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
175 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Quantities.Units.Imperial; | ||
using Quantities.Units.NonStandard; | ||
using Quantities.Units.Si; | ||
|
||
namespace Quantities; | ||
|
||
public interface ISystems<in TConstraint, out TResult> | ||
{ | ||
public TResult Si<TInjectedUnit>() where TInjectedUnit : ISiUnit, TConstraint; | ||
public TResult Metric<TInjectedUnit>() where TInjectedUnit : IMetricUnit, TConstraint; | ||
public TResult Imperial<TInjectedUnit>() where TInjectedUnit : IImperialUnit, TConstraint; | ||
public TResult NonStandard<TInjectedUnit>() where TInjectedUnit : INoSystemUnit, TConstraint; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Numerics; | ||
|
||
namespace Quantities.Numerics; | ||
|
||
internal static class Algorithms | ||
{ | ||
// Implements: https://en.wikipedia.org/wiki/Euclidean_algorithm | ||
public static T Gcd<T>(T a, T b) | ||
where T : INumberBase<T>, IModulusOperators<T, T, T> | ||
{ | ||
var big = T.MaxMagnitude(a, b); | ||
var small = T.MinMagnitude(a, b); | ||
return Impl(T.Abs(big), T.Abs(small)); | ||
static T Impl(T max, T min) => T.IsZero(min) ? max : Impl(min, max % min); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
using Quantities.Dimensions; | ||
using Quantities.Units.Si; | ||
|
||
namespace Quantities.Units.Imperial.Length; | ||
|
||
public readonly struct Foot : IImperialUnit, ILength | ||
{ | ||
public const Double ToMetre = 0.3048; | ||
public static Transformation ToSi(Transformation self) => ToMetre * self; | ||
public static Transformation ToSi(Transformation self) => 3048 * self.RootedIn<Metre>() / 1e4; | ||
public static String Representation => "ft"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
using Quantities.Dimensions; | ||
using Quantities.Units.Si; | ||
|
||
namespace Quantities.Units.Imperial.Temperature; | ||
|
||
// [K] ≡ ([°F] + 459.67) × 5⁄9 | ||
// See: https://en.wikipedia.org/wiki/Conversion_of_units#Temperature | ||
// See: https://en.wikipedia.org/wiki/Conversion_of_scales_of_temperature | ||
public readonly struct Fahrenheit : IImperialUnit, ITemperature | ||
{ | ||
public static Transformation ToSi(Transformation self) => 5 * (self + 459.67) / 9; | ||
public static Transformation ToSi(Transformation self) => 5 * (self.RootedIn<Kelvin>() + 459.67) / 9; | ||
public static String Representation => "°F"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.