TMath 1.1.0
See the version list below for details.
dotnet add package TMath --version 1.1.0
NuGet\Install-Package TMath -Version 1.1.0
<PackageReference Include="TMath" Version="1.1.0" />
paket add TMath --version 1.1.0
#r "nuget: TMath, 1.1.0"
// Install TMath as a Cake Addin #addin nuget:?package=TMath&version=1.1.0 // Install TMath as a Cake Tool #tool nuget:?package=TMath&version=1.1.0
TMath - Generics Math Library for C#
TMath is a C# Math library that has function implementations for any number or custom type
that implements INumber<T>
. Some functions require other implementations like
ILogarithmicFunctions<T>
or IPowerFunctions<T>
.
🌟 • Features
- Generics Support: TMath can make calculations using all number types with the same
function call, doesn't matter if you're using
float
,ulong
,decimal
or your custom numeric type, as long as it implementsINumber<T>
- Generics Constants: TMath also has a
TConstants<T>
class for getting mathematical constants as any numeric type, such as Euler's Number, Pi, Golden Ratio and common square roots - Expanded math functions: More math functions not supported by the default
Math
class that also work with generics, such asFactorial()
.
📙 • Getting Started
Installation
There are multiple ways of installing TMath on your project:
- NuGet Package Manager: From your IDE, simply open the package manager and search for TMath
- .NET CLI: Open a command line and switch to the directory that contains your project file. After that, run the following command
dotnet add package TMath
- Forking / Cloning the repository: Clone the repository into your projects and keep the package saved on your project files.
[!IMPORTANT] Downloading the files manually means you will have to update the package manually if you want the latest release whenever the package gets updated
🔧 • Usage
Using TMath is very simple, simply call the functions like you would with Math
and it'll automatically
return
the correct type for most functions, with the exception of a handful of them like Factorial<T>()
.
For getting any constants using TConstants<T>
, specify your type (for example, TConstants<float>
).
// Calculating the area of a circle arc.
decimal angle = TConstants<decimal>.Pi;
decimal radius = 1;
decimal areaOfArc = (Foo.Rad2Deg(angle) / 360) * TConstants<decimal>.Pi * Foo.Pow(radius, 2);
Console.WriteLine(areaOfArc);
// Calculating 20!
long factorial = TMath.Factorial<long>(20);
Console.WriteLine(factorial);
// Absolute value
sbyte number = -34;
sbyte abs = TMath.Abs(number);
Console.WriteLine(abs);
📄 • License
TMath is licensed under the MIT License.
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. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.7.0 | 144 | 3/1/2024 |
1.6.2 | 131 | 2/6/2024 |
1.6.0 | 109 | 1/24/2024 |
1.5.5 | 122 | 1/19/2024 |
1.5.2 | 105 | 1/19/2024 |
1.5.0 | 105 | 1/18/2024 |
1.4.1 | 141 | 12/30/2023 |
1.3.1 | 123 | 12/26/2023 |
1.2.0 | 178 | 12/1/2023 |
1.1.2 | 131 | 11/26/2023 |
1.1.1 | 131 | 11/26/2023 |
1.1.0 | 128 | 11/26/2023 |
1.0.1 | 127 | 11/25/2023 |
1.0.0 | 135 | 11/25/2023 |
Added TEasings: A Easings function class with support for generics
Added TMath functions:
- Sum<T>( ): Gets the summation of a function
- Truncate<T>(): Truncates a floating point number.
- CopySign<T>(): Copies the sign of one value to another.
- Trigonometric functions for supported types.