ktsu.io.PhysicalQuantity 1.0.0-alpha.5

Prefix Reserved
This is a prerelease version of ktsu.io.PhysicalQuantity.
dotnet add package ktsu.io.PhysicalQuantity --version 1.0.0-alpha.5                
NuGet\Install-Package ktsu.io.PhysicalQuantity -Version 1.0.0-alpha.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ktsu.io.PhysicalQuantity" Version="1.0.0-alpha.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ktsu.io.PhysicalQuantity --version 1.0.0-alpha.5                
#r "nuget: ktsu.io.PhysicalQuantity, 1.0.0-alpha.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ktsu.io.PhysicalQuantity as a Cake Addin
#addin nuget:?package=ktsu.io.PhysicalQuantity&version=1.0.0-alpha.5&prerelease

// Install ktsu.io.PhysicalQuantity as a Cake Tool
#tool nuget:?package=ktsu.io.PhysicalQuantity&version=1.0.0-alpha.5&prerelease                

ktsu.io.PhysicalQuantity

PhysicalQuantity is a .NET library that provides a robust framework for working with physical quantities, supporting a wide range of units and conversions.

Features

  • Comprehensive Unit Support: Supports a wide range of physical quantities including length, mass, time, energy, and more.
  • Accurate Conversions: Provides accurate unit conversions for each quantity.
  • Significant Numbers: Uses the SignificantNumber library to maintain precision in calculations.
  • Extensibility: Easily extendable to support custom units and quantities.

Installation

To install PhysicalQuantity, run the following command in your .NET project:

dotnet add package ktsu.io.PhysicalQuantity

Usage

Basic Example

using ktsu.io.PhysicalQuantity.Length;
using ktsu.io.SignificantNumber;

Length lengthInMeters = 100.Meters();
float lengthInKilometers = lengthInMeters.Kilometers<float>();

Console.WriteLine($"{lengthInMeters} is equal to {lengthInKilometers} kilometers");

Supported Quantities

  • Acceleration
  • AmountOfSubstance
  • Angle
  • AngularAcceleration
  • AngularVelocity
  • Area
  • Density
  • ElectricCurrent
  • ElectricPotential
  • Energy
  • Force
  • Illuminance
  • Jerk
  • Length
  • LuminousFlux
  • LuminousIntensity
  • Mass
  • Power
  • Pressure
  • Resistance
  • Temperature
  • Time
  • Torque
  • Velocity
  • Volume

Example Conversion

using ktsu.io.PhysicalQuantity.Mass;
using ktsu.io.SignificantNumber;

Mass massInKilograms = 70.Kilograms();
float massInPounds = massInKilograms.Pounds<float>();

Console.WriteLine($"{massInKilograms} is equal to {massInPounds} pounds");

Integrating and Deriving Quantities

The PhysicalQuantity library supports operations for integrating and deriving physical quantities, making it easier to work with quantities that result from these operations.

Deriving Quantities

To derive a quantity, you can use the appropriate operators provided by the IIntegrationOperators interface. For example, deriving velocity from distance and time:

using ktsu.io.PhysicalQuantity.Length;
using ktsu.io.PhysicalQuantity.Time;
using ktsu.io.PhysicalQuantity.Velocity;
using ktsu.io.SignificantNumber;

Length distance = 100.Meters();
Time time = 10.Seconds();
Velocity velocity = distance / time;

Console.WriteLine($"Velocity: {velocity}"); // Output: Velocity: 10 m/s
Integrating Quantities

To integrate quantities, you can use the appropriate operators. For example, integrating acceleration over time to get velocity:

using ktsu.io.PhysicalQuantity.Acceleration;
using ktsu.io.PhysicalQuantity.Time;
using ktsu.io.PhysicalQuantity.Velocity;
using ktsu.io.SignificantNumber;

Acceleration acceleration = 9.8.MetersPerSecondSquared();
Time time = 5.Seconds();
Velocity velocity = acceleration * time;

Console.WriteLine($"Velocity: {velocity}"); // Output: Velocity: 49 m/s

Example

Here's a more comprehensive example that demonstrates both integration and derivation:

using ktsu.io.PhysicalQuantity.Acceleration;
using ktsu.io.PhysicalQuantity.Length;
using ktsu.io.PhysicalQuantity.Time;
using ktsu.io.PhysicalQuantity.Velocity;
using ktsu.io.SignificantNumber;

Length initialDistance = 0.Meters();
Velocity initialVelocity = 0.MetersPerSecond();
Acceleration acceleration = 9.8.MetersPerSecondSquared();
Time time = 10.Seconds();

// Calculate final velocity: v = u + at
Velocity finalVelocity = initialVelocity + acceleration * time;

// Calculate distance traveled: s = ut + 0.5 * a * t^2
Length distance = initialVelocity * time + 0.5 * acceleration * time * time;

Console.WriteLine($"Final Velocity: {finalVelocity}"); // Output: Final Velocity: 98 m/s
Console.WriteLine($"Distance Traveled: {distance}");   // Output: Distance Traveled: 490 m

By using these integration and derivation methods, you can handle a wide range of physical calculations with ease.

Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

For questions or feedback, please open an issue on GitHub.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on ktsu.io.PhysicalQuantity:

Package Downloads
ktsu.io.Physics.Thermodynamics

Thermodynamics

ktsu.io.Physics.Earth

Library for Earth's physical properties and calculations, including gravity at various altitudes, radius, mass, volume, and density.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0-alpha.5 612 6/17/2024
1.0.0-alpha.4 55 6/17/2024
1.0.0-alpha.3 73 6/16/2024
1.0.0-alpha.2 71 6/6/2024
1.0.0-alpha.1 56 6/6/2024