A modeling of units of measures that does automatic conversion between units for any modeled quantity using Float64 values.
$ dotnet add package GraduatedCylinderA typed implementation of measurable dimensions for .NET (i.e. Length, Speed, Acceleration, Jerk).
There are 2 versions of this library:
Many operators are implemented to allow derivative computations without you explicitly worrying about units, it is taken care of for you (i.e. Jerk = Acceleration / Time).
Starting at version 6.0, this library uses Roslyn to generate many features from built in metadata, so no runtime reflection is required anymore.
You can build GraduatedCylinder using Visual Studio 2022. We use Nuke as the build engine, and deliver packages on NuGet.org
Contributions to GraduatedCylinder are gratefully received but we do ask you to follow certain conditions:
your-fork/your-branch to GraduatedCylinder/masterThe main contributors to the project will manage releases and SemVer-compliant version numbers.
Mass vehicleMass = new Mass(2500, MassUnit.Pounds);
Speed startSpeed = new Speed(72, SpeedUnit.MilesPerHour);
Speed endSpeed = new Speed(0, SpeedUnit.MilesPerHour);
Length stoppingDistance = new Length(1234, LengthUnit.Feet);
Acceleration deceleration = MotionCalculator.ComputeConstantAcceleration(startSpeed, endSpeed, stoppingDistance);
Force stoppingForceRequired = vehicleMass * deceleration;
Console.WriteLine($"To stop a vehicle of {vehicleMass} moving at {startSpeed} within {stoppingDistance},");
Console.WriteLine("the force required is:");
Console.WriteLine($"\t{constantStoppingForce}");
Console.WriteLine($"\t{constantStoppingForce.ToString(ForceUnit.Newtons, 3)}");
Console.WriteLine($"\t{constantStoppingForce.ToString(ForceUnit.KilogramForce)}");
Console.WriteLine($"\t{constantStoppingForce.ToString(ForceUnit.PoundForce, 5)}");
The output is as follows:
To stop a vehicle of 2,500.00 lbs moving at 72.00 mph within 1,234.00 ft,
the force required is:
-1,561.72 N
-1,561.721 N
-159.20 kgf
-351.08893 lbf