ktsu.PhysicalQuantity
1.0.0-alpha.23
Prefix Reserved
dotnet add package ktsu.PhysicalQuantity --version 1.0.0-alpha.23
NuGet\Install-Package ktsu.PhysicalQuantity -Version 1.0.0-alpha.23
<PackageReference Include="ktsu.PhysicalQuantity" Version="1.0.0-alpha.23" />
<PackageVersion Include="ktsu.PhysicalQuantity" Version="1.0.0-alpha.23" />
<PackageReference Include="ktsu.PhysicalQuantity" />
paket add ktsu.PhysicalQuantity --version 1.0.0-alpha.23
#r "nuget: ktsu.PhysicalQuantity, 1.0.0-alpha.23"
#:package ktsu.PhysicalQuantity@1.0.0-alpha.23
#addin nuget:?package=ktsu.PhysicalQuantity&version=1.0.0-alpha.23&prerelease
#tool nuget:?package=ktsu.PhysicalQuantity&version=1.0.0-alpha.23&prerelease
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 | Versions 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. |
-
net8.0
- ktsu.SemanticQuantity (>= 1.0.8)
- ktsu.SignificantNumber (>= 1.2.7)
-
net9.0
- ktsu.SemanticQuantity (>= 1.0.8)
- ktsu.SignificantNumber (>= 1.2.7)
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 |