Added conversion between number systems and their System.Numerics counterparts. (#32)

This commit is contained in:
That-One-Nerd 2023-07-10 16:04:04 -04:00
parent eeb70604d5
commit 2c2e7e3a99
4 changed files with 17 additions and 3 deletions

View File

@ -6,6 +6,10 @@ Here's the full changelog:
```
* Nerd_STF
* Mathematics
* NumberSystems
* Complex
+ operator Complex(SystemComplex)
+ operator SystemComplex(Complex)
* Float3
= Added a setter to `XY`
= Added a setter to `XZ`

View File

@ -1,4 +1,6 @@
namespace Nerd_STF.Mathematics.NumberSystems;
using SystemComplex = System.Numerics.Complex;
namespace Nerd_STF.Mathematics.NumberSystems;
public record struct Complex(float u, float i) : IAbsolute<Complex>, IAverage<Complex>, ICeiling<Complex>,
IClampMagnitude<Complex, float>, IComparable<Complex>, IDivide<Complex>, IDot<Complex, float>,
@ -204,4 +206,7 @@ public record struct Complex(float u, float i) : IAbsolute<Complex>, IAverage<Co
public static implicit operator Complex(Fill<float> fill) => new(fill);
public static implicit operator Complex(Fill<int> fill) => new(fill);
public static implicit operator Complex((float u, float i) val) => new(val.u, val.i);
public static implicit operator Complex(SystemComplex val) => ((float)val.Real, (float)val.Imaginary);
public static implicit operator SystemComplex(Complex val) => new(val.u, val.i);
}

View File

@ -1,4 +1,6 @@
namespace Nerd_STF.Mathematics.NumberSystems;
using SystemQuaternion = System.Numerics.Quaternion;
namespace Nerd_STF.Mathematics.NumberSystems;
public record struct Quaternion(float u, float i, float j, float k) : IAbsolute<Quaternion>, IAverage<Quaternion>,
ICeiling<Quaternion>, IClamp<Quaternion>, IClampMagnitude<Quaternion, float>, IComparable<Quaternion>,
@ -332,4 +334,7 @@ public record struct Quaternion(float u, float i, float j, float k) : IAbsolute<
public static implicit operator Quaternion(Fill<int> fill) => new(fill);
public static implicit operator Quaternion((float u, float i, float j, float k) val) =>
new(val.u, val.i, val.j, val.k);
public static implicit operator Quaternion(SystemQuaternion val) => (val.X, val.Y, val.Z, val.W);
public static implicit operator SystemQuaternion(Quaternion val) => new(val.u, val.i, val.j, val.k);
}

View File

@ -12,7 +12,7 @@
<Copyright>Copyright (c) 2023 That_One_Nerd</Copyright>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/That-One-Nerd/Nerd_STF</RepositoryUrl>
<AssemblyVersion>2.5.0</AssemblyVersion>
<AssemblyVersion>2.4.1</AssemblyVersion>
<PackageTags>c#;csharp;c sharp;math;mathematics;mathametics;maths;color;rgb;rgba;cmyk;cmyka;hsv;hsva;calculus;linear algebra;linalg;linearalgebra;matrix;matrix2x2;matrix 2x2;matrix3x3;matrix 3x3;matrix4x4;matrix 4x4;matrix multiplication;vector;vector2d;vector3d;vector2;vector3;float2;float3;float4;int2;int3;int4;angle;geometry;vert;line;polygon;triangle;quadrilateral;sphere;circle;number system;numbersystem;complex numbers;complex;2d numbers;2dnumbers;quaternions;4d numbers;4dnumbers</PackageTags>
<Version>2.4.1</Version>
<Product>Nerd_STF</Product>