Skip to content

Commit

Permalink
Remove OpenTK compatibility from Mathematics
Browse files Browse the repository at this point in the history
  • Loading branch information
Tornado-Technology committed Oct 26, 2024
1 parent 0f6e698 commit 7460b77
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 256 deletions.
5 changes: 0 additions & 5 deletions Hypercube.Mathematics/Hypercube.Mathematics.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,4 @@
<Product>Hypercube.Mathematics</Product>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="OpenTK.Mathematics" Version="5.0.0-pre.11" />
<PackageReference Include="OpenToolkit.Mathematics" Version="4.0.0-pre9.3" />
</ItemGroup>

</Project>
36 changes: 14 additions & 22 deletions Hypercube.Mathematics/Matrices/Matrix3x2.Compatibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,26 @@ namespace Hypercube.Mathematics.Matrices;
public partial struct Matrix3x2
{
/*
* OpenTK Compatibility
* System.Numerics Compatibility
*/

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator OpenTK.Mathematics.Matrix3x2(Matrix3x2 matrix3)
{
return new OpenTK.Mathematics.Matrix3x2(matrix3.Row0, matrix3.Row1, matrix3.Row2);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Matrix3x2(OpenTK.Mathematics.Matrix3x2 matrix3)
{
return new Matrix3x2(matrix3.Row0, matrix3.Row1, matrix3.Row2);
}

/*
* OpenToolkit Compatibility
*/


[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator OpenToolkit.Mathematics.Matrix3x2(Matrix3x2 matrix3)
public static implicit operator System.Numerics.Matrix3x2(Matrix3x2 matrix4X4)
{
return new OpenToolkit.Mathematics.Matrix3x2(matrix3.Row0, matrix3.Row1, matrix3.Row2);
return new System.Numerics.Matrix3x2(
matrix4X4.M00, matrix4X4.M01,
matrix4X4.M10, matrix4X4.M11,
matrix4X4.M20, matrix4X4.M21
);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Matrix3x2(OpenToolkit.Mathematics.Matrix3x2 matrix3)
public static implicit operator Matrix3x2(System.Numerics.Matrix3x2 matrix4X4)
{
return new Matrix3x2(matrix3.Row0, matrix3.Row1, matrix3.Row2);
return new Matrix3x2(
matrix4X4.M11, matrix4X4.M12,
matrix4X4.M21, matrix4X4.M22,
matrix4X4.M31, matrix4X4.M32
);
}
}
4 changes: 2 additions & 2 deletions Hypercube.Mathematics/Matrices/Matrix3x2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ public static Matrix3x2 CreateRotation(Angle angle)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Matrix3x2 CreateRotation(double angle)
{
var cos = (float)System.Math.Cos(angle);
var sin = (float)System.Math.Sin(angle);
var cos = (float)Math.Cos(angle);
var sin = (float)Math.Sin(angle);

return new Matrix3x2(cos, sin, -sin, cos, 0, 0);
}
Expand Down
36 changes: 1 addition & 35 deletions Hypercube.Mathematics/Matrices/Matrix3x3.Compatibility.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

namespace Hypercube.Mathematics.Matrices;

[SuppressMessage("ReSharper", "InconsistentNaming")]
public partial struct Matrix3x3
{
/*
* OpenTK Compatibility
*/

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator OpenTK.Mathematics.Matrix3(Matrix3x3 matrix3)
{
return new OpenTK.Mathematics.Matrix3(matrix3.Row0, matrix3.Row1, matrix3.Row2);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Matrix3x3(OpenTK.Mathematics.Matrix3 matrix3)
{
return new Matrix3x3(matrix3.Row0, matrix3.Row1, matrix3.Row2);
}

/*
* OpenToolkit Compatibility
*/

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator OpenToolkit.Mathematics.Matrix3(Matrix3x3 matrix3)
{
return new OpenToolkit.Mathematics.Matrix3(matrix3.Row0, matrix3.Row1, matrix3.Row2);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Matrix3x3(OpenToolkit.Mathematics.Matrix3 matrix3)
{
return new Matrix3x3(matrix3.Row0, matrix3.Row1, matrix3.Row2);
}
}
public partial struct Matrix3x3;
32 changes: 0 additions & 32 deletions Hypercube.Mathematics/Matrices/Matrix4X4.Compatibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,4 @@ public static implicit operator Matrix4X4(System.Numerics.Matrix4x4 matrix4X4)
matrix4X4.M31, matrix4X4.M32, matrix4X4.M33, matrix4X4.M34,
matrix4X4.M41, matrix4X4.M42, matrix4X4.M43, matrix4X4.M44);
}

/*
* OpenTK Compatibility
*/

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator OpenTK.Mathematics.Matrix4(Matrix4X4 matrix4X4)
{
return new OpenTK.Mathematics.Matrix4(matrix4X4.Row0, matrix4X4.Row1, matrix4X4.Row2, matrix4X4.Row3);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Matrix4X4(OpenTK.Mathematics.Matrix4 matrix4)
{
return new Matrix4X4(matrix4.Row0, matrix4.Row1, matrix4.Row2, matrix4.Row3);
}

/*
* Open Toolkit Compatibility
*/

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator OpenToolkit.Mathematics.Matrix4(Matrix4X4 matrix4X4)
{
return new OpenToolkit.Mathematics.Matrix4(matrix4X4.Row0, matrix4X4.Row1, matrix4X4.Row2, matrix4X4.Row3);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Matrix4X4(OpenToolkit.Mathematics.Matrix4 matrix4)
{
return new Matrix4X4(matrix4.Row0, matrix4.Row1, matrix4.Row2, matrix4.Row3);
}
}
32 changes: 0 additions & 32 deletions Hypercube.Mathematics/Vectors/Vector2.Compatibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,36 +51,4 @@ public static implicit operator System.Numerics.Vector2(Vector2 vector)
{
return new System.Numerics.Vector2(vector.X, vector.Y);
}

/*
* OpenTK Compatibility
*/

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Vector2(OpenTK.Mathematics.Vector2 vector)
{
return new Vector2(vector.X, vector.Y);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator OpenTK.Mathematics.Vector2(Vector2 vector)
{
return new OpenTK.Mathematics.Vector2(vector.X, vector.Y);
}

/*
* OpenToolkit Compatibility
*/

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Vector2(OpenToolkit.Mathematics.Vector2 vector)
{
return new Vector2(vector.X, vector.Y);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator OpenToolkit.Mathematics.Vector2(Vector2 vector)
{
return new OpenToolkit.Mathematics.Vector2(vector.X, vector.Y);
}
}
32 changes: 0 additions & 32 deletions Hypercube.Mathematics/Vectors/Vector2i.Compatibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,36 +69,4 @@ public static implicit operator System.Drawing.Size(Vector2i vector2)
{
return new System.Drawing.Size(vector2.X, vector2.Y);
}

/*
* OpenTK Compatibility
*/

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Vector2i(OpenTK.Mathematics.Vector2i vector)
{
return new Vector2i(vector.X, vector.Y);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator OpenTK.Mathematics.Vector2i(Vector2i vector)
{
return new OpenTK.Mathematics.Vector2i(vector.X, vector.Y);
}

/*
* OpenToolkit Compatibility
*/

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Vector2i(OpenToolkit.Mathematics.Vector2i vector)
{
return new Vector2i(vector.X, vector.Y);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator OpenToolkit.Mathematics.Vector2i(Vector2i vector)
{
return new OpenToolkit.Mathematics.Vector2i(vector.X, vector.Y);
}
}
32 changes: 0 additions & 32 deletions Hypercube.Mathematics/Vectors/Vector3.Compatibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,36 +51,4 @@ public static implicit operator Vector3(System.Numerics.Vector3 vector3)
{
return new Vector3(vector3.X, vector3.Y, vector3.Z);
}

/*
* OpenTK Compatibility
*/

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator OpenTK.Mathematics.Vector3(Vector3 vector)
{
return new OpenTK.Mathematics.Vector3(vector.X, vector.Y, vector.Z);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Vector3(OpenTK.Mathematics.Vector3 vector)
{
return new Vector3(vector.X, vector.Y, vector.Z);
}

/*
* OpenToolkit Compatibility
*/

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator OpenToolkit.Mathematics.Vector3(Vector3 vector)
{
return new OpenToolkit.Mathematics.Vector3(vector.X, vector.Y, vector.Z);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Vector3(OpenToolkit.Mathematics.Vector3 vector)
{
return new Vector3(vector.X, vector.Y, vector.Z);
}
}
32 changes: 0 additions & 32 deletions Hypercube.Mathematics/Vectors/Vector3i.Compability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,36 +47,4 @@ public static implicit operator System.Numerics.Vector3(Vector3i value)
{
return new System.Numerics.Vector3(value.X, value.Y, value.Z);
}

/*
* OpenTK Compatibility
*/

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Vector3i(OpenTK.Mathematics.Vector3i value)
{
return new Vector3i(value.X, value.Y, value.Z);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator OpenTK.Mathematics.Vector3i(Vector3i value)
{
return new OpenTK.Mathematics.Vector3i(value.X, value.Y, value.Z);
}

/*
* OpenToolkit Compatibility
*/

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Vector3i(OpenToolkit.Mathematics.Vector3i vector)
{
return new Vector3i(vector.X, vector.Y, vector.Z);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator OpenToolkit.Mathematics.Vector3i(Vector3i vector)
{
return new OpenToolkit.Mathematics.Vector3i(vector.X, vector.Y, vector.Z);
}
}
32 changes: 0 additions & 32 deletions Hypercube.Mathematics/Vectors/Vector4.Compatibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,4 @@ public static implicit operator System.Numerics.Vector4(Vector4 vector4)
{
return new System.Numerics.Vector4(vector4.X, vector4.Y, vector4.Z, vector4.W);
}

/*
* OpenTK Compatibility
*/

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Vector4(OpenTK.Mathematics.Vector4 vector4)
{
return new Vector4(vector4.X, vector4.Y, vector4.Z, vector4.W);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator OpenTK.Mathematics.Vector4(Vector4 vector4)
{
return new OpenTK.Mathematics.Vector4(vector4.X, vector4.Y, vector4.Z, vector4.W);
}

/*
* OpenToolkit Compatibility
*/

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator OpenToolkit.Mathematics.Vector4(Vector4 vector4)
{
return new OpenToolkit.Mathematics.Vector4(vector4.X, vector4.Y, vector4.Z, vector4.W);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Vector4(OpenToolkit.Mathematics.Vector4 vector4)
{
return new Vector4(vector4.X, vector4.Y, vector4.Z, vector4.W);
}
}

0 comments on commit 7460b77

Please sign in to comment.