ktsu.PhysicalQuantity 1.0.0-alpha.23

Prefix Reserved
This is a prerelease version of ktsu.PhysicalQuantity.
dotnet add package ktsu.PhysicalQuantity --version 1.0.0-alpha.23
                    
NuGet\Install-Package ktsu.PhysicalQuantity -Version 1.0.0-alpha.23
                    
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.PhysicalQuantity" Version="1.0.0-alpha.23" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ktsu.PhysicalQuantity" Version="1.0.0-alpha.23" />
                    
Directory.Packages.props
<PackageReference Include="ktsu.PhysicalQuantity" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ktsu.PhysicalQuantity --version 1.0.0-alpha.23
                    
#r "nuget: ktsu.PhysicalQuantity, 1.0.0-alpha.23"
                    
#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.
#:package ktsu.PhysicalQuantity@1.0.0-alpha.23
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ktsu.PhysicalQuantity&version=1.0.0-alpha.23&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=ktsu.PhysicalQuantity&version=1.0.0-alpha.23&prerelease
                    
Install as a Cake Tool

ktsu.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.PhysicalQuantity

Usage

Basic Example

using ktsu.PhysicalQuantity.Length;
using ktsu.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.PhysicalQuantity.Mass;
using ktsu.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.PhysicalQuantity.Length;
using ktsu.PhysicalQuantity.Time;
using ktsu.PhysicalQuantity.Velocity;
using ktsu.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.PhysicalQuantity.Acceleration;
using ktsu.PhysicalQuantity.Time;
using ktsu.PhysicalQuantity.Velocity;
using ktsu.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.PhysicalQuantity.Acceleration;
using ktsu.PhysicalQuantity.Length;
using ktsu.PhysicalQuantity.Time;
using ktsu.PhysicalQuantity.Velocity;
using ktsu.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 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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

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

Package Downloads
ktsu.Physics.Earth

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

ktsu.Physics.Thermodynamics

Thermodynamics

ktsu.Physics.Constants

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-alpha.23 3,075 12/26/2024
1.0.0-alpha.22 130 12/26/2024
1.0.0-alpha.21 119 12/26/2024
1.0.0-alpha.20 111 12/26/2024
1.0.0-alpha.19 121 12/26/2024
1.0.0-alpha.18 126 12/26/2024
1.0.0-alpha.17 132 12/26/2024
1.0.0-alpha.16 446 12/24/2024
1.0.0-alpha.15 154 12/23/2024
1.0.0-alpha.14 133 12/23/2024
1.0.0-alpha.13 130 12/22/2024
1.0.0-alpha.12 127 12/22/2024
1.0.0-alpha.11 320 12/6/2024
1.0.0-alpha.10 178 12/5/2024
1.0.0-alpha.9 224 12/2/2024
1.0.0-alpha.8 110 12/2/2024
1.0.0-alpha.7 169 12/1/2024
1.0.0-alpha.6 147 12/1/2024