- Notifications
You must be signed in to change notification settings - Fork1
A .NET library that provides strongly-typed implementations of multiple coordinate systems, including rectangular, polar, spherical, and geodetic.
License
NetFabric/NetFabric.Numerics
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Welcome to the documentation forNetFabric.Numerics, a powerful C# library that provides strongly-typed implementations of multiple coordinate systems, including rectangular, polar, spherical, and geodetic. Whether you're working with angles, points, or geographic coordinates, this library has you covered!
Note: The
NetFabric.Numericslibrary utilizes advanced generic math features, which are only available in .NET 7 and C# 11.Make sure you are using a compatible version of the framework before using this library.
To get started withNetFabric.Numerics, you need to install the library's NuGet packages. The library is divided into three packages, each serving a specific purpose:
- NetFabric.Numerics.Angle: Provides strongly-typed angle implementations.
- NetFabric.Numerics: Provides strongly-typed rectangular, polar and spherical coordinate implementations.
- NetFabric.Numerics.Geodesy: Provides strongly-typed geodetic coordinate implementations.
Make sure to include the appropriate package(s) in your project, depending on your specific needs.
NetFabric.Numerics adopts a robust, strongly-typed methodology, harnessing the capabilities of generics to guarantee both type safety and adaptability. Through the utilization of generics, you have the ability to define the internal data type and the characteristics of the coordinate system without the need for additional memory allocation.
Let's take a look at some examples to illustrate this:
When working with points in different coordinate systems,NetFabric.Numerics allows you to specify the data type used internally. Here's an example:
usingNetFabric.Numerics.Rectangular2D;varintegerPoint=newPoint<int>(0,0);// Point using integersvardoublePrecisionPoint=newPoint<double>(0.0,0.0);// Point using double precisionvarsinglePrecisionPoint=newPoint<float>(0.0,0.0);// Point using single precisionvarcheckedConversion=Point<float>.CreateChecked(doublePrecisionPoint);// Throws if overflow occursvarsaturatedConversion=Point<float>.CreateSaturating(doublePrecisionPoint);// Saturates if overflow occursvartruncatedConversion=Point<float>.CreateTruncating(doublePrecisionPoint);// Truncates if overflow occurs
By specifying the desired data type, you have control over the precision and memory usage of your points.
NetFabric.Numerics also supports strongly-typed angles, with support for various units of measurement. Here's an example:
usingNetFabric.Numerics;vardegreesAngle=newAngle<Degrees,double>(0.0);// Angle using degreesvarradiansAngle=newAngle<Radians,double>(0.0);// Angle using radiansvargradiansAngle=newAngle<Gradians,double>(0.0);// Angle using gradiansvarrevolutionsAngle=newAngle<Revolutions,double>(0.0);// Angle using revolutionsvardoublePrecisionAngle=newAngle<Degrees,double>(0.0);// Angle with double precisionvarsinglePrecisionAngle=newAngle<Degrees,float>(0.0);// Angle with single precision
You can choose the unit of measurement for your angles and specify the desired precision.
NetFabric.Numerics provides strongly-typed polar coordinate implementations. Here's an example:
usingNetFabric.Numerics.Polar;vardegreesPoint=newPoint<Degrees,double>(0.0,0.0);// Polar point using degreesvarradiansPoint=newPoint<Radians,double>(0.0,0.0);// Polar point using radiansvargradiansPoint=newPoint<Gradians,double>(0.0,0.0);// Polar point using gradiansvarrevolutionsPoint=newPoint<Revolutions,double>(0.0,0.0);// Polar point using revolutionsvardoublePrecisionPoint=newPoint<Degrees,double>(0.0,0.0);// Polar point with double precisionvarsinglePrecisionPoint=newPoint<Degrees,float>(0.0,0.0);// Polar point with single precision
WithNetFabric.Numerics, you can work with polar coordinates using different units of measurement and specify the desired precision for the azimuth and radius.
NetFabric.Numerics also supports strongly-typed geodetic coordinate implementations, specifically latitude and longitude. Here's an example:
usingNetFabric.Numerics.Geodesy.Geodetic2;varwgs84Point=newPoint<WGS84,Degrees,double>(new(0.0),new(0.0));// Geodetic point using WGS84 datumvarwgs1972Point=newPoint<WGS1972,Degrees,double>(new(0.0),new(0.0));// Geodetic point using WGS1972 datumvarnad83Point=newPoint<NAD83,Degrees,double>(new(0.0),new(0.0));// Geodetic point using NAD83 datumvarnad1927ConusPoint=newPoint<NAD1927CONUS,Degrees,double>(new(0.0),new(0.0));// Geodetic point using NAD1927CONUS datumvardoublePrecisionPoint=newPoint<WGS84,Degrees,double>(new(0.0),new(0.0));// Geodetic point with double precisionvarsinglePrecisionPoint=newPoint<WGS84,Degrees,float>(new(0.0f),new(0.0f));// Geodetic point with single precisionvarminutesPoint=newPoint<WGS84,Degrees,double>(Angle.ToDegrees<double>(0,0.0),Angle.ToDegrees<double>(0,0.0));// Geodetic point using degrees and minutesvarminutesSecondsPoint=newPoint<WGS84,Degrees,double>(Angle.ToDegrees<double>(0,0,0.0),Angle.ToDegrees<double>(0,0,0.0));// Geodetic point using degrees, minutes and secondsvar(degreesLatitude,minutesLatitude)=Angle.ToDegreesMinutes<double,int,double>(wgs84Point.Latitude);// Convert latitude to degrees and minutesvar(degreesLatitude2,minutesLatitude2,secondsLatitude)=Angle.ToDegreesMinutesSeconds<double,int,int,double>(wgs84Point.Latitude);// Convert latitude to degrees, minutes, and seconds
NetFabric.Numerics enables you to work with geodetic coordinates using various datums, allowing you to specify the desired precision and units of measurement for latitude and longitude.
This addition provides clarity about the usage of generic types for specifying data types and properties within theNetFabric.Numerics library, enhancing the documentation's value. If you have any further suggestions or updates, please feel free to let me know.
The following open-source projects are used to build and test this project:
This project is licensed under the MIT license. See theLICENSE file for more info.
About
A .NET library that provides strongly-typed implementations of multiple coordinate systems, including rectangular, polar, spherical, and geodetic.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.