Skip to content

Feature/math 3.0 #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sources/Maths/Maths/Legacy/Vector2D.Ops.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public static Vector2D<T> TransformNormal<T>(Vector2D<T> normal, Matrix4X4<T> ma
/// <param name="value">The source vector to be rotated.</param>
/// <param name="rotation">The rotation to apply.</param>
/// <returns>The transformed vector.</returns>
public static Vector2D<T> Transform<T>(Vector2D<T> value, Quaternion<T> rotation)
public static Vector2D<T> Transform<T>(Vector2D<T> value, Legacy.Quaternion<T> rotation)
where T : unmanaged, IFormattable, IEquatable<T>, IComparable<T>
{
T x2 = Scalar.Add(rotation.X, rotation.X);
Expand Down Expand Up @@ -285,4 +285,4 @@ public static Vector2D<T> Multiply<T>(Vector2D<T> value1, Matrix2X2<T> value2)
where T : unmanaged, IFormattable, IEquatable<T>, IComparable<T>
=> value1 * value2;
}
}
}
4 changes: 2 additions & 2 deletions sources/Maths/Maths/Legacy/Vector3D.Ops.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public static Vector3D<T> Transform<T>(Vector3D<T> position, Matrix4X4<T> matrix
/// <param name="rotation">The rotation to apply.</param>
/// <returns>The transformed vector.</returns>
[MethodImpl((MethodImplOptions) 768)]
public static Vector3D<T> Transform<T>(Vector3D<T> value, Quaternion<T> rotation)
public static Vector3D<T> Transform<T>(Vector3D<T> value, Legacy.Quaternion<T> rotation)
where T : unmanaged, IFormattable, IEquatable<T>, IComparable<T>
{
T x2 = Scalar.Add(rotation.X, rotation.X);
Expand Down Expand Up @@ -296,4 +296,4 @@ public static Vector3D<T> TransformNormal<T>(Vector3D<T> normal, Matrix4X4<T> ma
);
}
}
}
}
8 changes: 4 additions & 4 deletions sources/Maths/Maths/Legacy/Vector4D.Ops.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public static Vector4D<T> Transform<T>(Vector2D<T> position, Matrix4X4<T> matrix
/// <param name="rotation">The rotation to apply.</param>
/// <returns>The transformed vector.</returns>
[MethodImpl((MethodImplOptions) 768)]
public static Vector4D<T> Transform<T>(Vector2D<T> value, Quaternion<T> rotation)
public static Vector4D<T> Transform<T>(Vector2D<T> value, Silk.NET.Maths.Legacy.Quaternion<T> rotation)
where T : unmanaged, IFormattable, IEquatable<T>, IComparable<T>
{
T x2 = Scalar.Add(rotation.X, rotation.X);
Expand Down Expand Up @@ -283,7 +283,7 @@ public static Vector4D<T> Transform<T>(Vector3D<T> position, Matrix4X4<T> matrix
/// <param name="rotation">The rotation to apply.</param>
/// <returns>The transformed vector.</returns>
[MethodImpl((MethodImplOptions) 768)]
public static Vector4D<T> Transform<T>(Vector3D<T> value, Quaternion<T> rotation)
public static Vector4D<T> Transform<T>(Vector3D<T> value, Legacy.Quaternion<T> rotation)
where T : unmanaged, IFormattable, IEquatable<T>, IComparable<T>
{
T x2 = Scalar.Add(rotation.X, rotation.X);
Expand Down Expand Up @@ -329,7 +329,7 @@ public static Vector4D<T> Transform<T>(Vector4D<T> vector, Matrix4X4<T> matrix)
/// <param name="rotation">The rotation to apply.</param>
/// <returns>The transformed vector.</returns>
[MethodImpl((MethodImplOptions) 768)]
public static Vector4D<T> Transform<T>(Vector4D<T> value, Quaternion<T> rotation)
public static Vector4D<T> Transform<T>(Vector4D<T> value, Legacy.Quaternion<T> rotation)
where T : unmanaged, IFormattable, IEquatable<T>, IComparable<T>
{
T x2 = Scalar.Add(rotation.X, rotation.X);
Expand All @@ -354,4 +354,4 @@ public static Vector4D<T> Transform<T>(Vector4D<T> value, Quaternion<T> rotation
);
}
}
}
}
8 changes: 4 additions & 4 deletions sources/Maths/Maths/Matrix2X3.Ops.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static Matrix2X3<T> CreateFromAxisAngle<T>(Vector3D<T> axis, T angle)
/// <summary>Creates a rotation matrix from the given Quaternion rotation value.</summary>
/// <param name="quaternion">The source Quaternion.</param>
/// <returns>The rotation matrix.</returns>
public static Matrix2X3<T> CreateFromQuaternion<T>(Quaternion<T> quaternion)
public static Matrix2X3<T> CreateFromQuaternion<T>(Silk.NET.Maths.Legacy.Quaternion<T> quaternion)
where T : unmanaged, IFormattable, IEquatable<T>, IComparable<T>
{
Matrix2X3<T> result = Matrix2X3<T>.Identity;
Expand Down Expand Up @@ -140,7 +140,7 @@ public static Matrix2X3<T> CreateFromQuaternion<T>(Quaternion<T> quaternion)
public static Matrix2X3<T> CreateFromYawPitchRoll<T>(T yaw, T pitch, T roll)
where T : unmanaged, IFormattable, IEquatable<T>, IComparable<T>
{
Quaternion<T> q = Quaternion<T>.CreateFromYawPitchRoll(yaw, pitch, roll);
Legacy.Quaternion<T> q = Legacy.Quaternion<T>.CreateFromYawPitchRoll(yaw, pitch, roll);
return CreateFromQuaternion(q);
}

Expand Down Expand Up @@ -223,7 +223,7 @@ public static unsafe Matrix2X3<T> Lerp<T>(Matrix2X3<T> matrix1, Matrix2X3<T> mat
/// <param name="value">The source matrix to transform.</param>
/// <param name="rotation">The rotation to apply.</param>
/// <returns>The transformed matrix.</returns>
public static Matrix2X3<T> Transform<T>(Matrix2X3<T> value, Quaternion<T> rotation)
public static Matrix2X3<T> Transform<T>(Matrix2X3<T> value, Legacy.Quaternion<T> rotation)
where T : unmanaged, IFormattable, IEquatable<T>, IComparable<T>
{
// Compute rotation matrix.
Expand Down Expand Up @@ -260,4 +260,4 @@ public static Matrix2X3<T> Transform<T>(Matrix2X3<T> value, Quaternion<T> rotati
return new(value.M11 * q1 + value.M12 * q2 + value.M13 * q3, value.M21 * q1 + value.M22 * q2 + value.M23 * q3);
}
}
}
}
14 changes: 7 additions & 7 deletions sources/Maths/Maths/Matrix3X3.Ops.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static Matrix3X3<T> CreateFromAxisAngle<T>(Vector3D<T> axis, T angle)
/// <summary>Creates a rotation matrix from the given Quaternion rotation value.</summary>
/// <param name="quaternion">The source Quaternion.</param>
/// <returns>The rotation matrix.</returns>
public static Matrix3X3<T> CreateFromQuaternion<T>(Quaternion<T> quaternion)
public static Matrix3X3<T> CreateFromQuaternion<T>(Silk.NET.Maths.Legacy.Quaternion<T> quaternion)
where T : unmanaged, IFormattable, IEquatable<T>, IComparable<T>
{
Matrix3X3<T> result = Matrix3X3<T>.Identity;
Expand Down Expand Up @@ -167,7 +167,7 @@ public static Matrix3X3<T> CreateFromQuaternion<T>(Quaternion<T> quaternion)
public static Matrix3X3<T> CreateFromYawPitchRoll<T>(T yaw, T pitch, T roll)
where T : unmanaged, IFormattable, IEquatable<T>, IComparable<T>
{
Quaternion<T> q = Quaternion<T>.CreateFromYawPitchRoll(yaw, pitch, roll);
Legacy.Quaternion<T> q = Legacy.Quaternion<T>.CreateFromYawPitchRoll(yaw, pitch, roll);
return CreateFromQuaternion(q);
}

Expand Down Expand Up @@ -373,7 +373,7 @@ public static Matrix3X3<T> Subtract<T>(Matrix3X3<T> value1, Matrix3X3<T> value2)
/// <param name="scale">The scaling component of the transformation matrix.</param>
/// <param name="rotation">The rotation component of the transformation matrix.</param>
/// <returns>True if the source matrix was successfully decomposed; False otherwise.</returns>
public static bool Decompose<T>(Matrix3X3<T> matrix, out Vector3D<T> scale, out Quaternion<T> rotation)
public static bool Decompose<T>(Matrix3X3<T> matrix, out Vector3D<T> scale, out Silk.NET.Maths.Legacy.Quaternion<T> rotation)
where T : unmanaged, IFormattable, IEquatable<T>, IComparable<T>
{
bool result = true;
Expand Down Expand Up @@ -546,13 +546,13 @@ public static bool Decompose<T>(Matrix3X3<T> matrix, out Vector3D<T> scale, out
if (!Scalar.GreaterThanOrEqual(Scalar.As<float, T>(DecomposeEpsilon), det))
{
// Non-SRT matrix encountered
rotation = Quaternion<T>.Identity;
rotation = Legacy.Quaternion<T>.Identity;
result = false;
}
else
{
// generate the quaternion from the matrix
rotation = Quaternion<T>.CreateFromRotationMatrix(matTemp);
rotation = Legacy.Quaternion<T>.CreateFromRotationMatrix(matTemp);
}
}
}
Expand All @@ -579,7 +579,7 @@ public static unsafe Matrix3X3<T> Lerp<T>(Matrix3X3<T> matrix1, Matrix3X3<T> mat
/// <param name="value">The source matrix to transform.</param>
/// <param name="rotation">The rotation to apply.</param>
/// <returns>The transformed matrix.</returns>
public static Matrix3X3<T> Transform<T>(Matrix3X3<T> value, Quaternion<T> rotation)
public static Matrix3X3<T> Transform<T>(Matrix3X3<T> value, Legacy.Quaternion<T> rotation)
where T : unmanaged, IFormattable, IEquatable<T>, IComparable<T>
{
// Compute rotation matrix.
Expand Down Expand Up @@ -625,4 +625,4 @@ public static unsafe Matrix3X3<T> Transpose<T>(Matrix3X3<T> matrix)
return new(matrix.Column1, matrix.Column2, matrix.Column3);
}
}
}
}
14 changes: 7 additions & 7 deletions sources/Maths/Maths/Matrix4X4.Ops.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public static Matrix4X4<T> CreateFromAxisAngle<T>(Vector3D<T> axis, T angle)
/// <summary>Creates a rotation matrix from the given Quaternion rotation value.</summary>
/// <param name="quaternion">The source Quaternion.</param>
/// <returns>The rotation matrix.</returns>
public static Matrix4X4<T> CreateFromQuaternion<T>(Quaternion<T> quaternion)
public static Matrix4X4<T> CreateFromQuaternion<T>(Silk.NET.Maths.Legacy.Quaternion<T> quaternion)
where T : unmanaged, IFormattable, IEquatable<T>, IComparable<T>
{
Matrix4X4<T> result = Matrix4X4<T>.Identity;
Expand Down Expand Up @@ -237,7 +237,7 @@ public static Matrix4X4<T> CreateFromQuaternion<T>(Quaternion<T> quaternion)
public static Matrix4X4<T> CreateFromYawPitchRoll<T>(T yaw, T pitch, T roll)
where T : unmanaged, IFormattable, IEquatable<T>, IComparable<T>
{
Quaternion<T> q = Quaternion<T>.CreateFromYawPitchRoll(yaw, pitch, roll);
Legacy.Quaternion<T> q = Legacy.Quaternion<T>.CreateFromYawPitchRoll(yaw, pitch, roll);
return CreateFromQuaternion(q);
}

Expand Down Expand Up @@ -1276,7 +1276,7 @@ private static Vector128<T> Permute(Vector128<T> value, byte control)
/// <param name="rotation">The rotation component of the transformation matrix.</param>
/// <param name="translation">The translation component of the transformation matrix</param>
/// <returns>True if the source matrix was successfully decomposed; False otherwise.</returns>
public static bool Decompose<T>(Matrix4X4<T> matrix, out Vector3D<T> scale, out Quaternion<T> rotation, out Vector3D<T> translation)
public static bool Decompose<T>(Matrix4X4<T> matrix, out Vector3D<T> scale, out Silk.NET.Maths.Legacy.Quaternion<T> rotation, out Vector3D<T> translation)
where T : unmanaged, IFormattable, IEquatable<T>, IComparable<T>
{
bool result = true;
Expand Down Expand Up @@ -1454,13 +1454,13 @@ public static bool Decompose<T>(Matrix4X4<T> matrix, out Vector3D<T> scale, out
if (!Scalar.GreaterThanOrEqual(Scalar.As<float, T>(DecomposeEpsilon), det))
{
// Non-SRT matrix encountered
rotation = Quaternion<T>.Identity;
rotation = Legacy.Quaternion<T>.Identity;
result = false;
}
else
{
// generate the quaternion from the matrix
rotation = Quaternion<T>.CreateFromRotationMatrix(matTemp);
rotation = Legacy.Quaternion<T>.CreateFromRotationMatrix(matTemp);
}
}
}
Expand Down Expand Up @@ -1488,7 +1488,7 @@ public static unsafe Matrix4X4<T> Lerp<T>(Matrix4X4<T> matrix1, Matrix4X4<T> mat
/// <param name="value">The source matrix to transform.</param>
/// <param name="rotation">The rotation to apply.</param>
/// <returns>The transformed matrix.</returns>
public static Matrix4X4<T> Transform<T>(Matrix4X4<T> value, Quaternion<T> rotation)
public static Matrix4X4<T> Transform<T>(Matrix4X4<T> value, Legacy.Quaternion<T> rotation)
where T : unmanaged, IFormattable, IEquatable<T>, IComparable<T>
{
// Compute rotation matrix.
Expand Down Expand Up @@ -1539,4 +1539,4 @@ public static unsafe Matrix4X4<T> Transpose<T>(Matrix4X4<T> matrix)
return new(matrix.Column1, matrix.Column2, matrix.Column3, matrix.Column4);
}
}
}
}
4 changes: 2 additions & 2 deletions sources/Maths/Maths/Plane.Ops.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public static Plane<T> Transform<T>(Plane<T> plane, Matrix4X4<T> matrix)
/// <param name="rotation">The Quaternion rotation to apply to the Plane.</param>
/// <returns>A new Plane that results from applying the rotation.</returns>
[MethodImpl((MethodImplOptions) 768)]
public static Plane<T> Transform<T>(Plane<T> plane, Quaternion<T> rotation)
public static Plane<T> Transform<T>(Plane<T> plane, Legacy.Quaternion<T> rotation)
where T : unmanaged, IFormattable, IEquatable<T>, IComparable<T>
{
// Compute rotation matrix.
Expand Down Expand Up @@ -220,4 +220,4 @@ public static Plane<T> Transform<T>(Plane<T> plane, Quaternion<T> rotation)
plane.Distance);
}
}
}
}
Loading