NetFabric.Numerics
1.0.0-beta07
Prefix Reserved
See the version list below for details.
dotnet add package NetFabric.Numerics --version 1.0.0-beta07
NuGet\Install-Package NetFabric.Numerics -Version 1.0.0-beta07
<PackageReference Include="NetFabric.Numerics" Version="1.0.0-beta07" />
paket add NetFabric.Numerics --version 1.0.0-beta07
#r "nuget: NetFabric.Numerics, 1.0.0-beta07"
// Install NetFabric.Numerics as a Cake Addin #addin nuget:?package=NetFabric.Numerics&version=1.0.0-beta07&prerelease // Install NetFabric.Numerics as a Cake Tool #tool nuget:?package=NetFabric.Numerics&version=1.0.0-beta07&prerelease
NetFabric.Numerics
Overview
NetFabric.Numerics is a C# library that specializes in delivering strongly-typed implementations for various coordinate systems, making it well-suited for precise numeric and geometric operations. This README will introduce you to the library's key features and how to use it effectively.
Key Features
Strong Typing: The library places a strong emphasis on type safety, ensuring that your code remains robust without the need for excessive memory allocation.
Universal Compatibility: NetFabric.Numerics harnesses the latest generic math features, and it requires .NET 7 or a more recent version.
Mathematical Concepts: The library is founded on the mathematical concepts of points and vectors. Subtracting two points results in a vector, and adding a point and a vector results in a point.
Support for Multiple Coordinate Systems: NetFabric.Numerics supports multiple coordinate systems, including Rectangular, Polar, and Spherical coordinates. This allows you to work with various coordinate systems seamlessly, expanding the library's versatility for your numeric and geometric operations.
Usage
To make the most of NetFabric.Numerics, follow these steps:
- Installation: The library is available as a NuGet package. You can install it using your preferred method, such as Package Manager Console, .NET CLI, or Visual Studio.
dotnet add package NetFabric.Numerics
- Add Namespace: Import the necessary namespaces in your C# code to access the library's functionality.
using NetFabric.Numerics;
using NetFabric.Numerics.Rectangular2D;
using NetFabric.Numerics.Polar;
using NetFabric.Numerics.Spherical; // Include the Spherical coordinate system
When using points and vectors from multiple coordinate systems, you can use the following namespace:
using NetFabric.Numerics;
Precede the type by the coordinate system name to avoid ambiguity:
var point2D = new Rectangular2D.Point<int>(10, 20);
var point3D = new Rectangular3D.Point<int>(10, 20, 30);
var pointPolar = new Polar.Point<Degrees, float>(10, 20);
var pointSpherical = new Spherical.Point<Degrees, float>(10, 20, 30);
- Start Using the Library: Once the library is installed and namespaces are imported, you can begin using it for your strongly-typed numeric and geometric operations. For detailed information and examples on how to use different features and coordinate systems, refer to the library's documentation.
Strong Typing in Coordinates
NetFabric.Numerics excels in providing a strongly-typed approach to coordinate systems, built on the mathematical concepts of points and vectors. Subtracting two points results in a vector, while adding a point and a vector results in a point. This approach is showcased in various examples:
using NetFabric.Numerics.Rectangular2D;
var integerPoint = new Point<int>(0, 0); // Point using integers
var doublePrecisionPoint = new Point<double>(0.0, 0.0); // Point using double precision
var singlePrecisionPoint = new Point<float>(0.0, 0.0); // Point using single precision
Quaternions Made Simple
Quaternions are essential for orientation and rotation. With NetFabric.Numerics, you can work with them efficiently:
// Strongly-typed Quaternion using single precision
var quaternionFloat = new Quaternion<float>(1.0f, 2.0f, 3.0f, 4.0f);
Efficient Math Operations
NetFabric.Numerics simplifies numeric operations while maintaining precision and strong typing:
// Subtract two 3D points, resulting in a vector
var vector3DDouble = point3DDouble - new Point<double>(1.0, 1.0, 1.0);
// Transform a 3D point with a vector, resulting in a new point
var point3DTransformed = point3DDouble + vector3DDouble;
Simple Conversions
The library simplifies converting between different numeric types while preserving strong typing:
// Convert a 3D point to single precision, checking for overflow
var convertToFloatChecked = Point<float>.CreateChecked(point3DDouble);
// Convert a 3D point to single precision, saturating on overflow
var convertToFloatSaturated = Point<float>.CreateSaturating(point3DDouble);
// Convert a 3D point to single precision, truncating on overflow
var convertToFloatTruncated = Point<float>.CreateTruncating(point3DDouble);
Credits
The following open-source projects are used to build and test this project:
License
This project is licensed under the MIT license. See the LICENSE file for more info.
Product | Versions 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. |
-
net7.0
- NetFabric.Numerics.Angle (>= 1.0.0-beta07)
-
net8.0
- NetFabric.Numerics.Angle (>= 1.0.0-beta07)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on NetFabric.Numerics:
Package | Downloads |
---|---|
NetFabric.Numerics.Geography
Package Description |
|
NetFabric.Numerics.Geodesy
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0-beta08 | 213 | 11/3/2023 |
1.0.0-beta07 | 87 | 10/24/2023 |
1.0.0-beta06 | 81 | 10/20/2023 |
1.0.0-beta05 | 77 | 10/20/2023 |
1.0.0-beta04 | 109 | 6/11/2023 |
1.0.0-beta03 | 81 | 6/10/2023 |
1.0.0-beta02 | 90 | 6/9/2023 |
1.0.0-beta01 | 86 | 5/23/2023 |